|
|
|
@ -162,7 +162,9 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
let notify = true;
|
|
|
|
let notify = true;
|
|
|
|
let createAppealTicket = false;
|
|
|
|
let createAppealTicket = false;
|
|
|
|
let confirmation;
|
|
|
|
let confirmation;
|
|
|
|
while (true) {
|
|
|
|
let timedOut = false;
|
|
|
|
|
|
|
|
let success = false;
|
|
|
|
|
|
|
|
while (!timedOut && !success) {
|
|
|
|
confirmation = await new confirmationMessage(interaction)
|
|
|
|
confirmation = await new confirmationMessage(interaction)
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
.setTitle("Mute")
|
|
|
|
.setTitle("Mute")
|
|
|
|
@ -203,162 +205,146 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
.addReasonButton(reason ?? "")
|
|
|
|
.addReasonButton(reason ?? "")
|
|
|
|
.send(true);
|
|
|
|
.send(true);
|
|
|
|
reason = reason ?? "";
|
|
|
|
reason = reason ?? "";
|
|
|
|
if (confirmation.cancelled) return;
|
|
|
|
if (confirmation.cancelled) timedOut = true;
|
|
|
|
if (confirmation.success) break;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (confirmation.success) {
|
|
|
|
if (timedOut) return;
|
|
|
|
let dmd = false;
|
|
|
|
let dmd = false;
|
|
|
|
let dm;
|
|
|
|
let dm;
|
|
|
|
const config = await client.database.guilds.read(interaction.guild.id);
|
|
|
|
const config = await client.database.guilds.read(interaction.guild.id);
|
|
|
|
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")
|
|
|
|
});
|
|
|
|
],
|
|
|
|
dmd = true;
|
|
|
|
components: [
|
|
|
|
}
|
|
|
|
new MessageActionRow().addComponents(
|
|
|
|
} catch {
|
|
|
|
config.moderation.mute.text
|
|
|
|
dmd = false;
|
|
|
|
? [
|
|
|
|
}
|
|
|
|
new MessageButton()
|
|
|
|
const member = user;
|
|
|
|
.setStyle("LINK")
|
|
|
|
let errors = 0;
|
|
|
|
.setLabel(config.moderation.mute.text)
|
|
|
|
try {
|
|
|
|
.setURL(config.moderation.mute.link)
|
|
|
|
if (config.moderation.mute.timeout) {
|
|
|
|
]
|
|
|
|
await member.timeout(muteTime * 1000, reason || "No reason provided");
|
|
|
|
: []
|
|
|
|
if (config.moderation.mute.role !== null) {
|
|
|
|
)
|
|
|
|
await member.roles.add(config.moderation.mute.role);
|
|
|
|
]
|
|
|
|
await client.database.eventScheduler.schedule(
|
|
|
|
});
|
|
|
|
"naturalUnmute",
|
|
|
|
dmd = true;
|
|
|
|
new Date().getTime() + muteTime * 1000,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
guild: interaction.guild.id,
|
|
|
|
|
|
|
|
user: user.id,
|
|
|
|
|
|
|
|
expires: new Date().getTime() + muteTime * 1000
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
errors++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
dmd = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const member = user;
|
|
|
|
|
|
|
|
let errors = 0;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (config.moderation.mute.timeout) {
|
|
|
|
|
|
|
|
await member.timeout(muteTime * 1000, reason || "No reason provided");
|
|
|
|
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("unmuteRole", new Date().getTime() + muteTime * 1000, {
|
|
|
|
await client.database.eventScheduler.schedule("naturalUnmute", new Date().getTime() + muteTime * 1000, {
|
|
|
|
guild: interaction.guild.id,
|
|
|
|
guild: interaction.guild.id,
|
|
|
|
user: user.id,
|
|
|
|
user: user.id,
|
|
|
|
role: config.moderation.mute.role
|
|
|
|
expires: new Date().getTime() + muteTime * 1000
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.log(e);
|
|
|
|
|
|
|
|
errors++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (errors === 2) {
|
|
|
|
} catch {
|
|
|
|
await interaction.editReply({
|
|
|
|
errors++;
|
|
|
|
embeds: [
|
|
|
|
}
|
|
|
|
new EmojiEmbed()
|
|
|
|
try {
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
if (config.moderation.mute.role !== null) {
|
|
|
|
.setTitle("Mute")
|
|
|
|
await member.roles.add(config.moderation.mute.role);
|
|
|
|
.setDescription("Something went wrong and the user was not muted")
|
|
|
|
await client.database.eventScheduler.schedule("unmuteRole", new Date().getTime() + muteTime * 1000, {
|
|
|
|
.setStatus("Danger")
|
|
|
|
guild: interaction.guild.id,
|
|
|
|
],
|
|
|
|
user: user.id,
|
|
|
|
components: []
|
|
|
|
role: config.moderation.mute.role
|
|
|
|
}); // TODO: make this clearer
|
|
|
|
});
|
|
|
|
if (dmd) await dm.delete();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason);
|
|
|
|
} catch (e) {
|
|
|
|
const failed = !dmd && notify;
|
|
|
|
console.log(e);
|
|
|
|
await interaction.editReply({
|
|
|
|
errors++;
|
|
|
|
embeds: [
|
|
|
|
}
|
|
|
|
new EmojiEmbed()
|
|
|
|
if (errors === 2) {
|
|
|
|
.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);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
await interaction.editReply({
|
|
|
|
await interaction.editReply({
|
|
|
|
embeds: [
|
|
|
|
embeds: [
|
|
|
|
new EmojiEmbed()
|
|
|
|
new EmojiEmbed()
|
|
|
|
.setEmoji("PUNISH.MUTE.GREEN")
|
|
|
|
.setEmoji("PUNISH.MUTE.RED")
|
|
|
|
.setTitle("Mute")
|
|
|
|
.setTitle("Mute")
|
|
|
|
.setDescription("No changes were made")
|
|
|
|
.setDescription("Something went wrong and the user was not muted")
|
|
|
|
.setStatus("Success")
|
|
|
|
.setStatus("Danger")
|
|
|
|
],
|
|
|
|
],
|
|
|
|
components: []
|
|
|
|
components: []
|
|
|
|
});
|
|
|
|
}); // TODO: make this clearer
|
|
|
|
|
|
|
|
if (dmd) await dm.delete();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) => {
|
|
|
|
|