From bbf6fed93e14dd53abfa1757e0631699df76cf3b Mon Sep 17 00:00:00 2001 From: Taken Date: Wed, 30 Aug 2023 10:57:30 +0200 Subject: [PATCH 1/3] Removed useless subcommmands --- commands/devel.js | 74 ----------------------------------------------- 1 file changed, 74 deletions(-) diff --git a/commands/devel.js b/commands/devel.js index 4c30acf..bfd2659 100644 --- a/commands/devel.js +++ b/commands/devel.js @@ -14,10 +14,6 @@ module.exports = { data: new SlashCommandBuilder() .setName('devel') .setDescription('Admin command.') - .addSubcommand(subcommand => - subcommand - .setName('dbclearnonguildmembers') - .setDescription('Clears the database of non-guild members.')) .addSubcommand(subcommand => subcommand .setName('reload') @@ -34,10 +30,6 @@ module.exports = { option .setName('count') .setDescription('Count of messages to purge reactions from.'))) - .addSubcommand(subcommand => - subcommand - .setName('updatemutedrolepermissions') - .setDescription('Update the permissions of the muted role.')) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDMPermission(false), @@ -49,32 +41,6 @@ module.exports = { const guild = interaction.guild; const embedColor = Number(color.replace("#", "0x")); - if (subcommand === 'dbclearnonguildmembers') { - - await interaction.deferReply({ ephemeral: true }) - - if (user.id !== dev) { - interaction.editReply({ content: 'Due to you not screwing something up this command is restricted to only ' + userMentioned, ephemeral: true }) - return - } - - const slothPixel = "https://api.slothpixel.me/api/guilds/" - const verifiedUsers = await verify.find() - - verifiedUsers.forEach(async (user) => { - - const userGuild = await fetch(slothPixel + user.uuid); - - if (userGuild.data.id !== hypixelGuildID) { - await verify.deleteOne({ uuid: user.uuid }) - } - - }) - - interaction.editReply({ content: 'Done!', ephemeral: true }) - - } - if (subcommand === 'reload') { const { exec } = require('child_process'); @@ -137,45 +103,5 @@ module.exports = { await interaction.editReply(`Purged reactions from ${count} message(s).`) } - - if (subcommand === 'updatemutedrolepermissions') { - - await interaction.reply({ content: 'In development', ephemeral: true }) - return - - await interaction.deferReply({ ephemeral: true }) - - const guild = interaction.guild; - const voiceChannels = guild.channels.cache.filter(channel => channel.type === ChannelType.GuildVoice); - const textChannels = guild.channels.cache.filter(channel => channel.type === ChannelType.GuildText); - const mutedRole = guild.roles.cache.get(muted); - - // for (const channel of voiceChannels) { - // await channel[1].permissionOverwrites.create(mutedRole, [ - // { - // id: mutedRole, - // deny: [PermissionFlagsBits.Speak, PermissionFlagsBits.SendMessages] - // }, - // { - // id: guild.roles.everyone, - // deny: [PermissionFlagsBits.Connect, PermissionFlagsBits.ViewChannel] - // }, - // { - // id: "722386801930797056", - // allow: [PermissionFlagsBits.Connect, PermissionFlagsBits.ViewChannel] - // } - // ]) - // } - - const channel = guild.channels.cache.get("1108161929882636380"); - - await channel.permissionOverwrites.edit("961891974472953906", { - 2097152: true, - 2048: true - }) - - await interaction.editReply({ content: 'Updated permissions for voice channels.', ephemeral: true }) - - } } }; \ No newline at end of file From 1977287abbd71f1e98b545e947569a5834f8487d Mon Sep 17 00:00:00 2001 From: Taken Date: Wed, 30 Aug 2023 11:03:03 +0200 Subject: [PATCH 2/3] 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 From 4a3c2b3fa79e01def7ef8bcff0d77b6274c52855 Mon Sep 17 00:00:00 2001 From: Taken Date: Wed, 30 Aug 2023 11:09:28 +0200 Subject: [PATCH 3/3] Fixed issuw with script --- scripts/deploy-commands.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/deploy-commands.js b/scripts/deploy-commands.js index f04055f..cbfbc30 100644 --- a/scripts/deploy-commands.js +++ b/scripts/deploy-commands.js @@ -18,12 +18,12 @@ else if (arg === '--prod') { // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment for (const file of commandFiles) { - const command = require(`./commands/${file}`); + const command = require(`../commands/${file}`); commands.push(command.data.toJSON()); } for (const file of contentMenuCommands) { - const command = require(`./commands-contextmenu/${file}`); + const command = require(`../commands-contextmenu/${file}`); commands.push(command.data.toJSON()); } @@ -56,7 +56,7 @@ else if (arg === '--dev') { // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment for (const file of commandFiles) { - const command = require(`./commands-testing/${file}`); + const command = require(`../commands-testing/${file}`); commands.push(command.data.toJSON()); }