pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 1 | import { LoadingEmbed } from './../../utils/defaultEmbeds.js'; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 2 | import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js"; |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 3 | import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
| 4 | import { WrappedCheck } from "jshaiku"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 5 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 6 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
| 7 | import confirmationMessage from "../../utils/confirmationMessage.js"; |
| 8 | import keyValueList from "../../utils/generateKeyValueList.js"; |
| 9 | import humanizeDuration from "humanize-duration"; |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 10 | import client from "../../utils/client.js"; |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 11 | import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js"; |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 12 | |
| 13 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 14 | builder |
| 15 | .setName("mute") |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 16 | .setDescription("Mutes a member, stopping them from talking in the server") |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 17 | .addUserOption(option => option.setName("user").setDescription("The user to mute").setRequired(true)) |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 18 | .addIntegerOption(option => option.setName("days").setDescription("The number of days to mute the user for | Default: 0").setMinValue(0).setMaxValue(27).setRequired(false)) |
| 19 | .addIntegerOption(option => option.setName("hours").setDescription("The number of hours to mute the user for | Default: 0").setMinValue(0).setMaxValue(23).setRequired(false)) |
| 20 | .addIntegerOption(option => option.setName("minutes").setDescription("The number of minutes to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false)) |
| 21 | .addIntegerOption(option => option.setName("seconds").setDescription("The number of seconds to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false)) |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 22 | |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 23 | const callback = async (interaction: CommandInteraction): Promise<any> => { |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 24 | const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 25 | const user = interaction.options.getMember("user") as GuildMember |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 26 | const time = { |
| 27 | days: interaction.options.getInteger("days") || 0, |
| 28 | hours: interaction.options.getInteger("hours") || 0, |
| 29 | minutes: interaction.options.getInteger("minutes") || 0, |
| 30 | seconds: interaction.options.getInteger("seconds") || 0 |
| 31 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 32 | let config = await client.database.guilds.read(interaction.guild.id) |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 33 | let serverSettingsDescription = (config.moderation.mute.timeout ? "given a timeout" : "") |
| 34 | if (config.moderation.mute.role) serverSettingsDescription += (serverSettingsDescription ? " and " : "") + `given the <@&${config.moderation.mute.role}> role` |
| 35 | |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 36 | let muteTime = (time.days * 24 * 60 * 60) + (time.hours * 60 * 60) + (time.minutes * 60) + time.seconds |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 37 | if (muteTime === 0) { |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 38 | let m = await interaction.reply({embeds: [ |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 39 | new EmojiEmbed() |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 40 | .setEmoji("PUNISH.MUTE.GREEN") |
| 41 | .setTitle("Mute") |
| 42 | .setDescription("How long should the user be muted") |
| 43 | .setStatus("Success") |
| 44 | ], components: [ |
| 45 | new MessageActionRow().addComponents([ |
| 46 | new Discord.MessageButton() |
| 47 | .setCustomId("1m") |
| 48 | .setLabel("1 Minute") |
| 49 | .setStyle("SECONDARY"), |
| 50 | new Discord.MessageButton() |
| 51 | .setCustomId("10m") |
| 52 | .setLabel("10 Minutes") |
| 53 | .setStyle("SECONDARY"), |
| 54 | new Discord.MessageButton() |
| 55 | .setCustomId("30m") |
| 56 | .setLabel("30 Minutes") |
| 57 | .setStyle("SECONDARY"), |
| 58 | new Discord.MessageButton() |
| 59 | .setCustomId("1h") |
| 60 | .setLabel("1 Hour") |
| 61 | .setStyle("SECONDARY") |
| 62 | ]), |
| 63 | new MessageActionRow().addComponents([ |
| 64 | new Discord.MessageButton() |
| 65 | .setCustomId("6h") |
| 66 | .setLabel("6 Hours") |
| 67 | .setStyle("SECONDARY"), |
| 68 | new Discord.MessageButton() |
| 69 | .setCustomId("12h") |
| 70 | .setLabel("12 Hours") |
| 71 | .setStyle("SECONDARY"), |
| 72 | new Discord.MessageButton() |
| 73 | .setCustomId("1d") |
| 74 | .setLabel("1 Day") |
| 75 | .setStyle("SECONDARY"), |
| 76 | new Discord.MessageButton() |
| 77 | .setCustomId("1w") |
| 78 | .setLabel("1 Week") |
| 79 | .setStyle("SECONDARY") |
| 80 | ]), |
| 81 | new MessageActionRow().addComponents([ |
| 82 | new Discord.MessageButton() |
| 83 | .setCustomId("cancel") |
| 84 | .setLabel("Cancel") |
| 85 | .setStyle("DANGER") |
| 86 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 87 | ]) |
| 88 | ], ephemeral: true, fetchReply: true}) |
| 89 | let component; |
| 90 | try { |
pineafan | c6158ab | 2022-06-17 16:34:07 +0100 | [diff] [blame] | 91 | component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000}); |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 92 | } catch { return } |
| 93 | component.deferUpdate(); |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 94 | if (component.customId === "cancel") return interaction.editReply({embeds: [new EmojiEmbed() |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 95 | .setEmoji("PUNISH.MUTE.RED") |
| 96 | .setTitle("Mute") |
| 97 | .setDescription("Mute cancelled") |
| 98 | .setStatus("Danger") |
| 99 | ]}) |
| 100 | switch (component.customId) { |
| 101 | case "1m": { muteTime = 60; break; } |
| 102 | case "10m": { muteTime = 60 * 10; break; } |
| 103 | case "30m": { muteTime = 60 * 30; break; } |
| 104 | case "1h": { muteTime = 60 * 60; break; } |
| 105 | case "6h": { muteTime = 60 * 60 * 6; break; } |
| 106 | case "12h": { muteTime = 60 * 60 * 12; break; } |
| 107 | case "1d": { muteTime = 60 * 60 * 24; break; } |
| 108 | case "1w": { muteTime = 60 * 60 * 24 * 7; break; } |
| 109 | } |
| 110 | } else { |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 111 | await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 112 | } |
pineafan | 5d1908e | 2022-02-28 21:34:47 +0000 | [diff] [blame] | 113 | // TODO:[Modals] Replace this with a modal |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 114 | let reason = null; |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 115 | let notify = true; |
| 116 | let createAppealTicket = false; |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 117 | let confirmation; |
| 118 | while (true) { |
| 119 | confirmation = await new confirmationMessage(interaction) |
| 120 | .setEmoji("PUNISH.MUTE.RED") |
| 121 | .setTitle("Mute") |
| 122 | .setDescription(keyValueList({ |
| 123 | "user": renderUser(user.user), |
| 124 | "time": `${humanizeDuration(muteTime * 1000, {round: true})}`, |
| 125 | "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*" |
| 126 | }) |
| 127 | + `The user will be ` + serverSettingsDescription + "\n" |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 128 | + `The user **will${notify ? '' : ' not'}** be notified\n\n` |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 129 | + `Are you sure you want to mute <@!${user.id}>?`) |
| 130 | .setColor("Danger") |
| 131 | .addCustomBoolean( |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 132 | "appeal", "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)), |
| 133 | async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason), |
| 134 | "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket) |
| 135 | .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify) |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 136 | .addReasonButton(reason ?? "") |
| 137 | .send(true) |
| 138 | reason = reason ?? "" |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 139 | if (confirmation.cancelled) return |
| 140 | if (confirmation.success) break |
| 141 | if (confirmation.newReason) reason = confirmation.newReason |
| 142 | if (confirmation.components) { |
| 143 | notify = confirmation.components.notify.active |
| 144 | createAppealTicket = confirmation.components.appeal.active |
| 145 | } |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 146 | } |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 147 | if (confirmation.success) { |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 148 | let dmd = false |
pineafan | 5d1908e | 2022-02-28 21:34:47 +0000 | [diff] [blame] | 149 | let dm; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 150 | let config = await client.database.guilds.read(interaction.guild.id); |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 151 | try { |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 152 | if (notify) { |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 153 | dm = await user.send({ |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 154 | embeds: [new EmojiEmbed() |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 155 | .setEmoji("PUNISH.MUTE.RED") |
| 156 | .setTitle("Muted") |
| 157 | .setDescription(`You have been muted in ${interaction.guild.name}` + |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 158 | (reason ? ` for:\n> ${reason}` : ".\n\n" + |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 159 | `You will be unmuted at: <t:${Math.round((new Date).getTime() / 1000) + muteTime}:D> at <t:${Math.round((new Date).getTime() / 1000) + muteTime}:T> (<t:${Math.round((new Date).getTime() / 1000) + muteTime}:R>)`) + |
| 160 | (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ``)) |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 161 | .setStatus("Danger") |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 162 | ], |
| 163 | components: [new MessageActionRow().addComponents(config.moderation.mute.text ? [new MessageButton() |
| 164 | .setStyle("LINK") |
| 165 | .setLabel(config.moderation.mute.text) |
| 166 | .setURL(config.moderation.mute.link) |
| 167 | ] : [])] |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 168 | }) |
| 169 | dmd = true |
| 170 | } |
| 171 | } catch {} |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 172 | let member = user |
| 173 | let errors = 0 |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 174 | try { |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 175 | if (config.moderation.mute.timeout) { |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 176 | await member.timeout(muteTime * 1000, reason || "No reason provided") |
| 177 | if (config.moderation.mute.role !== null) { |
| 178 | await member.roles.add(config.moderation.mute.role) |
| 179 | await client.database.eventScheduler.schedule("naturalUnmute", new Date().getTime() + muteTime * 1000, { |
| 180 | guild: interaction.guild.id, |
| 181 | user: user.id, |
| 182 | expires: new Date().getTime() + muteTime * 1000 |
| 183 | }) |
| 184 | } |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 185 | } |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 186 | } catch { errors++ } |
| 187 | try { |
| 188 | if (config.moderation.mute.role !== null) { |
| 189 | await member.roles.add(config.moderation.mute.role) |
| 190 | await client.database.eventScheduler.schedule("unmuteRole", new Date().getTime() + muteTime * 1000, { |
| 191 | guild: interaction.guild.id, |
| 192 | user: user.id, |
| 193 | role: config.moderation.mute.role |
| 194 | }) |
| 195 | } |
| 196 | } catch (e){ console.log(e); errors++ } |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 197 | if (errors === 2) { |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 198 | await interaction.editReply({embeds: [new EmojiEmbed() |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 199 | .setEmoji("PUNISH.MUTE.RED") |
| 200 | .setTitle(`Mute`) |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 201 | .setDescription("Something went wrong and the user was not muted") |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 202 | .setStatus("Danger") |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 203 | ], components: []}) // TODO: make this clearer |
pineafan | 5d1908e | 2022-02-28 21:34:47 +0000 | [diff] [blame] | 204 | if (dmd) await dm.delete() |
| 205 | return |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 206 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 207 | try { await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason) } catch {} |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 208 | let failed = (dmd === false && notify) |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 209 | await interaction.editReply({embeds: [new EmojiEmbed() |
pineafan | 5d1908e | 2022-02-28 21:34:47 +0000 | [diff] [blame] | 210 | .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`) |
| 211 | .setTitle(`Mute`) |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 212 | .setDescription("The member was muted" + (failed ? ", but could not be notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ``)) |
pineafan | 5d1908e | 2022-02-28 21:34:47 +0000 | [diff] [blame] | 213 | .setStatus(failed ? "Warning" : "Success") |
| 214 | ], components: []}) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 215 | let data = { |
| 216 | meta:{ |
| 217 | type: 'memberMute', |
| 218 | displayName: 'Member Muted', |
| 219 | calculateType: 'guildMemberPunish', |
| 220 | color: NucleusColors.yellow, |
| 221 | emoji: 'PUNISH.WARN.YELLOW', |
| 222 | timestamp: new Date().getTime() |
| 223 | }, |
| 224 | list: { |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 225 | memberId: entry(member.user.id, `\`${member.user.id}\``), |
| 226 | name: entry(member.user.id, renderUser(member.user)), |
| 227 | mutedUntil: entry(new Date().getTime() + muteTime * 1000, renderDelta(new Date().getTime() + muteTime * 1000)), |
| 228 | muted: entry(new Date().getTime(), renderDelta(new Date().getTime() - 1000)), |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 229 | mutedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)), |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 230 | reason: entry(reason, reason ? reason : '*No reason provided*') |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 231 | }, |
| 232 | hidden: { |
| 233 | guild: interaction.guild.id |
| 234 | } |
| 235 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 236 | log(data); |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 237 | } else { |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 238 | await interaction.editReply({embeds: [new EmojiEmbed() |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 239 | .setEmoji("PUNISH.MUTE.GREEN") |
| 240 | .setTitle(`Mute`) |
| 241 | .setDescription("No changes were made") |
| 242 | .setStatus("Success") |
| 243 | ], components: []}) |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => { |
pineafan | 5d1908e | 2022-02-28 21:34:47 +0000 | [diff] [blame] | 248 | let member = (interaction.member as GuildMember) |
| 249 | let me = (interaction.guild.me as GuildMember) |
| 250 | let apply = (interaction.options.getMember("user") as GuildMember) |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 251 | if (member === null || me === null || apply === null) throw "That member is not in the server" |
pineafan | 5d1908e | 2022-02-28 21:34:47 +0000 | [diff] [blame] | 252 | let memberPos = member.roles ? member.roles.highest.position : 0 |
| 253 | let mePos = me.roles ? me.roles.highest.position : 0 |
| 254 | let applyPos = apply.roles ? apply.roles.highest.position : 0 |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 255 | // Check if Nucleus can mute the member |
pineafan | 5d1908e | 2022-02-28 21:34:47 +0000 | [diff] [blame] | 256 | if (! (mePos > applyPos)) throw "I do not have a role higher than that member" |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 257 | // Check if Nucleus has permission to mute |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 258 | if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission"; |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 259 | // Do not allow the user to have admin or be the owner |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 260 | if (apply.permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id === interaction.guild.ownerId) throw "You cannot mute an admin or the owner" |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 261 | // Do not allow muting Nucleus |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 262 | if (member.id === me.id) throw "I cannot mute myself" |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 263 | // Allow the owner to mute anyone |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 264 | if (member.id === interaction.guild.ownerId) return true |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 265 | // Check if the user has moderate_members permission |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 266 | if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission"; |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 267 | // Check if the user is below on the role list |
pineafan | 5d1908e | 2022-02-28 21:34:47 +0000 | [diff] [blame] | 268 | if (! (memberPos > applyPos)) throw "You do not have a role higher than that member" |
pineafan | 8b4b17f | 2022-02-27 20:42:52 +0000 | [diff] [blame] | 269 | // Allow mute |
| 270 | return true |
| 271 | } |
| 272 | |
| 273 | export { command, callback, check }; |