stats channels
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 0239951..2068b15 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -12,16 +12,14 @@
.setName("ban")
.setDescription("Bans a user from the server")
.addUserOption(option => option.setName("user").setDescription("The user to ban").setRequired(true))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are banned | Default: Yes").setRequired(false)
- .addChoices([["Yes", "yes"], ["No", "no"]])
- )
- .addIntegerOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false))
+ .addNumberOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false))
const callback = async (interaction: CommandInteraction): Promise<any> => {
const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
let reason = null
- let confirmation
+ let notify = true;
+ let confirmation;
while (true) {
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
@@ -30,22 +28,24 @@
"user": renderUser(interaction.options.getUser("user")),
"reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
})
- + `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n`
+ + `The user **will${notify ? '' : ' not'}** be notified\n`
+ `${addPlurals(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
+ `Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
.addReasonButton(reason ?? "")
.send(reason !== null)
reason = reason ?? ""
- if (confirmation.newReason === undefined) break
- reason = confirmation.newReason
+ if (confirmation.cancelled) return
+ if (confirmation.success) break
+ if (confirmation.newReason) reason = confirmation.newReason
+ if (confirmation.components) notify = confirmation.components.notify.active
}
if (confirmation.success) {
let dmd = false
let dm;
let config = await client.database.guilds.read(interaction.guild.id);
try {
- if (interaction.options.getString("notify") != "no") {
+ if (notify) {
dm = await (interaction.options.getMember("user") as GuildMember).send({
embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
@@ -66,7 +66,7 @@
try {
let member = (interaction.options.getMember("user") as GuildMember)
member.ban({
- days: Number(interaction.options.getInteger("delete") ?? 0),
+ days: Number(interaction.options.getNumber("delete") ?? 0),
reason: reason ?? "No reason provided"
})
try { await client.database.history.create("ban", interaction.guild.id, member.user, interaction.user, reason) } catch {}
@@ -104,7 +104,7 @@
if (dmd) await dm.delete()
return
}
- let failed = (dmd == false && interaction.options.getString("notify") != "no")
+ let failed = (dmd == false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Ban`)
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index b7f4b74..0ea93d8 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -14,7 +14,6 @@
.setDescription("Shows moderator information about a user")
.addUserOption(option => option.setName("user").setDescription("The user to get information about").setRequired(true))
-
const types = {
"warn": {emoji: "PUNISH.WARN.YELLOW", text: "Warned"},
"mute": {emoji: "PUNISH.MUTE.YELLOW", text: "Muted"},
@@ -237,8 +236,7 @@
} catch (e) { return }
if (i.customId === "modify") {
await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Editing moderator note`).addComponents(
- // @ts-ignore
- new MessageActionRow().addComponents(new TextInputComponent()
+ new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
.setCustomId("note")
.setLabel("Note")
.setMaxLength(4000)
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 793a630..eac7ca3 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -12,14 +12,12 @@
.setName("kick")
.setDescription("Kicks a user from the server")
.addUserOption(option => option.setName("user").setDescription("The user to kick").setRequired(true))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are kicked | Default: Yes").setRequired(false)
- .addChoices([["Yes", "yes"], ["No", "no"]])
- )
const callback = async (interaction: CommandInteraction): Promise<any> => {
const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
let reason = null;
+ let notify = true;
let confirmation
while (true) {
confirmation = await new confirmationMessage(interaction)
@@ -29,21 +27,25 @@
"user": renderUser(interaction.options.getUser("user")),
"reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
})
- + `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+ `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
.addReasonButton(reason ?? "")
.send(reason !== null)
reason = reason ?? ""
- if (confirmation.newReason === undefined) break
- reason = confirmation.newReason
+ if (confirmation.cancelled) return
+ if (confirmation.success) break
+ if (confirmation.newReason) reason = confirmation.newReason
+ if (confirmation.components) {
+ notify = confirmation.components.notify.active
+ }
}
if (confirmation.success) {
let dmd = false
let dm;
let config = await client.database.guilds.read(interaction.guild.id);
try {
- if (interaction.options.getString("notify") != "no") {
+ if (notify) {
dm = await (interaction.options.getMember("user") as GuildMember).send({
embeds: [new EmojiEmbed()
.setEmoji("PUNISH.KICK.RED")
@@ -65,8 +67,7 @@
(interaction.options.getMember("user") as GuildMember).kick(reason ?? "No reason provided.")
let member = (interaction.options.getMember("user") as GuildMember)
try { await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason) } catch {}
- // @ts-ignore
- const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
let data = {
meta: {
type: 'memberKick',
@@ -102,7 +103,7 @@
if (dmd) await dm.delete()
return
}
- let failed = (dmd == false && interaction.options.getString("notify") != "no")
+ let failed = (dmd == false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Kick`)
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 5e1a18b..f98bd6a 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -18,8 +18,6 @@
.addIntegerOption(option => option.setName("hours").setDescription("The number of hours to mute the user for | Default: 0").setMinValue(0).setMaxValue(23).setRequired(false))
.addIntegerOption(option => option.setName("minutes").setDescription("The number of minutes to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false))
.addIntegerOption(option => option.setName("seconds").setDescription("The number of seconds to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are muted | Default: yes").setRequired(false)
- .addChoices([["Yes", "yes"], ["No", "no"]]))
const callback = async (interaction: CommandInteraction): Promise<any> => {
const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger
@@ -119,6 +117,8 @@
}
// TODO:[Modals] Replace this with a modal
let reason = null;
+ let notify = true;
+ let createAppealTicket = false;
let confirmation;
while (true) {
confirmation = await new confirmationMessage(interaction)
@@ -130,32 +130,39 @@
"reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
})
+ `The user will be ` + serverSettingsDescription + "\n"
- + `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+ `Are you sure you want to mute <@!${user.id}>?`)
.setColor("Danger")
.addCustomBoolean(
- "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, user.user, interaction.user, reason),
- "An appeal ticket will be created when Confirm is clicked")
+ "appeal", "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
+ async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
+ "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket)
+ .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
.addReasonButton(reason ?? "")
.send(true)
reason = reason ?? ""
- if (confirmation.newReason === undefined) break
- reason = confirmation.newReason
+ if (confirmation.cancelled) return
+ if (confirmation.success) break
+ if (confirmation.newReason) reason = confirmation.newReason
+ if (confirmation.components) {
+ notify = confirmation.components.notify.active
+ createAppealTicket = confirmation.components.appeal.active
+ }
}
if (confirmation.success) {
let dmd = false
let dm;
let config = await client.database.guilds.read(interaction.guild.id);
try {
- if (interaction.options.getString("notify") != "no") {
+ if (notify) {
dm = await user.send({
embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Muted")
.setDescription(`You have been muted in ${interaction.guild.name}` +
(reason ? ` for:\n> ${reason}` : ".\n\n" +
- `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>)`))
+ `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>)`) +
+ (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()
@@ -198,16 +205,16 @@
.setTitle(`Mute`)
.setDescription("Something went wrong and the user was not muted")
.setStatus("Danger")
- ], components: []})
+ ], components: []}) // TODO: make this clearer
if (dmd) await dm.delete()
return
}
try { await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason) } catch {}
- let failed = (dmd == false && interaction.options.getString("notify") != "no")
+ let failed = (dmd == false && 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" : ""))
+ .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: []})
let data = {
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index f842d76..3ff18ec 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -13,40 +13,43 @@
.setDescription("Changes a users nickname")
.addUserOption(option => option.setName("user").setDescription("The user to change").setRequired(true))
.addStringOption(option => option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when their nickname is changed | Default: No").setRequired(false)
- .addChoices([["Yes", "yes"], ["No", "no"]])
- )
const callback = async (interaction: CommandInteraction): Promise<any> => {
const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
- let confirmation = await new confirmationMessage(interaction)
- .setEmoji("PUNISH.NICKNAME.RED")
- .setTitle("Nickname")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "new nickname": `${interaction.options.getString("name") ? interaction.options.getString("name") : "*No nickname*"}`
- })
- + `The user **will${interaction.options.getString("notify") == "yes" ? '' : ' not'}** be notified\n\n`
- + `Are you sure you want to ${interaction.options.getString("name") ? "change" : "clear"} <@!${(interaction.options.getMember("user") as GuildMember).id}>'s nickname?`)
- .setColor("Danger")
- .addCustomBoolean(
- "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, null),
- "An appeal ticket will be created when Confirm is clicked")
- .send()
+ let notify = true;
+ let confirmation;
+ while (true) {
+ confirmation = await new confirmationMessage(interaction)
+ .setEmoji("PUNISH.NICKNAME.RED")
+ .setTitle("Nickname")
+ .setDescription(keyValueList({
+ "user": renderUser(interaction.options.getUser("user")),
+ "new nickname": `${interaction.options.getString("name") ? interaction.options.getString("name") : "*No nickname*"}`
+ })
+ + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+ + `Are you sure you want to ${interaction.options.getString("name") ? "change" : "clear"} <@!${(interaction.options.getMember("user") as GuildMember).id}>'s nickname?`)
+ .setColor("Danger")
+ .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ .send(interaction.options.getString("name") !== null)
+ if (confirmation.cancelled) return
+ if (confirmation.success) break
+ if (confirmation.components) {
+ notify = confirmation.components.notify.active
+ }
+ }
if (confirmation.success) {
let dmd = false
let dm;
try {
- if (interaction.options.getString("notify") == "yes") {
+ if (notify) {
dm = await (interaction.options.getMember("user") as GuildMember).send({
embeds: [new EmojiEmbed()
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname changed")
.setDescription(`Your nickname was ${interaction.options.getString("name") ? "changed" : "cleared"} in ${interaction.guild.name}.` +
(interaction.options.getString("name") ? ` it is now: ${interaction.options.getString("name")}` : "") + "\n\n" +
- (confirmation.buttonClicked ? `You can appeal this here: <#${confirmation.response}>` : ``))
+ (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ``))
.setStatus("Danger")
]
})
@@ -61,8 +64,7 @@
try { await client.database.history.create(
"nickname", interaction.guild.id, member.user, interaction.user,
null, before, nickname) } catch {}
- // @ts-ignore
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
let data = {
meta: {
type: 'memberUpdate',
@@ -94,11 +96,11 @@
if (dmd) await dm.delete()
return
}
- let failed = (dmd == false && interaction.options.getString("notify") == "yes")
+ let failed = (dmd == false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Nickname`)
- .setDescription("The members nickname was changed" + (failed ? ", but was not notified" : "") + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
+ .setDescription("The members nickname was changed" + (failed ? ", but was not notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ``))
.setStatus(failed ? "Warning" : "Success")
], components: []})
} else {
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index fd8e6b8..af7beb3 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -132,7 +132,6 @@
}
let attachmentObject;
try {
- // @ts-ignore
const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
let data = {
meta: {
@@ -210,6 +209,7 @@
}))
.setColor("Danger")
.send()
+ if (confirmation.cancelled) return
if (confirmation.success) {
let messages;
try {
@@ -234,7 +234,6 @@
}
let attachmentObject;
try {
- // @ts-ignore
const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
let data = {
meta: {
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index d9a8421..2b386fd 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -31,6 +31,7 @@
+ `Are you sure you want to set the slowmode in this channel?`)
.setColor("Danger")
.send()
+ if (confirmation.cancelled) return
if (confirmation.success) {
try {
(interaction.channel as TextChannel).setRateLimitPerUser(time)
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index a368e7a..7fefb1b 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -13,14 +13,12 @@
.setDescription("Kicks a user and deletes their messages")
.addUserOption(option => option.setName("user").setDescription("The user to softban").setRequired(true))
.addIntegerOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are softbanned | Default: Yes").setRequired(false)
- .addChoices([["Yes", "yes"], ["No", "no"]])
- )
const callback = async (interaction: CommandInteraction): Promise<any> => {
const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
let reason = null;
+ let notify = true;
let confirmation;
while (true) {
let confirmation = await new confirmationMessage(interaction)
@@ -30,21 +28,26 @@
"user": renderUser(interaction.options.getUser("user")),
"reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
})
- + `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n`
+ + `The user **will${notify ? '' : ' not'}** be notified\n`
+ `${addPlural(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
+ `Are you sure you want to softban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
+ .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
.addReasonButton(reason ?? "")
.send(reason !== null)
reason = reason ?? ""
- if (confirmation.newReason === undefined) break
- reason = confirmation.newReason
+ if (confirmation.cancelled) return
+ if (confirmation.success) break
+ if (confirmation.newReason) reason = confirmation.newReason
+ if (confirmation.components) {
+ notify = confirmation.components.notify.active
+ }
}
if (confirmation.success) {
let dmd = false;
let config = await client.database.guilds.read(interaction.guild.id);
try {
- if (interaction.options.getString("notify") != "no") {
+ if (notify) {
await (interaction.options.getMember("user") as GuildMember).send({
embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
@@ -78,7 +81,7 @@
], components: []})
}
try { await client.database.history.create("softban", interaction.guild.id, member.user, reason) } catch {}
- let failed = (dmd == false && interaction.options.getString("notify") != "no")
+ let failed = (dmd == false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Softban`)
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index e512084..035b809 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -36,12 +36,12 @@
+ `Are you sure you want to unban <@${resolved.user.id}>?`)
.setColor("Danger")
.send()
+ if (confirmation.cancelled) return
if (confirmation.success) {
try {
await interaction.guild.members.unban(resolved.user as User, "Unban");
let member = (resolved.user as User)
try { await client.database.history.create("unban", interaction.guild.id, member, interaction.user) } catch {}
- // @ts-ignore
const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
let data = {
meta: {
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index d5f4205..56a0b56 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -11,14 +11,12 @@
.setName("unmute")
.setDescription("Unmutes a user")
.addUserOption(option => option.setName("user").setDescription("The user to unmute").setRequired(true))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are unmuted | Default: No").setRequired(false)
- .addChoices([["Yes", "yes"], ["No", "no"]])
- )
const callback = async (interaction: CommandInteraction): Promise<any> => {
const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger
// TODO:[Modals] Replace this with a modal
let reason = null;
+ let notify = false;
let confirmation;
while (true) {
confirmation = await new confirmationMessage(interaction)
@@ -28,20 +26,23 @@
"user": renderUser(interaction.options.getUser("user")),
"reason": `\n> ${reason ? reason : "*No reason provided*"}`
})
- + `The user **will${interaction.options.getString("notify") === "yes" ? '' : ' not'}** be notified\n\n`
+ + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+ `Are you sure you want to unmute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
.addReasonButton(reason ?? "")
.send(reason !== null)
- reason = reason ?? ""
- if (confirmation.newReason === undefined) break
- reason = confirmation.newReason
+ if (confirmation.success) break
+ if (confirmation.newReason) reason = confirmation.newReason
+ if (confirmation.components) {
+ notify = confirmation.components.notify.active
+ }
}
+ if (confirmation.cancelled) return
if (confirmation.success) {
let dmd = false
let dm;
try {
- if (interaction.options.getString("notify") != "no") {
+ if (notify) {
dm = await (interaction.options.getMember("user") as GuildMember).send({
embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
@@ -88,7 +89,7 @@
}
}
log(data);
- let failed = (dmd == false && interaction.options.getString("notify") != "no")
+ let failed = (dmd == false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Unmute`)
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 379d49c..3e76321 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -1,4 +1,4 @@
-import Discord, { CommandInteraction, GuildMember, MessageActionRow } from "discord.js";
+import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -12,14 +12,13 @@
.setName("warn")
.setDescription("Warns a user")
.addUserOption(option => option.setName("user").setDescription("The user to warn").setRequired(true))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are warned | Default: Yes").setRequired(false)
- .addChoices([["Yes", "yes"], ["No", "no"]])
- )
const callback = async (interaction: CommandInteraction): Promise<any> => {
const { log, NucleusColors, renderUser, entry } = client.logger
// TODO:[Modals] Replace this with a modal
let reason = null;
+ let notify = true;
+ let createAppealTicket = false;
let confirmation;
while (true) {
confirmation = await new confirmationMessage(interaction)
@@ -29,44 +28,52 @@
"user": renderUser(interaction.options.getUser("user")),
"reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
})
- + `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+ `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
.addCustomBoolean(
- "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
+ "appeal", "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
- "An appeal ticket will be created when Confirm is clicked")
- .addReasonButton(reason)
+ "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket)
+ .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
.addReasonButton(reason ?? "")
.send(reason !== null)
reason = reason ?? ""
- if (confirmation.newReason === undefined) break
- reason = confirmation.newReason
+ if (confirmation.cancelled) return
+ if (confirmation.success) break
+ if (confirmation.newReason) reason = confirmation.newReason
+ if (confirmation.components) {
+ notify = confirmation.components.notify.active
+ createAppealTicket = confirmation.components.appeal.active
+ }
}
if (confirmation.success) {
let dmd = false
try {
- if (interaction.options.getString("notify") != "no") {
+ if (notify) {
+ const config = await client.database.guilds.read(interaction.guild.id)
await (interaction.options.getMember("user") as GuildMember).send({
embeds: [new EmojiEmbed()
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warned")
.setDescription(`You have been warned in ${interaction.guild.name}` +
(reason ? ` for:\n> ${reason}` : ".") + "\n\n" +
- (confirmation.buttonClicked ? `You can appeal this here ticket: <#${confirmation.response}>` : ``))
+ (confirmation.components.appeal.response ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>` : ``))
.setStatus("Danger")
- ]
+ .setFooter({
+ text: config.moderation.warn.text ? "The button below is set by the server admins. Do not enter any passwords or other account details on the linked site." : "",
+ iconURL: "https://cdn.discordapp.com/emojis/952295894370369587.webp?size=128&quality=lossless"
+ })
+ ],
+ components: config.moderation.warn.text ? [new MessageActionRow().addComponents([new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.warn.text)
+ .setURL(config.moderation.warn.link)
+ ])] : []
})
dmd = true
}
- } catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle(`Warn`)
- .setDescription("Something went wrong and the user was not warned")
- .setStatus("Danger")
- ], components: []})
- }
+ } catch {}
let data = {
meta:{
type: 'memberWarn',
@@ -91,12 +98,12 @@
interaction.user, reason
)} catch {}
log(data);
- let failed = (dmd == false && interaction.options.getString("notify") != "no")
+ let failed = (dmd == false && notify)
if (!failed) {
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
- .setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
+ .setDescription("The user was warned" + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ``))
.setStatus("Success")
], components: []})
} else {
@@ -118,7 +125,7 @@
.setStyle("SECONDARY")
.setDisabled((interaction.options.getMember("user") as GuildMember).permissionsIn(interaction.channel as Discord.TextChannel).has("VIEW_CHANNEL") === false),
])
- ],
+ ]
})
let component;
try {