summaryrefslogtreecommitdiff
path: root/src/utils/commandRegistry.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/commandRegistry.js')
-rw-r--r--src/utils/commandRegistry.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/commandRegistry.js b/src/utils/commandRegistry.js
new file mode 100644
index 0000000..918e7b3
--- /dev/null
+++ b/src/utils/commandRegistry.js
@@ -0,0 +1,16 @@
+const { REST, Routes } = require('discord.js');
+
+async function registerCommands(commands, token, clientId) {
+ const rest = new REST({ version: '10' }).setToken(token);
+
+ try {
+ await rest.put(
+ Routes.applicationCommands(clientId),
+ { body: commands.map(cmd => cmd.toJSON()) }
+ );
+ } catch (error) {
+ console.error('Error registering commands:', error);
+ }
+}
+
+module.exports = { registerCommands };