From 3ae3aab9b1ba4863c31b4627e16cfe51a36389ae Mon Sep 17 00:00:00 2001 From: drippy-cat <95929812+drippy-cat@users.noreply.github.com> Date: Tue, 6 Dec 2022 09:59:28 -0500 Subject: [PATCH] created and edited admin.ts just need to create a new role called "Goody wannabe admin". Add the role ID in line 4. Also, probably should double check that all this code works. --- slash/admin.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 slash/admin.ts diff --git a/slash/admin.ts b/slash/admin.ts new file mode 100644 index 0000000..f66fb26 --- /dev/null +++ b/slash/admin.ts @@ -0,0 +1,40 @@ +// Goofy person wanted admin >:) +// The record maps choice name -> Discord role ID +const ROLES: Record = { + 'Admin :)': '############', +}; + +discord.interactions.commands.register( + { + name: 'admin', + description: 'Get admin perms!!!!', + ackBehavior: discord.interactions.commands.AckBehavior.MANUAL, + options: (opts) => ({ + role: opts.string({ + required: true, + description: 'Add/remove admin', + choices: Object.keys(ROLES) + }) + }) + }, + async (interaction, { role }) => { + const roleId = ROLES[role]; + if (!roleId) { + await interaction.respondEphemeral( + '❌ Something unexpected happened! Please ping Echo/Piplup so they can fix this!' + ); + return; + } + if (interaction.member.roles.includes(roleId)) { + await interaction.member.removeRole(roleId); + await interaction.respondEphemeral( + `✅ Since you already had the \`${role}\` role, I removed it from you!` + ); + return; + } + await interaction.member.addRole(roleId); + await interaction.respondEphemeral( + `✅ You've been given the \`${role}\` role!` + ); + } +);