From b52e09a3eb7a695f394aca5dd23f39989cce7094 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Tue, 29 Mar 2022 22:03:09 -0500 Subject: [PATCH] Use pure JS for deploying the commands --- src/deploy-commands.js | 20 +++++++++++++++++++ ...loy-commands.ts => deploy-commands.ts.bak} | 0 tsconfig.json | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/deploy-commands.js rename src/{deploy-commands.ts => deploy-commands.ts.bak} (100%) diff --git a/src/deploy-commands.js b/src/deploy-commands.js new file mode 100644 index 0000000..0b7b816 --- /dev/null +++ b/src/deploy-commands.js @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +const fs = require('node:fs'); +const { REST } = require('@discordjs/rest'); +const { Routes } = require('discord-api-types/v9'); +const { clientId, token } = require('./helpers/env'); + +const commands = []; +const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); + +for (const file of commandFiles) { + const command = require(`./commands/${file}`); + commands.push(command.data.toJSON()); +} + +const rest = new REST({ version: '9' }).setToken(token); + +rest.put(Routes.applicationCommands(clientId), { body: commands }) + .then(() => console.log('Successfully registered application commands.')) + .catch(console.error); diff --git a/src/deploy-commands.ts b/src/deploy-commands.ts.bak similarity index 100% rename from src/deploy-commands.ts rename to src/deploy-commands.ts.bak diff --git a/tsconfig.json b/tsconfig.json index cf9211b..63f9120 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,7 +37,7 @@ // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ + "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */