|
|
|
@ -1,10 +1,11 @@
|
|
|
|
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
|
|
|
|
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
|
|
|
|
import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
|
|
|
|
import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
|
|
|
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
|
|
|
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
|
|
|
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
|
|
|
|
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
|
|
|
|
import getEmojiByName from "../../utils/getEmojiByName.js";
|
|
|
|
import getEmojiByName from "../../utils/getEmojiByName.js";
|
|
|
|
import confirmationMessage from "../../utils/confirmationMessage.js";
|
|
|
|
import confirmationMessage from "../../utils/confirmationMessage.js";
|
|
|
|
import keyValueList from "../../utils/generateKeyValueList.js";
|
|
|
|
import keyValueList from "../../utils/generateKeyValueList.js";
|
|
|
|
|
|
|
|
// @ts-expect-error
|
|
|
|
import humanizeDuration from "humanize-duration";
|
|
|
|
import humanizeDuration from "humanize-duration";
|
|
|
|
import client from "../../utils/client.js";
|
|
|
|
import client from "../../utils/client.js";
|
|
|
|
import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js";
|
|
|
|
import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js";
|
|
|
|
@ -56,7 +57,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
minutes: interaction.options.getInteger("minutes") ?? 0,
|
|
|
|
minutes: interaction.options.getInteger("minutes") ?? 0,
|
|
|
|
seconds: interaction.options.getInteger("seconds") ?? 0
|
|
|
|
seconds: interaction.options.getInteger("seconds") ?? 0
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const config = await client.database.guilds.read(interaction.guild.id);
|
|
|
|
const config = await client.database.guilds.read(interaction.guild!.id);
|
|
|
|
let serverSettingsDescription = config.moderation.mute.timeout ? "given a timeout" : "";
|
|
|
|
let serverSettingsDescription = config.moderation.mute.timeout ? "given a timeout" : "";
|
|
|
|
if (config.moderation.mute.role)
|
|
|
|
if (config.moderation.mute.role)
|
|
|
|
serverSettingsDescription +=
|
|
|
|
serverSettingsDescription +=
|
|
|
|
@ -158,13 +159,13 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO:[Modals] Replace this with a modal
|
|
|
|
// TODO:[Modals] Replace this with a modal
|
|
|
|
let reason = null;
|
|
|
|
let reason: string | null = null;
|
|
|
|
let notify = true;
|
|
|
|
let notify = true;
|
|
|
|
let createAppealTicket = false;
|
|
|
|
let createAppealTicket = false;
|
|
|
|
let confirmation;
|
|
|
|
let confirmation;
|
|
|
|
let timedOut = false;
|
|
|
|
let timedOut = false;
|
|
|
|
let success = false;
|
|
|
|
let success = false;
|
|
|
|
while (!timedOut && !success) {
|
|
|
|
do {
|
|
|
|
confirmation = await new confirmationMessage(interaction)
|
|
|
|
confirmation = await new confirmationMessage(interaction)
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
.setTitle("Mute")
|
|
|
|
.setTitle("Mute")
|
|
|
|
@ -174,7 +175,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
time: `${humanizeDuration(muteTime * 1000, {
|
|
|
|
time: `${humanizeDuration(muteTime * 1000, {
|
|
|
|
round: true
|
|
|
|
round: true
|
|
|
|
})}`,
|
|
|
|
})}`,
|
|
|
|
reason: reason ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ") : "*No reason provided*"
|
|
|
|
reason: reason ? "\n> " + (reason).replaceAll("\n", "\n> ") : "*No reason provided*"
|
|
|
|
}) +
|
|
|
|
}) +
|
|
|
|
"The user will be " +
|
|
|
|
"The user will be " +
|
|
|
|
serverSettingsDescription +
|
|
|
|
serverSettingsDescription +
|
|
|
|
@ -186,9 +187,9 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
.addCustomBoolean(
|
|
|
|
.addCustomBoolean(
|
|
|
|
"appeal",
|
|
|
|
"appeal",
|
|
|
|
"Create appeal ticket",
|
|
|
|
"Create appeal ticket",
|
|
|
|
!(await areTicketsEnabled(interaction.guild.id)),
|
|
|
|
!(await areTicketsEnabled(interaction.guild!.id)),
|
|
|
|
async () =>
|
|
|
|
async () =>
|
|
|
|
await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
|
|
|
|
await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
|
|
|
|
"An appeal ticket will be created when Confirm is clicked",
|
|
|
|
"An appeal ticket will be created when Confirm is clicked",
|
|
|
|
"CONTROL.TICKET",
|
|
|
|
"CONTROL.TICKET",
|
|
|
|
createAppealTicket
|
|
|
|
createAppealTicket
|
|
|
|
@ -197,7 +198,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
"notify",
|
|
|
|
"notify",
|
|
|
|
"Notify user",
|
|
|
|
"Notify user",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
null,
|
|
|
|
undefined,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
|
|
|
|
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
|
|
|
|
notify
|
|
|
|
notify
|
|
|
|
@ -209,154 +210,165 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
if (confirmation.success) success = true;
|
|
|
|
if (confirmation.success) success = true;
|
|
|
|
if (confirmation.newReason) reason = confirmation.newReason;
|
|
|
|
if (confirmation.newReason) reason = confirmation.newReason;
|
|
|
|
if (confirmation.components) {
|
|
|
|
if (confirmation.components) {
|
|
|
|
notify = confirmation.components.notify.active;
|
|
|
|
notify = confirmation.components["notify"]!.active;
|
|
|
|
createAppealTicket = confirmation.components.appeal.active;
|
|
|
|
createAppealTicket = confirmation.components["appeal"]!.active;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!timedOut && !success)
|
|
|
|
if (timedOut) return;
|
|
|
|
if (timedOut) return;
|
|
|
|
let dmd = false;
|
|
|
|
let dmd = false;
|
|
|
|
let dm;
|
|
|
|
let dm;
|
|
|
|
const config = await client.database.guilds.read(interaction.guild.id);
|
|
|
|
if (confirmation.success) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (notify) {
|
|
|
|
if (notify) {
|
|
|
|
dm = await user.send({
|
|
|
|
dm = await user.send({
|
|
|
|
embeds: [
|
|
|
|
embeds: [
|
|
|
|
new EmojiEmbed()
|
|
|
|
new EmojiEmbed()
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
.setTitle("Muted")
|
|
|
|
.setTitle("Muted")
|
|
|
|
.setDescription(
|
|
|
|
.setDescription(
|
|
|
|
`You have been muted in ${interaction.guild.name}` +
|
|
|
|
`You have been muted in ${interaction.guild!.name}` +
|
|
|
|
(reason
|
|
|
|
(reason
|
|
|
|
? ` for:\n> ${reason}`
|
|
|
|
? ` for:\n> ${reason}`
|
|
|
|
: ".\n\n" +
|
|
|
|
: ".\n\n" +
|
|
|
|
`You will be unmuted at: <t:${
|
|
|
|
`You will be unmuted at: <t:${
|
|
|
|
Math.round(new Date().getTime() / 1000) + muteTime
|
|
|
|
Math.round(new Date().getTime() / 1000) + muteTime
|
|
|
|
}:D> at <t:${Math.round(new Date().getTime() / 1000) + muteTime}:T> (<t:${
|
|
|
|
}:D> at <t:${Math.round(new Date().getTime() / 1000) + muteTime}:T> (<t:${
|
|
|
|
Math.round(new Date().getTime() / 1000) + muteTime
|
|
|
|
Math.round(new Date().getTime() / 1000) + muteTime
|
|
|
|
}:R>)`) +
|
|
|
|
}:R>)`) +
|
|
|
|
(confirmation.components.appeal.response
|
|
|
|
(confirmation.components!["appeal"]!.response
|
|
|
|
? `You can appeal this here: <#${confirmation.components.appeal.response}>`
|
|
|
|
? `You can appeal this here: <#${confirmation.components!["appeal"]!.response}>`
|
|
|
|
: "")
|
|
|
|
: "")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.setStatus("Danger")
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
components: [
|
|
|
|
|
|
|
|
new MessageActionRow().addComponents(
|
|
|
|
|
|
|
|
config.moderation.mute.text
|
|
|
|
|
|
|
|
? [
|
|
|
|
|
|
|
|
new MessageButton()
|
|
|
|
|
|
|
|
.setStyle("LINK")
|
|
|
|
|
|
|
|
.setLabel(config.moderation.mute.text)
|
|
|
|
|
|
|
|
.setURL(config.moderation.mute.link)
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
: []
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.setStatus("Danger")
|
|
|
|
]
|
|
|
|
],
|
|
|
|
});
|
|
|
|
components: [
|
|
|
|
dmd = true;
|
|
|
|
new MessageActionRow().addComponents(
|
|
|
|
}
|
|
|
|
config.moderation.mute.text
|
|
|
|
} catch {
|
|
|
|
? [
|
|
|
|
dmd = false;
|
|
|
|
new MessageButton()
|
|
|
|
|
|
|
|
.setStyle("LINK")
|
|
|
|
|
|
|
|
.setLabel(config.moderation.mute.text)
|
|
|
|
|
|
|
|
.setURL(config.moderation.mute.link)
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
: []
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
dmd = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch {
|
|
|
|
const member = user;
|
|
|
|
dmd = false;
|
|
|
|
let errors = 0;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
const member = user;
|
|
|
|
if (config.moderation.mute.timeout) {
|
|
|
|
let errors = 0;
|
|
|
|
await member.timeout(muteTime * 1000, reason || "No reason provided");
|
|
|
|
try {
|
|
|
|
if (config.moderation.mute.role !== null) {
|
|
|
|
if (config.moderation.mute.timeout) {
|
|
|
|
await member.roles.add(config.moderation.mute.role);
|
|
|
|
await member.timeout(muteTime * 1000, reason || "No reason provided");
|
|
|
|
await client.database.eventScheduler.schedule("naturalUnmute", new Date().getTime() + muteTime * 1000, {
|
|
|
|
|
|
|
|
guild: interaction.guild!.id,
|
|
|
|
|
|
|
|
user: user.id,
|
|
|
|
|
|
|
|
expires: new Date().getTime() + muteTime * 1000
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
errors++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (config.moderation.mute.role !== null) {
|
|
|
|
if (config.moderation.mute.role !== null) {
|
|
|
|
await member.roles.add(config.moderation.mute.role);
|
|
|
|
await member.roles.add(config.moderation.mute.role);
|
|
|
|
await client.database.eventScheduler.schedule("naturalUnmute", new Date().getTime() + muteTime * 1000, {
|
|
|
|
await client.database.eventScheduler.schedule("unmuteRole", new Date().getTime() + muteTime * 1000, {
|
|
|
|
guild: interaction.guild.id,
|
|
|
|
guild: interaction.guild!.id,
|
|
|
|
user: user.id,
|
|
|
|
user: user.id,
|
|
|
|
expires: new Date().getTime() + muteTime * 1000
|
|
|
|
role: config.moderation.mute.role
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.log(e);
|
|
|
|
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch {
|
|
|
|
if (errors === 2) {
|
|
|
|
errors++;
|
|
|
|
await interaction.editReply({
|
|
|
|
}
|
|
|
|
embeds: [
|
|
|
|
try {
|
|
|
|
new EmojiEmbed()
|
|
|
|
if (config.moderation.mute.role !== null) {
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
await member.roles.add(config.moderation.mute.role);
|
|
|
|
.setTitle("Mute")
|
|
|
|
await client.database.eventScheduler.schedule("unmuteRole", new Date().getTime() + muteTime * 1000, {
|
|
|
|
.setDescription("Something went wrong and the user was not muted")
|
|
|
|
guild: interaction.guild.id,
|
|
|
|
.setStatus("Danger")
|
|
|
|
user: user.id,
|
|
|
|
],
|
|
|
|
role: config.moderation.mute.role
|
|
|
|
components: []
|
|
|
|
});
|
|
|
|
}); // TODO: make this clearer
|
|
|
|
|
|
|
|
if (dmd && dm) await dm.delete();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
await client.database.history.create("mute", interaction.guild!.id, member.user, interaction.user, reason);
|
|
|
|
console.log(e);
|
|
|
|
const failed = !dmd && notify;
|
|
|
|
errors++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errors === 2) {
|
|
|
|
|
|
|
|
await interaction.editReply({
|
|
|
|
await interaction.editReply({
|
|
|
|
embeds: [
|
|
|
|
embeds: [
|
|
|
|
new EmojiEmbed()
|
|
|
|
new EmojiEmbed()
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
|
|
|
|
.setTitle("Mute")
|
|
|
|
.setTitle("Mute")
|
|
|
|
.setDescription("Something went wrong and the user was not muted")
|
|
|
|
.setDescription(
|
|
|
|
.setStatus("Danger")
|
|
|
|
"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}>`
|
|
|
|
|
|
|
|
: "")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.setStatus(failed ? "Warning" : "Success")
|
|
|
|
],
|
|
|
|
],
|
|
|
|
components: []
|
|
|
|
components: []
|
|
|
|
}); // TODO: make this clearer
|
|
|
|
});
|
|
|
|
if (dmd) await dm.delete();
|
|
|
|
const data = {
|
|
|
|
return;
|
|
|
|
meta: {
|
|
|
|
|
|
|
|
type: "memberMute",
|
|
|
|
|
|
|
|
displayName: "Member Muted",
|
|
|
|
|
|
|
|
calculateType: "guildMemberPunish",
|
|
|
|
|
|
|
|
color: NucleusColors.yellow,
|
|
|
|
|
|
|
|
emoji: "PUNISH.WARN.YELLOW",
|
|
|
|
|
|
|
|
timestamp: new Date().getTime()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
list: {
|
|
|
|
|
|
|
|
memberId: entry(member.user.id, `\`${member.user.id}\``),
|
|
|
|
|
|
|
|
name: entry(member.user.id, renderUser(member.user)),
|
|
|
|
|
|
|
|
mutedUntil: entry(
|
|
|
|
|
|
|
|
new Date().getTime() + muteTime * 1000,
|
|
|
|
|
|
|
|
renderDelta(new Date().getTime() + muteTime * 1000)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
muted: entry(new Date().getTime(), renderDelta(new Date().getTime() - 1000)),
|
|
|
|
|
|
|
|
mutedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user)),
|
|
|
|
|
|
|
|
reason: entry(reason, reason ? reason : "*No reason provided*")
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
hidden: {
|
|
|
|
|
|
|
|
guild: interaction.guild!.id
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
log(data);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
await interaction.editReply({
|
|
|
|
|
|
|
|
embeds: [
|
|
|
|
|
|
|
|
new EmojiEmbed()
|
|
|
|
|
|
|
|
.setEmoji("PUNISH.BAN.GREEN")
|
|
|
|
|
|
|
|
.setTitle("Softban")
|
|
|
|
|
|
|
|
.setDescription("No changes were made")
|
|
|
|
|
|
|
|
.setStatus("Success")
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
components: []
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason);
|
|
|
|
|
|
|
|
const failed = !dmd && notify;
|
|
|
|
|
|
|
|
await interaction.editReply({
|
|
|
|
|
|
|
|
embeds: [
|
|
|
|
|
|
|
|
new EmojiEmbed()
|
|
|
|
|
|
|
|
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
|
|
|
|
|
|
|
|
.setTitle("Mute")
|
|
|
|
|
|
|
|
.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}>`
|
|
|
|
|
|
|
|
: "")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.setStatus(failed ? "Warning" : "Success")
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
components: []
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
|
|
|
|
meta: {
|
|
|
|
|
|
|
|
type: "memberMute",
|
|
|
|
|
|
|
|
displayName: "Member Muted",
|
|
|
|
|
|
|
|
calculateType: "guildMemberPunish",
|
|
|
|
|
|
|
|
color: NucleusColors.yellow,
|
|
|
|
|
|
|
|
emoji: "PUNISH.WARN.YELLOW",
|
|
|
|
|
|
|
|
timestamp: new Date().getTime()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
list: {
|
|
|
|
|
|
|
|
memberId: entry(member.user.id, `\`${member.user.id}\``),
|
|
|
|
|
|
|
|
name: entry(member.user.id, renderUser(member.user)),
|
|
|
|
|
|
|
|
mutedUntil: entry(
|
|
|
|
|
|
|
|
new Date().getTime() + muteTime * 1000,
|
|
|
|
|
|
|
|
renderDelta(new Date().getTime() + muteTime * 1000)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
muted: entry(new Date().getTime(), renderDelta(new Date().getTime() - 1000)),
|
|
|
|
|
|
|
|
mutedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
|
|
|
|
|
|
|
|
reason: entry(reason, reason ? reason : "*No reason provided*")
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
hidden: {
|
|
|
|
|
|
|
|
guild: interaction.guild.id
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
log(data);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const check = (interaction: CommandInteraction) => {
|
|
|
|
const check = (interaction: CommandInteraction) => {
|
|
|
|
const member = interaction.member as GuildMember;
|
|
|
|
const member = interaction.member as GuildMember;
|
|
|
|
const me = interaction.guild.me!;
|
|
|
|
const me = interaction.guild!.me!;
|
|
|
|
const apply = interaction.options.getMember("user") as GuildMember;
|
|
|
|
const apply = interaction.options.getMember("user") as GuildMember;
|
|
|
|
if (member === null || me === null || apply === null) throw new Error("That member is not in the server");
|
|
|
|
const memberPos = member.roles.cache.size > 1 ? member.roles.highest.position : 0;
|
|
|
|
const memberPos = member.roles ? member.roles.highest.position : 0;
|
|
|
|
const mePos = me.roles.cache.size > 1 ? me.roles.highest.position : 0;
|
|
|
|
const mePos = me.roles ? me.roles.highest.position : 0;
|
|
|
|
const applyPos = apply.roles.cache.size > 1 ? apply.roles.highest.position : 0;
|
|
|
|
const applyPos = apply.roles ? apply.roles.highest.position : 0;
|
|
|
|
|
|
|
|
// Do not allow muting the owner
|
|
|
|
// Do not allow muting the owner
|
|
|
|
if (member.id === interaction.guild.ownerId) throw new Error("You cannot mute the owner of the server");
|
|
|
|
if (member.id === interaction.guild!.ownerId) throw new Error("You cannot mute the owner of the server");
|
|
|
|
// Check if Nucleus can mute the member
|
|
|
|
// Check if Nucleus can mute the member
|
|
|
|
if (!(mePos > applyPos)) throw new Error("I do not have a role higher than that member");
|
|
|
|
if (!(mePos > applyPos)) throw new Error("I do not have a role higher than that member");
|
|
|
|
// Check if Nucleus has permission to mute
|
|
|
|
// Check if Nucleus has permission to mute
|
|
|
|
@ -364,7 +376,7 @@ const check = (interaction: CommandInteraction) => {
|
|
|
|
// Do not allow muting Nucleus
|
|
|
|
// Do not allow muting Nucleus
|
|
|
|
if (member.id === me.id) throw new Error("I cannot mute myself");
|
|
|
|
if (member.id === me.id) throw new Error("I cannot mute myself");
|
|
|
|
// Allow the owner to mute anyone
|
|
|
|
// Allow the owner to mute anyone
|
|
|
|
if (member.id === interaction.guild.ownerId) return true;
|
|
|
|
if (member.id === interaction.guild!.ownerId) return true;
|
|
|
|
// Check if the user has moderate_members permission
|
|
|
|
// Check if the user has moderate_members permission
|
|
|
|
if (!member.permissions.has("MODERATE_MEMBERS"))
|
|
|
|
if (!member.permissions.has("MODERATE_MEMBERS"))
|
|
|
|
throw new Error("You do not have the *Moderate Members* permission");
|
|
|
|
throw new Error("You do not have the *Moderate Members* permission");
|
|
|
|
|