add structure for simplifie creation of global command

This commit is contained in:
Arthur Puechberty
2026-01-17 15:13:22 +01:00
parent 08647924e3
commit d5f0f4c30b
11 changed files with 593 additions and 17 deletions
+6 -8
View File
@@ -13,17 +13,15 @@ module.exports = async (client, guildId = null) => {
========================= */
if (!guildId) {
const globalCommands = [
{
name: 'ping',
description: 'Replies with Pong!',
},
];
const globalCommands = [];
client.commands.forEach((command) => {
globalCommands.push(command.data.toJSON());
});
try {
console.log('Refreshing GLOBAL slash commands...');
await rest.put(
Routes.applicationCommands(CLIENT_ID),
Routes.applicationCommands(client.user.id),
{ body: globalCommands }
);
console.log('Global slash commands loaded');
@@ -69,7 +67,7 @@ module.exports = async (client, guildId = null) => {
try {
await rest.put(
Routes.applicationGuildCommands(CLIENT_ID, guild.id),
Routes.applicationGuildCommands(client.user.id, guild.id),
{ body: guildCommands }
);
console.log(`Guild commands updated for ${guild.name}`);