I hereby decree that this document shall no longer contain the substring " == ", and hereafter shall be referred to as " === ". This amendment shall take effect immediately.
Signed-off-by: pineafan <pineapplefanyt@gmail.com>
diff --git a/src/commands/categorisationTest.ts b/src/commands/categorisationTest.ts
deleted file mode 100644
index b052783..0000000
--- a/src/commands/categorisationTest.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-import { CommandInteraction, GuildChannel, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
-import { SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
-import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-import client from "../utils/client.js"
-import addPlural from "../utils/plurals.js";
-import getEmojiByName from "../utils/getEmojiByName.js";
-
-const command = new SlashCommandBuilder() // TODO: remove for release
- .setName("categorise")
- .setDescription("Categorises your servers channels")
-
-const callback = async (interaction: CommandInteraction): Promise<any> => {
- let channels = interaction.guild.channels.cache.filter(c => c.type !== "GUILD_CATEGORY");
- let categorised = {}
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Loading...")
- .setEmoji("NUCLEUS.LOADING")
- .setStatus("Success")
- ], ephemeral: true});
- let predicted = {}
- let types = {
- general: ["general", "muted", "main", "topic", "discuss"],
- commands: ["bot", "command", "music"],
- images: ["pic", "selfies", "image"],
- nsfw: ["porn", "nsfw", "sex"],
- links: ["links"],
- advertising: ["ads", "advert", "server", "partner"],
- staff: ["staff", "mod", "admin"],
- spam: ["spam"],
- other: ["random"]
- }
- for (let c of channels.values()) {
- for (let type in types) {
- for (let word of types[type]) {
- if (c.name.toLowerCase().includes(word)) {
- predicted[c.id] = predicted[c.id] ?? []
- predicted[c.id].push(type)
- }
- }
- }
- }
- let m;
- for (let c of channels) {
- // convert channel to a channel if its a string
- let channel: any
- if (typeof c === "string") channel = interaction.guild.channels.cache.get(channel).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()
- .setTitle("Categorise")
- .setDescription(`Select all types that apply to <#${channel}>.\n\n` +
- `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`)
- .setEmoji("CHANNEL.CATEGORY.CREATE")
- .setStatus("Success")
- ], components: [
- new MessageActionRow().addComponents([new MessageSelectMenu()
- .setCustomId("selected")
- .setMaxValues(Object.keys(types).length)
- .setMinValues(1)
- .setPlaceholder("Select all types that apply to this channel")
- .setOptions(Object.keys(types).map(type => ({label: type, value: type})))
- ]),
- new MessageActionRow().addComponents([
- new MessageButton().setLabel("Accept Suggestion").setCustomId("accept").setStyle("SUCCESS").setDisabled(predicted[channel].length === 0)
- .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.TICK", "id"))),
- new MessageButton().setLabel("Use \"Other\"").setCustomId("reject").setStyle("SECONDARY")
- .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.CROSS", "id")))
- ])
- ]})
- let i;
- try {
- i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Categorise")
- .setEmoji("CHANNEL.CATEGORY.DELETE")
- .setStatus("Danger")
- .setDescription(`Select all types that apply to <#${channel}>.\n\n` +
- `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`)
- .setFooter({text: "Message timed out"})
- ]})
- }
- i.deferUpdate()
- let selected;
- if (i.customId === "select") { selected = i.values; }
- if (i.customId === "accept") { selected = predicted[channel]; }
- if (i.customId === "reject") { selected = ["other"]; }
- categorised[channel] = selected
- }
- console.log(categorised)
-}
-
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true;
-}
-
-export { command };
-export { callback };
-export { check };
\ No newline at end of file
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 2068b15..5da8693 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -104,7 +104,7 @@
if (dmd) await dm.delete()
return
}
- let failed = (dmd == false && notify)
+ let failed = (dmd === false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Ban`)
@@ -125,20 +125,20 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
let apply = (interaction.options.getMember("user") as GuildMember)
- if (member == null || me == null || apply == null) throw "That member is not in the server"
+ if (member === null || me === null || apply === null) throw "That member is not in the server"
let memberPos = member.roles ? member.roles.highest.position : 0
let mePos = me.roles ? me.roles.highest.position : 0
let applyPos = apply.roles ? apply.roles.highest.position : 0
// Check if Nucleus can ban the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to ban
- if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the Ban members permission";
+ if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
// Do not allow banning Nucleus
- if (member.id == interaction.guild.me.id) throw "I cannot ban myself"
+ if (member.id === interaction.guild.me.id) throw "I cannot ban myself"
// Allow the owner to ban anyone
- if (member.id == interaction.guild.ownerId) return true
+ if (member.id === interaction.guild.ownerId) return true
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the Ban members permission";
+ if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow ban
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index 0ea93d8..c50c6f4 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -143,7 +143,7 @@
let end = "\n\nJanuary " + currentYear.toString() + pageIndicator(
Math.max(groups.length, 1),
groups.length === 0 ? 1 : pageIndex
- ) + (currentYear == new Date().getFullYear() ? monthNames[new Date().getMonth()] : "December"
+ ) + (currentYear === new Date().getFullYear() ? monthNames[new Date().getMonth()] : "December"
) + " " + currentYear.toString()
if (groups.length > 0) {
let toRender = groups[Math.min(pageIndex, groups.length - 1)]
@@ -204,8 +204,8 @@
let member = (interaction.options.getMember("user")) as Discord.GuildMember;
await interaction.reply({embeds: [new EmojiEmbed()
.setEmoji("NUCLEUS.LOADING")
- .setTitle("Downloading data...")
- .setStatus("Success")
+ .setTitle("Downloading Data")
+ .setStatus("Danger")
], ephemeral: true, fetchReply: true});
let note;
let firstLoad = true;
@@ -260,7 +260,7 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id == interaction.channel.id, (m) => m.customId == "modify")
+ out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify")
} catch (e) { continue }
if (out.fields) {
let toAdd = out.fields.getTextInputValue("note") || null;
@@ -275,7 +275,7 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the Moderate members permission";
+ if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
return true
}
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index eac7ca3..a0b9a97 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -103,7 +103,7 @@
if (dmd) await dm.delete()
return
}
- let failed = (dmd == false && notify)
+ let failed = (dmd === false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Kick`)
@@ -124,20 +124,20 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
let apply = (interaction.options.getMember("user") as GuildMember)
- if (member == null || me == null || apply == null) throw "That member is not in the server"
+ if (member === null || me === null || apply === null) throw "That member is not in the server"
let memberPos = member.roles ? member.roles.highest.position : 0
let mePos = me.roles ? me.roles.highest.position : 0
let applyPos = apply.roles ? apply.roles.highest.position : 0
// Check if Nucleus can kick the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to kick
- if (! me.permissions.has("KICK_MEMBERS")) throw "I do not have the Kick members permission";
+ if (! me.permissions.has("KICK_MEMBERS")) throw "I do not have the *Kick Members* permission";
// Do not allow kicking Nucleus
- if (member.id == interaction.guild.me.id) throw "I cannot kick myself"
+ if (member.id === interaction.guild.me.id) throw "I cannot kick myself"
// Allow the owner to kick anyone
- if (member.id == interaction.guild.ownerId) return true
+ if (member.id === interaction.guild.ownerId) return true
// Check if the user has kick_members permission
- if (! member.permissions.has("KICK_MEMBERS")) throw "You do not have the Kick members permission";
+ if (! member.permissions.has("KICK_MEMBERS")) throw "You do not have the *Kick Members* permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow kick
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index f98bd6a..8bb6854 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
@@ -33,7 +34,7 @@
if (config.moderation.mute.role) serverSettingsDescription += (serverSettingsDescription ? " and " : "") + `given the <@&${config.moderation.mute.role}> role`
let muteTime = (time.days * 24 * 60 * 60) + (time.hours * 60 * 60) + (time.minutes * 60) + time.seconds
- if (muteTime == 0) {
+ if (muteTime === 0) {
let m = await interaction.reply({embeds: [
new EmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
@@ -90,7 +91,7 @@
component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
} catch { return }
component.deferUpdate();
- if (component.customId == "cancel") return interaction.editReply({embeds: [new EmojiEmbed()
+ if (component.customId === "cancel") return interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Mute")
.setDescription("Mute cancelled")
@@ -107,13 +108,7 @@
case "1w": { muteTime = 60 * 60 * 24 * 7; break; }
}
} else {
- await interaction.reply({embeds: [
- new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Mute")
- .setDescription("Loading...")
- .setStatus("Success")
- ], ephemeral: true, fetchReply: true})
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
}
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -199,7 +194,7 @@
})
}
} catch (e){ console.log(e); errors++ }
- if (errors == 2) {
+ if (errors === 2) {
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle(`Mute`)
@@ -210,7 +205,7 @@
return
}
try { await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason) } catch {}
- let failed = (dmd == false && notify)
+ let failed = (dmd === false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Mute`)
@@ -253,22 +248,22 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
let apply = (interaction.options.getMember("user") as GuildMember)
- if (member == null || me == null || apply == null) throw "That member is not in the server"
+ if (member === null || me === null || apply === null) throw "That member is not in the server"
let memberPos = member.roles ? member.roles.highest.position : 0
let mePos = me.roles ? me.roles.highest.position : 0
let applyPos = apply.roles ? apply.roles.highest.position : 0
// Check if Nucleus can mute the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to mute
- if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the Moderate members permission";
+ if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
// Do not allow the user to have admin or be the owner
- if (apply.permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
+ if (apply.permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id === interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
// Do not allow muting Nucleus
- if (member.id == me.id) throw "I cannot mute myself"
+ if (member.id === me.id) throw "I cannot mute myself"
// 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
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the Moderate members permission";
+ if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow mute
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 3ff18ec..cf33109 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -96,7 +96,7 @@
if (dmd) await dm.delete()
return
}
- let failed = (dmd == false && notify)
+ let failed = (dmd === false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Nickname`)
@@ -117,20 +117,20 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
let apply = (interaction.options.getMember("user") as GuildMember)
- if (member == null || me == null || apply == null) throw "That member is not in the server"
+ if (member === null || me === null || apply === null) throw "That member is not in the server"
let memberPos = member.roles ? member.roles.highest.position : 0
let mePos = me.roles ? me.roles.highest.position : 0
let applyPos = apply.roles ? apply.roles.highest.position : 0
// Check if Nucleus can change the nickname
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to change the nickname
- if (! me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the Manage nicknames permission";
+ if (! me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the *Manage Nicknames* permission";
// Allow the owner to change anyone's nickname
- if (member.id == interaction.guild.ownerId) return true
+ if (member.id === interaction.guild.ownerId) return true
// Check if the user has manage_nicknames permission
- if (! member.permissions.has("MANAGE_NICKNAMES")) throw "You do not have the Manage nicknames permission";
+ if (! member.permissions.has("MANAGE_NICKNAMES")) throw "You do not have the *Manage Nicknames* permission";
// Allow changing your own nickname
- if (member == apply) return true
+ if (member === apply) return true
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow change
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index af7beb3..e1e4de9 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -314,11 +314,11 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
// Allow the owner to purge
- if (member.id == interaction.guild.ownerId) return true
+ if (member.id === interaction.guild.ownerId) return true
// Check if the user has manage_messages permission
- if (! member.permissions.has("MANAGE_MESSAGES")) throw "You do not have the Manage messages permission";
+ if (! member.permissions.has("MANAGE_MESSAGES")) throw "You do not have the *Manage Messages* permission";
// Check if nucleus has the manage_messages permission
- if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the Manage messages permission";
+ if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the *Manage Messages* permission";
// Allow warn
return true
}
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index 2b386fd..6b33e12 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -62,9 +62,9 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
// Check if Nucleus can set the slowmode
- if (! interaction.guild.me.permissions.has("MANAGE_CHANNELS")) throw "I do not have the Manage channels permission";
+ if (! interaction.guild.me.permissions.has("MANAGE_CHANNELS")) throw "I do not have the *Manage Channels* permission";
// Check if the user has manage_channel permission
- if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the Manage channels permission";
+ if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the *Manage Channels* permission";
// Allow slowmode
return true
}
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 7fefb1b..5c7e8c4 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -81,7 +81,7 @@
], components: []})
}
try { await client.database.history.create("softban", interaction.guild.id, member.user, reason) } catch {}
- let failed = (dmd == false && notify)
+ let failed = (dmd === false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Softban`)
@@ -102,20 +102,20 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
let apply = (interaction.options.getMember("user") as GuildMember)
- if (member == null || me == null || apply == null) throw "That member is not in the server"
+ if (member === null || me === null || apply === null) throw "That member is not in the server"
let memberPos = member.roles ? member.roles.highest.position : 0
let mePos = me.roles ? me.roles.highest.position : 0
let applyPos = apply.roles ? apply.roles.highest.position : 0
// Check if Nucleus can ban the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to ban
- if (!me.permissions.has("BAN_MEMBERS")) throw "I do not have the Ban members permission";
+ if (!me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
// Do not allow softbanning Nucleus
- if (member.id == me.id) throw "I cannot softban myself"
+ if (member.id === me.id) throw "I cannot softban myself"
// Allow the owner to ban anyone
- if (member.id == interaction.guild.ownerId) return true
+ if (member.id === interaction.guild.ownerId) return true
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the Ban members permission";
+ if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow softban
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 035b809..2605d28 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -15,9 +15,9 @@
const callback = async (interaction: CommandInteraction): Promise<any> => {
let bans = await interaction.guild.bans.fetch()
let user = interaction.options.getString("user")
- let resolved = bans.find(ban => ban.user.id == user)
- if (!resolved) resolved = bans.find(ban => ban.user.username.toLowerCase() == user.toLowerCase())
- if (!resolved) resolved = bans.find(ban => ban.user.tag.toLowerCase() == user.toLowerCase())
+ let resolved = bans.find(ban => ban.user.id === user)
+ if (!resolved) resolved = bans.find(ban => ban.user.username.toLowerCase() === user.toLowerCase())
+ if (!resolved) resolved = bans.find(ban => ban.user.tag.toLowerCase() === user.toLowerCase())
if (!resolved) {
return interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Unban")
@@ -92,11 +92,11 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
// Check if Nucleus can unban members
- if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the Ban members permission";
+ if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
// Allow the owner to unban anyone
- if (member.id == interaction.guild.ownerId) return true
+ if (member.id === interaction.guild.ownerId) return true
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the Ban members permission";
+ if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
// Allow unban
return true
}
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 56a0b56..25aacfa 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -89,7 +89,7 @@
}
}
log(data);
- let failed = (dmd == false && notify)
+ let failed = (dmd === false && notify)
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Unmute`)
@@ -110,20 +110,20 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
let apply = (interaction.options.getMember("user") as GuildMember)
- if (member == null || me == null || apply == null) throw "That member is not in the server"
+ if (member === null || me === null || apply === null) throw "That member is not in the server"
let memberPos = member.roles ? member.roles.highest.position : 0
let mePos = me.roles ? me.roles.highest.position : 0
let applyPos = apply.roles ? apply.roles.highest.position : 0
// Check if Nucleus can unmute the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to unmute
- if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the Moderate members permission";
+ if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
// Do not allow the user to have admin or be the owner
- if (apply.permissions.has("ADMINISTRATOR") || apply.id == interaction.guild.ownerId) throw "You cannot unmute an admin or the owner"
+ if (apply.permissions.has("ADMINISTRATOR") || apply.id === interaction.guild.ownerId) throw "You cannot unmute an admin or the owner"
// Allow the owner to unmute 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
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the Moderate members permission";
+ if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow unmute
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index 684fc3a..2f5cacc 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -51,7 +51,7 @@
`**${channels[page][0].parent ? channels[page][0].parent.name : "Uncategorised"}**` + "\n" +
channels[page].map(c => {
let channelType = c.type
- if (interaction.guild.rulesChannelId == c.id) channelType = "RULES"
+ if (interaction.guild.rulesChannelId === c.id) channelType = "RULES"
else if ("nsfw" in c && c.nsfw) channelType += "_NSFW"
return c.permissionsFor(member).has("VIEW_CHANNEL") ? (
`${getEmojiByName("ICONS.CHANNEL." + channelType)} ${c.name}\n` + (() => {
@@ -98,7 +98,7 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
- if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+ if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
return true
}
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 3e76321..5a42911 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -98,7 +98,7 @@
interaction.user, reason
)} catch {}
log(data);
- let failed = (dmd == false && notify)
+ let failed = (dmd === false && notify)
if (!failed) {
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
@@ -138,7 +138,7 @@
.setStatus("Success")
], components: []})
}
- if ( component.customId == "here" ) {
+ if ( component.customId === "here" ) {
await interaction.channel.send({
embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.RED`)
@@ -179,16 +179,16 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
let apply = (interaction.options.getMember("user") as GuildMember)
- if (member == null || me == null || apply == null) throw "That member is not in the server"
+ if (member === null || me === null || apply === null) throw "That member is not in the server"
let memberPos = member.roles ? member.roles.highest.position : 0
let mePos = me.roles ? me.roles.highest.position : 0
let applyPos = apply.roles ? apply.roles.highest.position : 0
// Do not allow warning bots
if (member.user.bot) throw "I cannot warn bots"
// Allow the owner to warn 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
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the Moderate members permission";
+ if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow warn
diff --git a/src/commands/nucleus/ping.ts b/src/commands/nucleus/ping.ts
index f10dcae..6353843 100644
--- a/src/commands/nucleus/ping.ts
+++ b/src/commands/nucleus/ping.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -13,12 +14,7 @@
// WEBSOCKET | Nucleus -> Discord
// EDITING | Nucleus -> discord -> nucleus | edit time / 2
let initial = new Date().getTime();
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Ping")
- .setDescription(`Checking ping times...`)
- .setEmoji("NUCLEUS.LOADING")
- .setStatus("Danger")
- ], ephemeral: true});
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
let ping = new Date().getTime() - initial;
interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Ping")
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index 6d62745..81d1503 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,35 +1,169 @@
+import { LoadingEmbed } from './../utils/defaultEmbeds.js';
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
-import { SlashCommandBuilder } from "@discordjs/builders";
+import { SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import { testLink, testMalware, testNSFW } from "../reflex/scanners.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
+import getEmojiByName from "../utils/getEmojiByName.js";
+import createPageIndicator from "../utils/createPageIndicator.js";
+import client from "../utils/client.js";
+import confirmationMessage from "../utils/confirmationMessage.js";
const command = new SlashCommandBuilder()
.setName("privacy")
.setDescription("Information and options for you and your server's settings")
+class Embed {
+ embed: Discord.MessageEmbed;
+ title: string;
+ description: string = "";
+ pageId: number = 0;
+ components?: MessageActionRow[] = [];
+ setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
+ setTitle(title: string) { this.title = title; return this; }
+ setDescription(description: string) { this.description = description; return this; }
+ setPageId(pageId: number) { this.pageId = pageId; return this; }
+ setComponents(components: MessageActionRow[]) { this.components = components; return this; }
+}
+
const callback = async (interaction: CommandInteraction): Promise<any> => {
- let components = [];
- if (interaction.inCachedGuild() && interaction.member.permissions.has("MANAGE_GUILD")) {
- components.push(new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Clear all data")
- .setEmoji("CONTROL.CROSS")
- .setCustomId("clear")
- .setStyle("DANGER")
- ]));
+ let pages = [
+ new Embed()
+ .setEmbed(new EmojiEmbed()
+ .setTitle("Nucleus Privacy")
+ .setDescription(
+ "Nucleus is a bot that naturally needs to store data about servers.\n" +
+ "We are entirely [open source](https://github.com/ClicksMinutePer/Nucleus), so you can check exactly what we store, and how it works.\n\n" +
+ "If you are a server administrator, you can view the options page in the dropdown under this message.\n\n" +
+ "Any questions about Nucleus, how it works and data stored can be asked in [our server](https://discord.gg/bPaNnxe)."
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ ).setTitle("Welcome").setDescription("General privacy information").setPageId(0),
+ new Embed()
+ .setEmbed(new EmojiEmbed()
+ .setTitle("Scanners")
+ .setDescription(
+ "Nucleus uses [unscan](https://unscan.co) to scan links, images and files for malware and other threats.\n" +
+ "This service's [privacy policy](https://unscan.co/policies) is public, and they \"do not store or sell your data.\""
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ ).setTitle("Scanners").setDescription("About Unscan").setPageId(1),
+ new Embed()
+ .setEmbed(new EmojiEmbed()
+ .setTitle("Link scanning and Transcripts")
+ .setDescription(
+ "**Facebook** - Facebook trackers include data such as your date of birth, and guess your age if not entered, your preferences, who you interact with and more.\n" +
+ "**AMP** - AMP is a technology that allows websites to be served by Google. This means Google can store and track data, and are pushing this to as many pages as possible.\n\n" +
+ "Transcripts allow you to store all messages sent in a channel. This could be an issue in some cases, as they are hosted on [Pastebin](https://pastebin.com), so a leaked link could show all messages sent in the channel.\n"
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ ).setTitle("Link scanning and Transcripts").setDescription("Regarding Facebook and AMP filter types, and ticket transcripts").setPageId(2)
+ ].concat((interaction.member as Discord.GuildMember).permissions.has("ADMINISTRATOR") ? [new Embed()
+ .setEmbed(new EmojiEmbed()
+ .setTitle("Options")
+ .setDescription(
+ "Below are buttons for controlling this servers privacy settings"
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ ).setTitle("Options").setDescription("Options").setPageId(3).setComponents([new MessageActionRow().addComponents([
+ new MessageButton().setLabel("Clear all data").setCustomId("clear-all-data").setStyle("DANGER")
+ ])])
+ ] : []);
+ let m;
+ m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
+ let page = 0;
+
+ let selectPaneOpen = false;
+ let nextFooter = null;
+
+ while (true) {
+ let selectPane = []
+
+ if (selectPaneOpen) {
+ let options = [];
+ pages.forEach(embed => {
+ options.push(new SelectMenuOption({
+ label: embed.title,
+ value: embed.pageId.toString(),
+ description: embed.description || "",
+ }))
+ })
+ selectPane = [new MessageActionRow().addComponents([
+ new Discord.MessageSelectMenu()
+ .addOptions(options)
+ .setCustomId("page")
+ .setMaxValues(1)
+ .setPlaceholder("Choose a page...")
+ ])]
+ }
+ let components = selectPane.concat([new MessageActionRow().addComponents([
+ new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(page === 0),
+ new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(false),
+ new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1)
+ ])])
+ let em = new Discord.MessageEmbed(pages[page].embed)
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
+ em.setFooter({text: nextFooter ?? ""})
+ await interaction.editReply({
+ embeds: [em],
+ components: components.concat(pages[page].components)
+ });
+ let i
+ try {
+ i = await m.awaitMessageComponent({time: 300000});
+ } catch(e) { break }
+ nextFooter = null
+ i.deferUpdate()
+ if (i.component.customId === "left") {
+ if (page > 0) page--;
+ selectPaneOpen = false;
+ } else if (i.component.customId === "right") {
+ if (page < pages.length - 1) page++;
+ selectPaneOpen = false;
+ } else if (i.component.customId === "select") {
+ selectPaneOpen = !selectPaneOpen;
+ } else if (i.component.customId === "page") {
+ page = parseInt(i.values[0]);
+ selectPaneOpen = false;
+ } else if (i.component.customId === "clear-all-data") {
+ let confirmation = await new confirmationMessage(interaction)
+ .setEmoji("CONTROL.BLOCKCROSS")
+ .setTitle("Clear All Data")
+ .setDescription(
+ `Are you sure you want to delete all data on this server? This includes your settings and all punishment histories.\n\n` +
+ "**This cannot be undone.**"
+ )
+ .setColor("Danger")
+ .send(true)
+ if (confirmation.cancelled) { break; }
+ if (confirmation.success) {
+ client.database.guilds.delete(interaction.guild.id);
+ client.database.history.delete(interaction.guild.id);
+ nextFooter = "All data cleared";
+ continue;
+ } else {
+ nextFooter = "No changes were made";
+ continue;
+ }
+ } else {
+ let em = new Discord.MessageEmbed(pages[page].embed)
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page))
+ em.setFooter({text: "Message closed"});
+ interaction.editReply({embeds: [em], components: []});
+ return
+ }
}
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Privacy")
- .setDescription(
- "**Link Scanning Types**\n" +
- "> Facebook - Facebook trackers include data such as your date of birth, and guess your age if not entered, your preferences, who you interact with and more.\n" +
- "> AMP - AMP is a technology that allows websites to be served by Google. This means Google can store and track data, and are pushing this to as many pages as possible.\n\n" +
- "**Transcripts**\n" +
- "> Transcripts allow you to store all messages sent in a channel. This could be an issue in some cases, as they are hosted on [Pastebin](https://pastebin.com), so a leaked link could show all messages sent in the channel.\n"
- )
- .setStatus("Success")
- .setEmoji("NUCLEUS.COMMANDS.LOCK")
- ], components: components});
+ let em = new Discord.MessageEmbed(pages[page].embed)
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page))
+ em.setFooter({text: "Message timed out"});
+ await interaction.editReply({
+ embeds: [em],
+ components: []
+ });
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index c431d39..274dd3d 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -28,7 +28,7 @@
.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
@@ -36,7 +36,7 @@
try {
let member = interaction.options.getMember("user") as GuildMember
let role = interaction.options.getRole("role") as Role
- if (interaction.options.getString("action") == "give") {
+ if (interaction.options.getString("action") === "give") {
member.roles.add(role)
} else {
member.roles.remove(role)
@@ -51,7 +51,7 @@
}
return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Role")
- .setDescription(`The role has been ${action == "give" ? "given" : "removed"} successfully`)
+ .setDescription(`The role has been ${action === "give" ? "given" : "removed"} successfully`)
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
], components: []})
@@ -69,13 +69,13 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
let apply = (interaction.options.getMember("user") as GuildMember)
- if (member == null || me == null || apply == null) throw "That member is not in the server"
+ if (member === null || me === null || apply === null) throw "That member is not in the server"
// Check if Nucleus has permission to role
- if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the Manage roles permission";
+ if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the *Manage Roles* permission";
// Allow the owner to role anyone
- if (member.id == interaction.guild.ownerId) return true
+ if (member.id === interaction.guild.ownerId) return true
// Check if the user has manage_roles permission
- if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+ if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
// Allow role
return true;
}
diff --git a/src/commands/server/about.ts b/src/commands/server/about.ts
index 28e09aa..70998d5 100644
--- a/src/commands/server/about.ts
+++ b/src/commands/server/about.ts
@@ -31,7 +31,7 @@
"2 factor authentication": `${guild.mfaLevel === "NONE" ? `${getEmojiByName("CONTROL.CROSS")} No` : `${getEmojiByName("CONTROL.TICK")} Yes`}`,
"verification level": `${toCapitals(guild.verificationLevel)}`,
"explicit content filter": `${toCapitals(guild.explicitContentFilter.toString().replace(/_/, " ", ))}`,
- "nitro boost level": `${guild.premiumTier != "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
+ "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
"channels": `${guild.channels.cache.size}`,
"roles": `${guild.roles.cache.size}`,
"members": `${guild.memberCount}`,
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index df2cdb4..23d5c66 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import Discord, { CommandInteraction, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -15,11 +16,7 @@
.addRoleOption(o => o.setName("role").setDescription("The role given when a member is muted"))
const callback = async (interaction: CommandInteraction): Promise<any> => {
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Loading")
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], ephemeral: true, fetchReply: true});
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
let m;
let clicked = "";
if (interaction.options.getRole("role")) {
@@ -49,7 +46,7 @@
.setEmoji("PUNISH.BAN.GREEN")
.setStatus("Success")
.setDescription(
- "These links are shown below the message sent in a user's DM when they are warned, banned, etc.\n\n" +
+ "These links are shown below the message sent in a user's DM when they are punished.\n\n" +
`**Mute Role:** ` + (moderation.mute.role ? `<@&${moderation.mute.role}>` : "*None set*")
)
], components: [new MessageActionRow().addComponents([
@@ -76,13 +73,16 @@
} catch (e) { return }
let chosen = moderation[i.customId] ?? {text: null, url: null};
if (i.component.customId === "clearMuteRole") {
+ i.deferUpdate()
if (clicked === "clearMuteRole") {
- await client.database.guilds.write(interaction.guild.id, { moderation: { mute: { role: null } } });
+ await client.database.guilds.write(interaction.guild.id, {"moderation.mute.role": null });
} else { clicked = "clearMuteRole" }
+ continue
} else { clicked = "" }
if (i.component.customId === "timeout") {
await i.deferUpdate()
- await client.database.guilds.write(interaction.guild.id, { moderation: { mute: { timeout: !moderation.mute.timeout } } });
+ await client.database.guilds.write(interaction.guild.id, {"moderation.mute.timeout": !moderation.mute.timeout } );
+ continue
} else if (i.customId) {
await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Options for ${i.customId}`).addComponents(
new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
@@ -117,7 +117,7 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id == interaction.channel.id, (m) => true)
+ out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => true)
} catch (e) { continue }
if (out.fields) {
let buttonText = out.fields.getTextInputValue("name");
@@ -125,7 +125,7 @@
let current = chosen;
if (current.text !== buttonText || current.link !== buttonLink) {
chosen = { text: buttonText, link: buttonLink };
- await client.database.guilds.write(interaction.guild.id, { ["moderation" + i.customId]: { text: buttonText, link: buttonLink }});
+ await client.database.guilds.write(interaction.guild.id, { ["moderation." + i.customId]: { text: buttonText, link: buttonLink }});
}
} else { continue }
}
@@ -135,7 +135,7 @@
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"
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
return true;
}
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index 0842923..2dae74e 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
import { ChannelType } from 'discord-api-types';
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
@@ -17,11 +18,7 @@
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});
+ m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
if (interaction.options.getChannel("channel")) {
let channel
try {
@@ -35,7 +32,7 @@
]})
}
channel = channel as Discord.TextChannel
- if (channel.guild.id != interaction.guild.id) {
+ if (channel.guild.id !== interaction.guild.id) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Attachment Log Channel")
.setDescription(`You must choose a channel in this server`)
@@ -120,11 +117,11 @@
i = await m.awaitMessageComponent({time: 300000});
} catch(e) { break }
i.deferUpdate()
- if (i.component.customId == "clear") {
+ if (i.component.customId === "clear") {
clicks += 1;
- if (clicks == 2) {
+ if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, {}, ["logging.announcements.channel"])
+ await client.database.guilds.write(interaction.guild.id, null, ["logging.announcements.channel"])
channel = undefined;
}
} else {
@@ -148,7 +145,7 @@
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"
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
return true;
}
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index aacc2e7..4030108 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
import { ChannelType } from 'discord-api-types';
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
@@ -17,11 +18,7 @@
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});
+ m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
if (interaction.options.getChannel("channel")) {
let channel
try {
@@ -35,7 +32,7 @@
]})
}
channel = channel as Discord.TextChannel
- if (channel.guild.id != interaction.guild.id) {
+ if (channel.guild.id !== interaction.guild.id) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Log Channel")
.setDescription(`You must choose a channel in this server`)
@@ -115,11 +112,11 @@
i = await m.awaitMessageComponent({time: 300000});
} catch(e) { break }
i.deferUpdate()
- if (i.component.customId == "clear") {
+ if (i.component.customId === "clear") {
clicks += 1;
- if (clicks == 2) {
+ if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, {}, ["logging.logs.channel"])
+ await client.database.guilds.write(interaction.guild.id, null, ["logging.logs.channel"])
channel = undefined;
}
} else {
@@ -143,7 +140,7 @@
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"
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
return true;
}
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 3cb7230..5867338 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
import { ChannelType } from 'discord-api-types';
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
@@ -17,11 +18,7 @@
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});
+ m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
if (interaction.options.getChannel("channel")) {
let channel
try {
@@ -35,7 +32,7 @@
]})
}
channel = channel as Discord.TextChannel
- if (channel.guild.id != interaction.guild.id) {
+ 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`)
@@ -117,11 +114,11 @@
i = await m.awaitMessageComponent({time: 300000});
} catch(e) { break }
i.deferUpdate()
- if (i.component.customId == "clear") {
+ if (i.component.customId === "clear") {
clicks += 1;
- if (clicks == 2) {
+ if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, {}, ["logging.staff.channel"])
+ await client.database.guilds.write(interaction.guild.id, null, ["logging.staff.channel"])
channel = undefined;
}
} else {
@@ -145,7 +142,7 @@
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"
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
return true;
}
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index ec54820..6f95b46 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -17,7 +17,7 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_ROLES")) throw "You must have the Manage roles permission to use this command"
+ if (!member.permissions.has("MANAGE_ROLES")) throw "You must have the *Manage Roles* permission to use this command"
return true;
}
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 3159e2d..d972674 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import { ChannelType } from 'discord-api-types';
import Discord, { AutocompleteInteraction, CommandInteraction, Message, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -8,6 +9,7 @@
import client from "../../utils/client.js";
import convertCurlyBracketString from '../../utils/convertCurlyBracketString.js';
import {callback as statsChannelAddCallback} from "../../reflex/statsChannelUpdate.js";
+import singleNotify from '../../utils/singleNotify.js';
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -17,14 +19,20 @@
.addStringOption(option => option.setName("name").setDescription("The new channel name | Enter any text or use the extra variables like {memberCount}").setAutocomplete(true))
const callback = async (interaction: CommandInteraction): Promise<any> => {
+ singleNotify("statsChannelDeleted", interaction.guild.id, true)
let m;
- m = await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Loading")
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], ephemeral: true, fetchReply: true});
+ m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+ let config = await client.database.guilds.read(interaction.guild.id);
if (interaction.options.getString("name")) {
- let channel
+ let channel;
+ if (Object.keys(config.getKey("stats")).length >= 25) {
+ return await interaction.editReply({embeds: [new EmojiEmbed()
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ .setTitle("Stats Channel")
+ .setDescription("You can only have 25 stats channels in a server")
+ .setStatus("Danger")
+ ]})
+ }
try {
channel = interaction.options.getChannel("channel")
} catch {
@@ -36,7 +44,7 @@
]})
}
channel = channel as Discord.TextChannel
- if (channel.guild.id != interaction.guild.id) {
+ if (channel.guild.id !== interaction.guild.id) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Stats Channel")
.setDescription(`You must choose a channel in this server`)
@@ -51,7 +59,7 @@
let confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.TEXT.EDIT")
.setTitle("Stats Channel")
- .setDescription(`Are you sure you want to set <#${channel.id}> to a stats channel?\n\n*Preview: ${newName}*`)
+ .setDescription(`Are you sure you want to set <#${channel.id}> to a stats channel?\n\n*Preview: ${newName.replace(/^ +| $/g, "")}*`)
.setColor("Warning")
.setInverted(true)
.send(true)
@@ -104,7 +112,7 @@
await statsChannelAddCallback(client, interaction.member);
}
while (true) {
- let config = await client.database.guilds.read(interaction.guild.id);
+ config = await client.database.guilds.read(interaction.guild.id);
let stats = config.getKey("stats")
let selectMenu = new MessageSelectMenu()
.setCustomId("remove")
@@ -133,8 +141,7 @@
i.deferUpdate()
if (i.customId === "remove") {
let toRemove = i.values;
- console.log(toRemove.map(k => `stats.${k}`))
- await client.database.guilds.write(interaction.guild.id, {}, toRemove.map(k => `stats.${k}`));
+ await client.database.guilds.write(interaction.guild.id, null, toRemove.map(k => `stats.${k}`));
}
}
await interaction.editReply({embeds: [new EmojiEmbed()
@@ -147,7 +154,7 @@
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"
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
return true;
}
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 16d5f3b..f199ac3 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import getEmojiByName from "../../utils/getEmojiByName.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -21,13 +22,7 @@
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
- });
+ m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
let options = {
enabled: interaction.options.getString("enabled") as string | boolean,
category: interaction.options.getChannel("category"),
@@ -51,7 +46,7 @@
})
}
channel = channel as Discord.CategoryChannel
- if (channel.guild.id != interaction.guild.id) return interaction.editReply({
+ if (channel.guild.id !== interaction.guild.id) return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Category")
.setDescription(`You must choose a category in this server`)
@@ -85,7 +80,7 @@
})
}
role = role as Discord.Role
- if (role.guild.id != interaction.guild.id) return interaction.editReply({
+ if (role.guild.id !== interaction.guild.id) return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Support Ping")
.setDescription(`You must choose a role in this server`)
@@ -174,23 +169,23 @@
.setStyle(data.enabled ? "SUCCESS" : "DANGER")
.setCustomId("enabled"),
new MessageButton()
- .setLabel(lastClicked == "cat" ? "Click again to confirm" : "Clear category")
+ .setLabel(lastClicked === "cat" ? "Click again to confirm" : "Clear category")
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setCustomId("clearCategory")
- .setDisabled(data.category == null),
+ .setDisabled(data.category === null),
new MessageButton()
- .setLabel(lastClicked == "max" ? "Click again to confirm" : "Reset max tickets")
+ .setLabel(lastClicked === "max" ? "Click again to confirm" : "Reset max tickets")
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setCustomId("clearMaxTickets")
- .setDisabled(data.maxTickets == 5),
+ .setDisabled(data.maxTickets === 5),
new MessageButton()
- .setLabel(lastClicked == "sup" ? "Click again to confirm" : "Clear support ping")
+ .setLabel(lastClicked === "sup" ? "Click again to confirm" : "Clear support ping")
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setCustomId("clearSupportPing")
- .setDisabled(data.supportRole == null),
+ .setDisabled(data.supportRole === null),
]), new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Manage types")
@@ -204,28 +199,28 @@
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) { break }
i.deferUpdate()
- if (i.component.customId == "clearCategory") {
- if (lastClicked == "cat") {
+ if (i.component.customId === "clearCategory") {
+ if (lastClicked === "cat") {
lastClicked = "";
- await client.database.guilds.write(interaction.guild.id, {}, ["tickets.category"])
+ await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"])
data.category = undefined;
} else lastClicked = "cat";
- } else if (i.component.customId == "clearMaxTickets") {
- if (lastClicked == "max") {
+ } else if (i.component.customId === "clearMaxTickets") {
+ if (lastClicked === "max") {
lastClicked = "";
- await client.database.guilds.write(interaction.guild.id, {}, ["tickets.maxTickets"])
+ await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"])
data.maxTickets = 5;
} else lastClicked = "max";
- } else if (i.component.customId == "clearSupportPing") {
- if (lastClicked == "sup") {
+ } else if (i.component.customId === "clearSupportPing") {
+ if (lastClicked === "sup") {
lastClicked = "";
- await client.database.guilds.write(interaction.guild.id, {}, ["tickets.supportRole"])
+ await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"])
data.supportRole = undefined;
} else lastClicked = "sup";
- } else if (i.component.customId == "enabled") {
+ } else if (i.component.customId === "enabled") {
await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled })
data.enabled = !data.enabled;
- } else if (i.component.customId == "manageTypes") {
+ } else if (i.component.customId === "manageTypes") {
data = await manageTypes(interaction, data, m);
} else {
break
@@ -329,12 +324,12 @@
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) { break }
- if (i.component.customId == "types") {
+ if (i.component.customId === "types") {
i.deferUpdate()
let types = toHexInteger(i.values, ticketTypes);
await client.database.guilds.write(interaction.guild.id, { "tickets.types": types })
data.types = types;
- } else if (i.component.customId == "removeTypes") {
+ } else if (i.component.customId === "removeTypes") {
i.deferUpdate()
let types = i.values
let customTypes = data.customTypes;
@@ -344,7 +339,7 @@
await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes })
data.customTypes = customTypes;
}
- } else if (i.component.customId == "addType") {
+ } else if (i.component.customId === "addType") {
await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter a name for the new type").addComponents(
new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
.setCustomId("type")
@@ -371,7 +366,7 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id == interaction.channel.id, (m) => m.customId == "addType")
+ out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "addType")
} catch (e) { continue }
if (out.fields) {
let toAdd = out.fields.getTextInputValue("type");
@@ -385,11 +380,11 @@
data.customTypes.push(toAdd);
}
} else { continue }
- } else if (i.component.customId == "switchToDefault") {
+ } else if (i.component.customId === "switchToDefault") {
i.deferUpdate()
await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, [])
data.useCustom = false;
- } else if (i.component.customId == "switchToCustom") {
+ } else if (i.component.customId === "switchToCustom") {
i.deferUpdate()
await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, [])
data.useCustom = true;
@@ -404,7 +399,7 @@
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"
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
return true;
}
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index d71fdf0..14dfe8d 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -14,11 +15,7 @@
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});
+ m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
if (interaction.options.getRole("role")) {
let role
try {
@@ -32,7 +29,7 @@
]})
}
role = role as Discord.Role
- if (role.guild.id != interaction.guild.id) {
+ if (role.guild.id !== interaction.guild.id) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
.setDescription(`You must choose a role in this server`)
@@ -100,23 +97,24 @@
.setDescription(role ? `Your verify role is currently set to <@&${role}>` : `You have not set a verify role`)
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel(clicks ? "Click again to confirm" : "Reset role")
- .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setDisabled(!role)
+ ], components: [new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel(clicks ? "Click again to confirm" : "Reset role")
+ .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
+ .setStyle("DANGER")
+ .setDisabled(!role)
])]});
let i;
try {
i = await m.awaitMessageComponent({time: 300000});
} catch(e) { break }
i.deferUpdate()
- if (i.component.customId == "clear") {
+ if (i.component.customId === "clear") {
clicks += 1;
- if (clicks == 2) {
+ if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, {}, ["verify.role", "verify.enabled"])
+ await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"])
role = undefined;
}
} else {
@@ -134,13 +132,13 @@
.setLabel("Clear")
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
.setStyle("SECONDARY")
- .setDisabled(true)
+ .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"
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
return true;
}
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index 0c44e37..03b13c6 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -55,4 +55,4 @@
export { command };
export { callback };
export { check };
-export { autocomplete };
\ No newline at end of file
+export { autocomplete };
diff --git a/src/commands/tags/create.ts b/src/commands/tags/create.ts
index 0e0d54d..b0a278d 100644
--- a/src/commands/tags/create.ts
+++ b/src/commands/tags/create.ts
@@ -79,7 +79,7 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the Manage Messages permission to use this command"
+ if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Server* permission to use this command"
return true;
}
diff --git a/src/commands/tags/delete.ts b/src/commands/tags/delete.ts
index f531e93..68a02d4 100644
--- a/src/commands/tags/delete.ts
+++ b/src/commands/tags/delete.ts
@@ -60,7 +60,7 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the Manage Messages permission to use this command"
+ if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command"
return true;
}
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index 2ecdfbf..2f585cd 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -75,7 +75,7 @@
toUnset.push(`tags.${name}`);
toSet[`tags.${newname}`] = data.tags[name];
}
- await client.database.guilds.write(interaction.guild.id, toSet, toUnset);
+ await client.database.guilds.write(interaction.guild.id, toSet === {} ? null : toSet, toUnset);
} catch (e) {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Edit")
@@ -94,7 +94,7 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the Manage Messages permission to use this command"
+ if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command"
return true;
}
diff --git a/src/commands/tags/list.ts b/src/commands/tags/list.ts
index a534791..c335267 100644
--- a/src/commands/tags/list.ts
+++ b/src/commands/tags/list.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
@@ -53,15 +54,7 @@
).setTitle(`Page ${pages.length + 1}`).setPageId(pages.length))
}
let m;
- m = await interaction.reply({
- embeds: [
- new EmojiEmbed()
- .setTitle("Welcome")
- .setDescription(`One moment...`)
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], fetchReply: true, ephemeral: true
- });
+ m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
let page = 0;
let selectPaneOpen = false;
while (true) {
@@ -100,15 +93,15 @@
i = await m.awaitMessageComponent({time: 300000 });
} catch (e) { break }
i.deferUpdate()
- if (i.component.customId == "left") {
+ if (i.component.customId === "left") {
if (page > 0) page--;
selectPaneOpen = false;
- } else if (i.component.customId == "right") {
+ } else if (i.component.customId === "right") {
if (page < pages.length - 1) page++;
selectPaneOpen = false;
- } else if (i.component.customId == "select") {
+ } else if (i.component.customId === "select") {
selectPaneOpen = !selectPaneOpen;
- } else if (i.component.customId == "page") {
+ } else if (i.component.customId === "page") {
page = parseInt(i.values[0]);
selectPaneOpen = false;
} else {
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 8557d15..82eda6a 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
@@ -64,7 +65,7 @@
membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp)
let joinPos = membersArray.findIndex(m => m.id === member.user.id)
- let roles = member.roles.cache.filter(r => r.id != interaction.guild.id).sort()
+ let roles = member.roles.cache.filter(r => r.id !== interaction.guild.id).sort()
let s = "";
let count = 0;
let ended = false
@@ -158,7 +159,7 @@
).setTitle("Key Permissions").setDescription("Key permissions the user has").setPageId(2),
]
let m
- m = await interaction.reply({embeds: [new EmojiEmbed().setTitle("Loading").setEmoji("NUCLEUS.LOADING").setStatus("Danger")], fetchReply: true, ephemeral: true});
+ m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
let page = 0
let breakReason = ""
while (true) {
@@ -212,18 +213,18 @@
i = await m.awaitMessageComponent({time: 300000});
} catch { breakReason = "Message timed out"; break }
i.deferUpdate()
- if (i.component.customId == "left") {
+ if (i.component.customId === "left") {
if (page > 0) page--;
selectPaneOpen = false;
- } else if (i.component.customId == "right") {
+ } else if (i.component.customId === "right") {
if (page < embeds.length - 1) page++;
selectPaneOpen = false;
- } else if (i.component.customId == "select") {
+ } else if (i.component.customId === "select") {
selectPaneOpen = !selectPaneOpen;
- } else if (i.component.customId == "close") {
+ } else if (i.component.customId === "close") {
breakReason = "Message closed";
break;
- } else if (i.component.customId == "page") {
+ } else if (i.component.customId === "page") {
page = parseInt(i.values[0]);
selectPaneOpen = false;
} else {
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index 54af9d7..f6c1df1 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
@@ -15,9 +16,9 @@
const generateFromTrack = (position: number, active: any, size: number, disabled: any) => {
active = active ? "ACTIVE" : "INACTIVE"
disabled = disabled ? "GREY." : ""
- if (position == 0 && size == 1) return "TRACKS.SINGLE." + disabled + active
- if (position == size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active
- if (position == 0) return "TRACKS.VERTICAL.TOP." + disabled + active
+ if (position === 0 && size === 1) return "TRACKS.SINGLE." + disabled + active
+ if (position === size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active
+ if (position === 0) return "TRACKS.VERTICAL.TOP." + disabled + active
return "TRACKS.VERTICAL.MIDDLE." + disabled + active
}
@@ -26,11 +27,7 @@
const member = interaction.options.getMember("user") as GuildMember;
const guild = interaction.guild;
let config = await client.database.guilds.read(guild.id);
- await interaction.reply({embeds: [new EmojiEmbed()
- .setEmoji("NUCLEUS.LOADING")
- .setTitle("Loading")
- .setStatus("Danger")
- ], ephemeral: true})
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
let track = 0
let generated;
const roles = await guild.roles.fetch()
@@ -43,10 +40,10 @@
let dropdown = new Discord.MessageSelectMenu().addOptions(config.tracks.map((option, index) => {
let hasRoleInTrack = option.track.some(element => {return memberRoles.cache.has(element)})
return new SelectMenuOption({
- default: index == track,
+ default: index === track,
label: option.name,
value: index.toString(),
- description: option.track.length == 0 ? "No" : addPlural(option.track.length, "role"),
+ description: option.track.length === 0 ? "No" : addPlural(option.track.length, "role"),
emoji: client.emojis.resolve(getEmojiByName("TRACKS.SINGLE." + (hasRoleInTrack ? "ACTIVE" : "INACTIVE"), "id"))
})
})).setCustomId("select").setMaxValues(1)
@@ -94,7 +91,7 @@
generated += "You don't have permission to manage one or more of the users roles, and therefore can't select one to keep."
}
} else {
- currentRoleIndex = selected.length == 0 ? -1 : data.track.indexOf(selected[0].toString())
+ currentRoleIndex = selected.length === 0 ? -1 : data.track.indexOf(selected[0].toString())
}
let m = await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("TRACKS.ICON")
@@ -112,7 +109,7 @@
.setLabel("Move up")
.setCustomId("promote")
.setStyle("SUCCESS")
- .setDisabled(conflict || currentRoleIndex == 0 || (currentRoleIndex == -1 ? false : !allowed[currentRoleIndex - 1])),
+ .setDisabled(conflict || currentRoleIndex === 0 || (currentRoleIndex === -1 ? false : !allowed[currentRoleIndex - 1])),
new MessageButton()
.setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
.setLabel("Move down")
@@ -120,7 +117,7 @@
.setStyle("DANGER")
.setDisabled(conflict || (
data.nullable ? currentRoleIndex <= -1 :
- currentRoleIndex == data.track.length - 1 || currentRoleIndex <= -1
+ currentRoleIndex === data.track.length - 1 || currentRoleIndex <= -1
) || !allowed[currentRoleIndex]),
])
])})
@@ -131,31 +128,31 @@
return
}
component.deferUpdate()
- if (component.customId == "conflict") {
- let rolesToRemove = selected.filter(role => role != component.values[0])
+ if (component.customId === "conflict") {
+ let rolesToRemove = selected.filter(role => role !== component.values[0])
await member.roles.remove(rolesToRemove)
- } else if (component.customId == "promote") {
+ } else if (component.customId === "promote") {
if (
- currentRoleIndex == -1 ? allowed[data.track.length - 1] :
+ currentRoleIndex === -1 ? allowed[data.track.length - 1] :
allowed[currentRoleIndex - 1] && allowed[currentRoleIndex]
) {
- if (currentRoleIndex == -1) {
+ if (currentRoleIndex === -1) {
await member.roles.add(data.track[data.track.length - 1])
} else if (currentRoleIndex < data.track.length) {
if (!data.retainPrevious) await member.roles.remove(data.track[currentRoleIndex])
await member.roles.add(data.track[currentRoleIndex - 1])
}
}
- } else if (component.customId == "demote") {
+ } else if (component.customId === "demote") {
if(allowed[currentRoleIndex]) {
- if (currentRoleIndex == data.track.length - 1) {
+ if (currentRoleIndex === data.track.length - 1) {
if (data.nullable) await member.roles.remove(data.track[currentRoleIndex])
} else if (currentRoleIndex > -1) {
await member.roles.remove(data.track[currentRoleIndex])
await member.roles.add(data.track[currentRoleIndex + 1])
}
}
- } else if (component.customId == "select") {
+ } else if (component.customId === "select") {
track = component.values[0]
}
}
@@ -166,7 +163,7 @@
if (tracks.length === 0) throw "This server does not have any tracks"
let member = (interaction.member as GuildMember)
// Allow the owner to promote anyone
- if (member.id == interaction.guild.ownerId) return true
+ if (member.id === interaction.guild.ownerId) return true
// Check if the user can manage any of the tracks
let managed = false
tracks.forEach(element => {
@@ -174,7 +171,7 @@
if (element.track.manageableBy.some(role => member.roles.cache.has(role))) managed = true
});
// Check if the user has manage_roles permission
- if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+ if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
// Allow track
return true;
}