Minor fix

This commit is contained in:
2023-04-19 12:12:41 +02:00
parent 8e5c4af4b6
commit 247e7192cc

View File

@@ -13,6 +13,7 @@ else if (arg === '--prod') {
const commands = [];
// Grab all the command files from the commands directory you created earlier
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const contentMenuCommands = fs.readdirSync('./commands-contextmenu').filter(file => file.endsWith('.js'));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
@@ -20,6 +21,11 @@ else if (arg === '--prod') {
commands.push(command.data.toJSON());
}
for (const file of contentMenuCommands) {
const command = require(`./commands-contextmenu/${file}`);
commands.push(command.data.toJSON());
}
// Construct and prepare an instance of the REST module
const rest = new REST({ version: '10' }).setToken(token);
@@ -74,38 +80,7 @@ else if (arg === '--dev') {
console.error(error);
}
})();
} else if (arg === '--contextmenu') {
const commands = [];
// Grab all the command files from the commands directory you created earlier
const commandFiles = fs.readdirSync('./commands-contextmenu').filter(file => file.endsWith('.js'));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
const command = require(`./commands-contextmenu/${file}`);
commands.push(command.data.toJSON());
}
// Construct and prepare an instance of the REST module
const rest = new REST({ version: '10' }).setToken(token);
// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application contextmenu (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application contextmenu (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
} else if (arg && arg !== '--prod' && arg !== '--dev' && arg !== '--contextmenu') {
else if (arg && arg !== '--prod' && arg !== '--dev') {
console.log('Invalid argument!');
}