From 87fa53abc930d255c0354992d3b3e4c202f6479d Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Thu, 24 Nov 2022 00:56:20 +1100 Subject: [PATCH] finally fix the admin check --- src/commands/bonk.ts | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/commands/bonk.ts b/src/commands/bonk.ts index 5565c4d..d835355 100644 --- a/src/commands/bonk.ts +++ b/src/commands/bonk.ts @@ -3,21 +3,18 @@ import { TClient } from 'src/client'; export default { async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ //if (!client.isStaff(interaction.member) && interaction.channelId == '468835415093411863') return interaction.reply('This command is restricted to staff only in this channel due to high usage.') - const member = interaction.options.getUser('member'); + const member = interaction.options.getMember('member'); const reason = interaction.options.getString('reason'); - const adminPerm = interaction.member.permissions.has('Administrator') - if (!member) { - return interaction.reply('You can\'t bonk the ghost.') - } else { - //if (member && adminPerm) return interaction.reply('You cannot bonk an admin!') | i need halp with this - if (member) { - const embed = new client.embed().setColor(client.config.embedColor) - .setDescription(`> <@${member.id}> has been bonked!\n${reason?.length == null ? '' : `> Reason: **${reason}**`}`) - .setImage('https://media.tenor.com/7tRddlNUNNcAAAAd/hammer-on-head-minions.gif') - .setFooter({text: `Bonk count for ${member.tag}: ${await client.bonkCount.getUser(member.id).toLocaleString('en-US')}`}) - interaction.reply({embeds: [embed]}) - client.bonkCount._incrementUser(member.id).forceSave(); - } + const adminPerm = member.permissions.has('Administrator'); + + if (adminPerm) return interaction.reply('You cannot bonk an admin!') + if (member) { + const embed = new client.embed().setColor(client.config.embedColor) + .setDescription(`> <@${member.id}> has been bonked!\n${reason?.length == null ? '' : `> Reason: **${reason}**`}`) + .setImage('https://media.tenor.com/7tRddlNUNNcAAAAd/hammer-on-head-minions.gif') + .setFooter({text: `Bonk count for ${member.user.tag}: ${await client.bonkCount.getUser(member.id).toLocaleString('en-US')}`}) + interaction.reply({embeds: [embed]}) + client.bonkCount._incrementUser(member.id).forceSave(); } }, data: new SlashCommandBuilder() @@ -25,7 +22,8 @@ export default { .setDescription('Bonk a member') .addUserOption((opt)=>opt .setName('member') - .setDescription('Which member to bonk?')) + .setDescription('Which member to bonk?') + .setRequired(true)) .addStringOption((opt)=>opt .setName('reason') .setDescription('Reason for the bonk'))