From 1977287abbd71f1e98b545e947569a5834f8487d Mon Sep 17 00:00:00 2001 From: Taken Date: Wed, 30 Aug 2023 11:03:03 +0200 Subject: [PATCH] Updating scripts and removing useless commands --- .gitignore | 1 - commands-testing/maketestembed.js | 41 ------------------- package.json | 5 +-- .../deploy-commands.js | 0 scripts/dev-deploy.js | 41 +++++++++++++++++++ 5 files changed, 43 insertions(+), 45 deletions(-) delete mode 100644 commands-testing/maketestembed.js rename deploy-commands.js => scripts/deploy-commands.js (100%) create mode 100644 scripts/dev-deploy.js diff --git a/.gitignore b/.gitignore index 31ec78e..bbeb5e0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ node_modules/* .env .prettierrc .editorconfig -dev-deploy.js diff --git a/commands-testing/maketestembed.js b/commands-testing/maketestembed.js deleted file mode 100644 index eb92fd1..0000000 --- a/commands-testing/maketestembed.js +++ /dev/null @@ -1,41 +0,0 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); - -module.exports = { - name: 'maketestembed', - description: 'Make a test embed', - type: 'slash', - - data: new SlashCommandBuilder() - .setName('maketestembed') - .setDescription('Make a test embed') - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - - async execute(interaction) { - - await interaction.reply({ - embeds: [{ - title: 'Test Embed', - description: 'This is a test embed', - color: 0xff0000, - fields: [ - { - name: 'Field 1', - value: 'This is field 1', - }, - { - name: 'Field 2', - value: 'This is field 2', - }, - { - name: 'Field 3', - value: 'This is field 3', - } - ], - footer: { - text: 'This is a test embed', - }, - }] - }); - - } -} diff --git a/package.json b/package.json index e6b7926..ec2c080 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,8 @@ "description": "", "main": "index.js", "scripts": { - "prod:build": "node deploy-commands.js --prod", - "prod:build:context": "node deploy-commands.js --contextmenu", - "dev:build": "node deploy-commands.js --dev" + "prod:build": "node scripts/deploy-commands.js --prod", + "dev:build": "node scripts/deploy-commands.js --dev" }, "author": "Taken", "license": "ISC", diff --git a/deploy-commands.js b/scripts/deploy-commands.js similarity index 100% rename from deploy-commands.js rename to scripts/deploy-commands.js diff --git a/scripts/dev-deploy.js b/scripts/dev-deploy.js new file mode 100644 index 0000000..1a19b27 --- /dev/null +++ b/scripts/dev-deploy.js @@ -0,0 +1,41 @@ +const { REST, Routes } = require('discord.js'); +const env = require('dotenv').config(); +const token = process.env.TOKEN; +const clientId = process.env.DEVID; +const guildId = process.env.GUILDID; + +const commands = []; +// Grab all the command files from the commands directory you created earlier +// const commandFiles = fs.readdirSync('./commands-testing').filter(file => file.endsWith('.js')); + +const commandFiles = [ + './commands/config.js', +] + +// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment +for (const file of commandFiles) { + const command = require(`${file}`); + commands.push(command.data.toJSON()); +} + +// Construct and prepare an instance of the REST module +const rest = new REST({ version: '10' }).setToken(token); + + +// and deploy your commands! + (async () => { + try { + console.log(`Started refreshing ${commands.length} application (/) commands.`); + + // The put method is used to fully refresh all commands in the guild with the current set + const data = await rest.put( + Routes.applicationGuildCommands(clientId, guildId), + { body: commands }, + ); + + console.log(`Successfully reloaded ${data.length} application (/) commands.`); + } catch (error) { + // And of course, make sure you catch and log any errors! + console.error(error); + } + })(); \ No newline at end of file