From e589752edcd9a4eba3c78e6251466e713f6efcbd Mon Sep 17 00:00:00 2001 From: KieranRobson Date: Tue, 22 Aug 2023 15:11:55 +0100 Subject: [PATCH] feat: Add nukecourserep - related #7 --- src/slashCommands/admin/nukecoursereps.js | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/slashCommands/admin/nukecoursereps.js diff --git a/src/slashCommands/admin/nukecoursereps.js b/src/slashCommands/admin/nukecoursereps.js new file mode 100644 index 0000000..5b4aa3d --- /dev/null +++ b/src/slashCommands/admin/nukecoursereps.js @@ -0,0 +1,53 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); + +module.exports = { + ...new SlashCommandBuilder() + .setName('nukecourserep') + .setDescription('Replaces course rep') + .setDefaultMemberPermissions( + PermissionFlagsBits.KickMembers || PermissionFlagsBits.BanMembers + ), + + /** + * + * @param {Client} client + * @param {CommandInteraction} interaction + * @param {String[]} args + */ + + run: async (client, interaction) => { + await interaction.deferReply({ + ephemeral: true, + }); + + try { + const role = interaction.guild.roles.cache.find( + (r) => r.name === 'Course Rep' + ); + + interaction.guild.roles.create({ + name: role.name, + color: role.color, + hoist: role.hoist, + position: role.position, + permissions: role.permissions, + mentionable: role.mentionable, + }); + + role.delete(role.id, 'The Nuke Course Rep Command Was Run. '); + + const newRole = interaction.guild.roles.cache.find( + (r) => r.name === 'Course Rep' + ); + interaction.editReply( + `Role has been replaced. The new role ID is: ${newRole.id}. Please pass this to Kieran.`, + true + ); + } catch (error) { + interaction.editReply({ + content: error, + ephemeral: true, + }); + } + }, +};