stats channels
diff --git a/src/commands/categorisationTest.ts b/src/commands/categorisationTest.ts
index f89a899..b052783 100644
--- a/src/commands/categorisationTest.ts
+++ b/src/commands/categorisationTest.ts
@@ -6,7 +6,7 @@
import addPlural from "../utils/plurals.js";
import getEmojiByName from "../utils/getEmojiByName.js";
-const command = new SlashCommandBuilder()
+const command = new SlashCommandBuilder() // TODO: remove for release
.setName("categorise")
.setDescription("Categorises your servers channels")
@@ -44,10 +44,8 @@
for (let c of channels) {
// convert channel to a channel if its a string
let channel: any
- console.log(c)
if (typeof c === "string") channel = interaction.guild.channels.cache.get(channel).id
- // @ts-ignore
- else channel = c[0].id
+ else channel = (c[0] as unknown as GuildChannel).id
console.log(channel)
if (!predicted[channel]) predicted[channel] = []
m = await interaction.editReply({embeds: [new EmojiEmbed()
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 {
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index 4e3a1c8..0c596ff 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -12,7 +12,6 @@
.addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true))
const callback = async (interaction: CommandInteraction): Promise<any> => {
- // @ts-ignore
const { renderUser } = client.logger
let suggestion = interaction.options.getString("suggestion");
let confirmation = await new confirmationMessage(interaction)
@@ -23,6 +22,7 @@
.setColor("Danger")
.setInverted(true)
.send()
+ if (confirmation.cancelled) return
if (confirmation.success) {
await (client.channels.cache.get('955161206459600976') as Discord.TextChannel).send({
embeds: [
diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index c2ade39..c431d39 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -28,10 +28,10 @@
.setDescription(keyValueList({
"user": renderUser(interaction.options.getUser("user")),
"role": renderRole(interaction.options.getRole("role"))
- })
- + `\nAre you sure you want to ${action == "give" ? "give the role to" : "remove the role from"} ${interaction.options.getUser("user")}?`)
+ }) + `\nAre you sure you want to ${action == "give" ? "give the role to" : "remove the role from"} ${interaction.options.getUser("user")}?`)
.setColor("Danger")
.send()
+ if (confirmation.cancelled) return
if (confirmation.success) {
try {
let member = interaction.options.getMember("user") as GuildMember
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 10a5887..aacc2e7 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -50,6 +50,7 @@
.setColor("Warning")
.setInverted(true)
.send(true)
+ if (confirmation.cancelled) return
if (confirmation.success) {
try {
await client.database.guilds.write(interaction.guild.id, {"logging.logs.channel": channel.id})
diff --git a/src/commands/settings/logs/ignore.ts b/src/commands/settings/logs/ignore.ts
index 3b81d42..59f6621 100644
--- a/src/commands/settings/logs/ignore.ts
+++ b/src/commands/settings/logs/ignore.ts
@@ -96,6 +96,7 @@
+ `Are you sure you want to **${interaction.options.getString("action") == "add" ? "add" : "remove"}** these to the ignore list?`)
.setColor("Warning")
.send(true)
+ if (confirmation.cancelled) return
if (confirmation.success) {
let data = client.database.guilds.read(interaction.guild.id)
if (channel) data.logging.logs.ignore.channels.concat([channel.id])
diff --git a/src/commands/settings/staff.ts b/src/commands/settings/staff.ts
deleted file mode 100644
index e0d2776..0000000
--- a/src/commands/settings/staff.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-import { ChannelType } from 'discord-api-types';
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import confirmationMessage from "../../utils/confirmationMessage.js";
-import getEmojiByName from "../../utils/getEmojiByName.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
-import client from "../../utils/client.js";
-
-const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("staff")
- .setDescription("Settings for the staff notifications channel")
- .addChannelOption(option => option.setName("channel").setDescription("The channel to set the staff notifications channel to").addChannelTypes([
- ChannelType.GuildNews, ChannelType.GuildText
- ]).setRequired(false))
-
-const callback = async (interaction: CommandInteraction): Promise<any> => {
- let m;
- m = await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Loading")
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], ephemeral: true, fetchReply: true});
- if (interaction.options.getChannel("channel")) {
- let channel
- try {
- channel = interaction.options.getChannel("channel")
- } catch {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.TEXT.DELETE")
- .setTitle("Staff Notifications Channel")
- .setDescription("The channel you provided is not a valid channel")
- .setStatus("Danger")
- ]})
- }
- channel = channel as Discord.TextChannel
- if (channel.guild.id != interaction.guild.id) {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications Channel")
- .setDescription(`You must choose a channel in this server`)
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]});
- }
- let confirmation = await new confirmationMessage(interaction)
- .setEmoji("CHANNEL.TEXT.EDIT")
- .setTitle("Staff Notifications Channel")
- .setDescription(
- `This will be the channel all notifications, updates, user reports etc. will be sent to.\n\n` +
- `Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
- )
- .setColor("Warning")
- .setInverted(true)
- .send(true)
- if (confirmation.success) {
- try {
- await client.database.guilds.write(interaction.guild.id, {"logging.staff.channel": channel.id})
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
- try {
- let data = {
- meta:{
- type: 'logIgnoreUpdated',
- displayName: 'Staff Notifications Channel Updated',
- calculateType: 'nucleusSettingsUpdated',
- color: NucleusColors.yellow,
- emoji: "CHANNEL.TEXT.EDIT",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(channel.id, renderChannel(channel)),
- },
- hidden: {
- guild: interaction.guild.id
- }
- }
- log(data);
- } catch {}
- } catch (e) {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications Channel")
- .setDescription(`Something went wrong and the staff notifications channel could not be set`)
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ], components: []});
- }
- } else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications Channel")
- .setDescription(`No changes were made`)
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: []});
- }
- }
- let clicks = 0;
- let data = await client.database.guilds.read(interaction.guild.id);
- let channel = data.logging.staff.channel;
- while (true) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications channel")
- .setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel(clicks ? "Click again to confirm" : "Reset channel")
- .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setDisabled(!channel)
- ])]});
- let i;
- try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break }
- i.deferUpdate()
- if (i.component.customId == "clear") {
- clicks += 1;
- if (clicks == 2) {
- clicks = 0;
- await client.database.guilds.write(interaction.guild.id, {}, ["logging.staff.channel"])
- channel = undefined;
- }
- } else {
- break
- }
- }
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications channel")
- .setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- .setFooter({text: "Message closed"})
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel("Clear")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])]});
-}
-
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the Manage Server permission to use this command"
- return true;
-}
-
-export { command };
-export { callback };
-export { check };
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index ba16751..16d5f3b 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -109,6 +109,7 @@
.setColor("Warning")
.setInverted(true)
.send(true)
+ if (confirmation.cancelled) return
if (confirmation.success) {
let toUpdate = {}
if (options.enabled !== null) toUpdate["tickets.enabled"] = options.enabled
@@ -345,8 +346,7 @@
}
} else if (i.component.customId == "addType") {
await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter a name for the new type").addComponents(
- // @ts-ignore
- new MessageActionRow().addComponents(new TextInputComponent()
+ new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
.setCustomId("type")
.setLabel("Name")
.setMaxLength(100)
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index 7a68c64..d71fdf0 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -47,6 +47,7 @@
.setColor("Warning")
.setInverted(true)
.send(true)
+ if (confirmation.cancelled) return
if (confirmation.success) {
try {
await client.database.guilds.write(interaction.guild.id, {"verify.role": role.id, "verify.enabled": true});
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index d032598..0c44e37 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -1,21 +1,58 @@
-import { CommandInteraction } from "discord.js";
+import { AutocompleteInteraction, CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import { callback as statsChannelAdd } from '../reflex/statsChannelAdd.js';
import client from "../utils/client.js"
+import EmojiEmbed from "../utils/generateEmojiEmbed.js";
const command = new SlashCommandBuilder()
.setName("tag")
.setDescription("Get and manage the servers tags")
+ .addStringOption(o => o.setName("tag").setDescription("The tag to get").setAutocomplete(true).setRequired(true))
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("This command is not yet finished [tag]");
+const callback = async (interaction: CommandInteraction) => {
+ const config = await client.database.guilds.read(interaction.guild.id)
+ const tags = config.getKey("tags")
+ const tag = tags[interaction.options.getString("tag")]
+ if (!tag) {
+ return await interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Tag")
+ .setDescription(`Tag \`${interaction.options.getString("tag")}\` does not exist`)
+ .setEmoji("PUNISH.NICKNAME.RED")
+ .setStatus("Danger")
+ ], ephemeral: true})
+ }
+ let url = ""
+ let components = []
+ if (tag.match(/^(http|https):\/\/[^ "]+$/)) {
+ url = tag
+ components = [new MessageActionRow().addComponents([new MessageButton()
+ .setLabel("Open")
+ .setURL(url)
+ .setStyle("LINK")
+ ])]
+ }
+ return await interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle(interaction.options.getString("tag"))
+ .setDescription(tag)
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ .setStatus("Success")
+ .setImage(url)
+ ], components: components, ephemeral: true})
+
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
return true;
}
+const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
+ if (!interaction.guild) return [];
+ const config = await client.database.guilds.read(interaction.guild.id)
+ const tags = Object.keys(config.getKey("tags"));
+ return tags
+}
+
export { command };
export { callback };
export { check };
+export { autocomplete };
\ No newline at end of file
diff --git a/src/commands/tags/create.ts b/src/commands/tags/create.ts
index 6dbecf4..0e0d54d 100644
--- a/src/commands/tags/create.ts
+++ b/src/commands/tags/create.ts
@@ -52,6 +52,7 @@
.setColor("Warning")
.setInverted(true)
.send()
+ if (confirmation.cancelled) return
if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Create")
.setDescription("No changes were made")
diff --git a/src/commands/tags/delete.ts b/src/commands/tags/delete.ts
index 2707465..74ebb25 100644
--- a/src/commands/tags/delete.ts
+++ b/src/commands/tags/delete.ts
@@ -32,6 +32,7 @@
.setColor("Warning")
.setInverted(true)
.send()
+ if (confirmation.cancelled) return
if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Delete")
.setDescription("No changes were made")
@@ -39,9 +40,7 @@
.setEmoji("PUNISH.NICKNAME.GREEN")
]});
try {
- data = await client.database.guilds.read(interaction.guild.id);
- delete data.tags[name];
- await client.database.guilds.write(interaction.guild.id, {tags: data});
+ await client.database.guilds.write(interaction.guild.id, null, [`tags.${name}`]);
} catch (e) {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Delete")
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index 77e21ae..2ecdfbf 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -60,6 +60,7 @@
.setColor("Warning")
.setInverted(true)
.send()
+ if (confirmation.cancelled) return
if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Edit")
.setDescription("No changes were made")