From 0699f514abbeb5bdfa0a978eb96f8f7995bc1773 Mon Sep 17 00:00:00 2001 From: DeathVenom54 Date: Sun, 9 Oct 2022 09:03:29 +0530 Subject: [PATCH] [feat](syncCommands) add syncAllGlobalCommands --- src/core/commands/syncCommands.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/commands/syncCommands.ts b/src/core/commands/syncCommands.ts index d249381..675de30 100644 --- a/src/core/commands/syncCommands.ts +++ b/src/core/commands/syncCommands.ts @@ -84,3 +84,19 @@ export const syncCommands = async (client: Client): Promise => { application.client.logMethod('Successfully synced commands', 'verbose'); }; + +/** + * Force-syncs all global slash commands + * + * @param {Client} client The bot's client + */ +export const syncAllGlobalCommands = async (client: Client): Promise => { + const application = client.application?.partial ? await client.application?.fetch() : client.application; + if (!application) throw new Error('Client application not found'); + + // sync global commands + const global = client.commands.get('global'); + if (global) { + await application.commands.set(global); + } +};