From e0cf09c93670a6750c22953b078e5944676d607a Mon Sep 17 00:00:00 2001 From: Taken Date: Mon, 4 Dec 2023 11:22:57 +0100 Subject: [PATCH 1/2] Updated unban command --- src/commands/unban.js | 10 ++++++++++ src/events/autocomplete/unban.js | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/commands/unban.js b/src/commands/unban.js index 288e94e..9030451 100644 --- a/src/commands/unban.js +++ b/src/commands/unban.js @@ -37,6 +37,16 @@ module.exports = { const mod = interaction.user const embedColor = Number(color.replace("#", "0x")) + if (userid === "none") { + await interaction.editReply({ + embeds: [{ + description: "You haven't specified a user to unban", + color: embedColor + }] + }) + return + } + const user = await interaction.client.users.fetch(userid) await interaction.guild.members.unban(user.id, reason) diff --git a/src/events/autocomplete/unban.js b/src/events/autocomplete/unban.js index bf9dae0..36d1d29 100644 --- a/src/events/autocomplete/unban.js +++ b/src/events/autocomplete/unban.js @@ -11,7 +11,13 @@ module.exports = { const focusedOption = interaction.options.getFocused(true) if (focusedOption.name !== "user") return - console.log + if (focusedOption.value === "") { + await interaction.respond([{ + name: "Please start typing a username to unban", + value: "none" + }]) + return + } const bannedUsers = await interaction.guild.bans.fetch() const filteredUsers = bannedUsers.filter((user) => From 0d3b01bbff6e51db1932cb56ede3483c45fb14b5 Mon Sep 17 00:00:00 2001 From: Taken Date: Mon, 4 Dec 2023 11:23:27 +0100 Subject: [PATCH 2/2] Added delete commands script --- package.json | 1 + scripts/delete-commands.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 scripts/delete-commands.js diff --git a/package.json b/package.json index b9eb2c2..46dbba2 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "nodemon", "dev:build": "node scripts/dev-deploy.js", + "dev:delete": "node scripts/delete-commands.js", "lint": "eslint_d src", "lint:fix": "eslint_d --fix src", "prod:build:global": "node scripts/deploy-commands.js --prod", diff --git a/scripts/delete-commands.js b/scripts/delete-commands.js new file mode 100644 index 0000000..7ba1ccd --- /dev/null +++ b/scripts/delete-commands.js @@ -0,0 +1,20 @@ +const { REST, Routes } = require("discord.js") +require("dotenv").config() +const token = process.env.DEVTOKEN +const clientId = process.env.DEVID +const guildId = process.env.GUILDID +const rest = new REST({ version: "10" }).setToken(token) + +async function deleteCommands() { + try { + console.log("Started deleting application (/) commands.") + await rest.put( + Routes.applicationGuildCommands(clientId, guildId), + { body: [] }, + ) + console.log("Successfully deleted application (/) commands.") + } catch (error) { + console.error(error) + } +} +deleteCommands()