From 9feff8c62f849a6e56a9c78ea75073aa66b6aee0 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Fri, 7 Jul 2023 00:29:27 +0200 Subject: [PATCH] Update deploy commands --- deploy-commands.js | 1 + deploy-system-commands.js | 32 ++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 deploy-system-commands.js diff --git a/deploy-commands.js b/deploy-commands.js index b035e18..c0018bc 100644 --- a/deploy-commands.js +++ b/deploy-commands.js @@ -16,6 +16,7 @@ const rest = new REST({ version: '10' }).setToken(token); (async () => { try { + console.log("DEPLOYING BOT SLASH COMMANDS"); console.log("Commands: ", commands.map((command) => {return command.name})); console.log('Started refreshing application (/) commands.'); diff --git a/deploy-system-commands.js b/deploy-system-commands.js new file mode 100644 index 0000000..2af6e57 --- /dev/null +++ b/deploy-system-commands.js @@ -0,0 +1,32 @@ +const fs = require('node:fs'); +const { REST, Routes } = require('discord.js'); +const { token, clientId, systemServerGuildId } = require('./config.json'); + +const systemCommands = []; +const systemCommandFiles = fs + .readdirSync('./system-commands') + .filter((file) => file.endsWith('.js')); + +for (const file of systemCommandFiles) { + const systemCommand = require(`./system-commands/${file}`); + systemCommands.push(systemCommand.data.toJSON()); +} + +const rest = new REST({ version: '10' }).setToken(token); + +(async () => { + try { + console.log("DEPLOYING SYSTEM SLASH COMMANDS"); + console.log("System Commands: ", systemCommands.map((systemCommand) => {return systemCommand.name})); + + console.log('Started refreshing application (/) system commands.'); + + await rest.put(Routes.applicationGuildCommands(clientId, systemServerGuildId), { + body: systemCommands + }); + + console.log('Successfully reloaded application (/) system commands.'); + } catch (error) { + console.error(error); + } +})(); diff --git a/package.json b/package.json index de88e21..d9bbb1f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "node ./index.js", - "deploy": "node ./deploy-commands.js" + "deploy": "node ./deploy-commands.js && node ./deploy-system-commands.js" }, "author": "", "license": "ISC",