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() 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) =>