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/Unfinished/all.ts b/src/Unfinished/all.ts
index 05eb603..5c482f1 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../utils/defaultEmbeds.js';
import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
@@ -78,12 +79,7 @@
}
const callback = async (interaction: CommandInteraction) => {
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Role all")
- .setDescription("Loading...")
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], ephemeral: true, fetchReply: true})
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
let filters: Filter[] = [
filterList.member.has.role("959901346000154674"),
filterList.member.nickname.startsWith("Pinea"),
@@ -112,7 +108,7 @@
.setDescription((all ? "All of the following must be true:" : "Any of the following must be true") + "\n" +
filters.map((f) => {
count ++;
- return (count == 1 ? getEmojiByName("ICONS.FILTER") : (all ? "**and** " : "**or** ")) +
+ return (count === 1 ? getEmojiByName("ICONS.FILTER") : (all ? "**and** " : "**or** ")) +
(f.inverted ? "**not** " : "") + `${f.name}`
}).join("\n") + "\n\n" + `This will affect ${addPlural(affected.length, "member")}`)
.setEmoji("GUILD.ROLES.CREATE")
@@ -144,11 +140,11 @@
const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
- 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/categorisationTest.ts b/src/Unfinished/categorisationTest.ts
similarity index 92%
rename from src/commands/categorisationTest.ts
rename to src/Unfinished/categorisationTest.ts
index b052783..c75d1bb 100644
--- a/src/commands/categorisationTest.ts
+++ b/src/Unfinished/categorisationTest.ts
@@ -1,23 +1,20 @@
+import { LoadingEmbed } from '../utils/defaultEmbeds.js';
import { CommandInteraction, GuildChannel, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
-import { SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
+import { 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
+const command = new SlashCommandBuilder()
.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});
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
let predicted = {}
let types = {
general: ["general", "muted", "main", "topic", "discuss"],
diff --git a/src/actions/createModActionTicket.ts b/src/actions/createModActionTicket.ts
index 40f99b9..72ba011 100644
--- a/src/actions/createModActionTicket.ts
+++ b/src/actions/createModActionTicket.ts
@@ -16,7 +16,7 @@
deny: ["VIEW_CHANNEL"],
type: "role"
})
- if (config.tickets.supportRole != null) {
+ if (config.tickets.supportRole !== null) {
overwrites.push({
id: guild.roles.cache.get(config.tickets.supportRole),
allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
@@ -40,10 +40,10 @@
try {
await c.send(
{
- content: (`<@${member.id}>` + (config.tickets.supportRole != null ? ` • <@&${config.tickets.supportRole}>` : "")),
+ content: (`<@${member.id}>` + (config.tickets.supportRole !== null ? ` • <@&${config.tickets.supportRole}>` : "")),
allowedMentions: {
users: [member.id],
- roles: (config.tickets.supportRole != null ? [config.tickets.supportRole] : [])
+ roles: (config.tickets.supportRole !== null ? [config.tickets.supportRole] : [])
}
}
)
@@ -51,7 +51,7 @@
.setTitle("New Ticket")
.setDescription(
`Ticket created by a Moderator\n` +
- `**Support type:** Appeal submission\n` + (reason != null ? `**Reason:**\n> ${reason}\n` : "") +
+ `**Support type:** Appeal submission\n` + (reason !== null ? `**Reason:**\n> ${reason}\n` : "") +
`**Ticket ID:** \`${c.id}\`\n` +
`Type \`/ticket close\` to close this ticket.`,
)
diff --git a/src/actions/roleMenu.ts b/src/actions/roleMenu.ts
index a4397a3..7432a3a 100644
--- a/src/actions/roleMenu.ts
+++ b/src/actions/roleMenu.ts
@@ -3,6 +3,7 @@
import { MessageActionRow, MessageSelectMenu } from 'discord.js';
import getEmojiByName from "../utils/getEmojiByName.js";
import client from "../utils/client.js";
+import { LoadingEmbed } from "../utils/defaultEmbeds.js";
export async function callback(interaction) {
let config = await client.database.guilds.read(interaction.guild.id);
@@ -18,12 +19,7 @@
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
], ephemeral: true})
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Roles")
- .setDescription("Loading...")
- .setStatus("Success")
- .setEmoji("NUCLEUS.LOADING")
- ], ephemeral: true})
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
let m;
if (config.roleMenu.allowWebUI) {
let code = ""
@@ -54,7 +50,7 @@
let up = true
try {
let status = await fetch(client.config.baseUrl).then(res => res.status);
- if (status != 200) up = false
+ if (status !== 200) up = false
} catch { up = false }
m = await interaction.editReply({
embeds: [new EmojiEmbed()
@@ -88,7 +84,7 @@
.setTitle("Roles")
.setEmoji("GUILD.GREEN")
.setDescription(`**${object.name}**` + (object.description ? `\n${object.description}` : ``) +
- `\n\nSelect ${object.min}` + (object.min != object.max ? ` to ${object.max}` : ``) + ` role${object.max == 1 ? '' : 's'} to add.`)
+ `\n\nSelect ${object.min}` + (object.min !== object.max ? ` to ${object.max}` : ``) + ` role${object.max === 1 ? '' : 's'} to add.`)
.setStatus("Success")
.setFooter({text: `Step ${i + 1}/${config.roleMenu.options.length}`})
],
@@ -99,7 +95,7 @@
.setStyle("DANGER")
.setCustomId("cancel")
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- ].concat(object.min == 0 ? [
+ ].concat(object.min === 0 ? [
new MessageButton()
.setLabel("Skip")
.setStyle("SECONDARY")
@@ -121,9 +117,9 @@
return
}
component.deferUpdate()
- if (component.customId == "rolemenu") {
+ if (component.customId === "rolemenu") {
rolesToAdd = rolesToAdd.concat(component.values)
- } else if (component.customId == "cancel") {
+ } else if (component.customId === "cancel") {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Roles")
.setDescription("Cancelled. No changes were made.")
diff --git a/src/actions/tickets/create.ts b/src/actions/tickets/create.ts
index e21aa3e..722eb3f 100644
--- a/src/actions/tickets/create.ts
+++ b/src/actions/tickets/create.ts
@@ -24,7 +24,7 @@
let category = interaction.guild.channels.cache.get(config.tickets.category) as Discord.CategoryChannel;
let count = 0;
category.children.forEach(element => {
- if (!(element.type == "GUILD_TEXT")) return;
+ if (!(element.type === "GUILD_TEXT")) return;
if ((element as Discord.TextChannel).topic.includes(`${interaction.member.user.id}`)) {
if ((element as Discord.TextChannel).topic.endsWith("Active")) {
count++;
@@ -84,13 +84,13 @@
if (custom) {
return new MessageButton()
.setLabel(type)
- .setStyle(chosenType == type ? "SUCCESS" : "SECONDARY")
+ .setStyle(chosenType === type ? "SUCCESS" : "SECONDARY")
.setCustomId(type)
.setDisabled(true)
} else {
return new MessageButton()
.setLabel(capitalize(type))
- .setStyle(chosenType == type ? "SUCCESS" : "SECONDARY")
+ .setStyle(chosenType === type ? "SUCCESS" : "SECONDARY")
.setCustomId(type)
.setEmoji(getEmojiByName(("TICKETS." + type.toString().toUpperCase()), "id"))
.setDisabled(true)
@@ -122,7 +122,7 @@
deny: ["VIEW_CHANNEL"],
type: "role"
})
- if (config.tickets.supportRole != null) {
+ if (config.tickets.supportRole !== null) {
overwrites.push({
id: interaction.guild.roles.cache.get(config.tickets.supportRole),
allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
@@ -151,10 +151,10 @@
try {
await c.send(
{
- content: (`<@${interaction.member.user.id}>` + (config.tickets.supportRole != null ? ` • <@&${config.tickets.supportRole}>` : "")),
+ content: (`<@${interaction.member.user.id}>` + (config.tickets.supportRole !== null ? ` • <@&${config.tickets.supportRole}>` : "")),
allowedMentions: {
users: [(interaction.member as Discord.GuildMember).id],
- roles: (config.tickets.supportRole != null ? [config.tickets.supportRole] : [])
+ roles: (config.tickets.supportRole !== null ? [config.tickets.supportRole] : [])
}
}
)
@@ -165,7 +165,7 @@
.setTitle("New Ticket")
.setDescription(
`Ticket created by <@${interaction.member.user.id}>\n` +
- `**Support type:** ${chosenType != null ? (emoji) + " " + capitalize(chosenType) : "General"}\n` +
+ `**Support type:** ${chosenType !== null ? (emoji) + " " + capitalize(chosenType) : "General"}\n` +
`**Ticket ID:** \`${c.id}\`\n${content}\n` +
`Type \`/ticket close\` to close this ticket.`,
)
diff --git a/src/actions/tickets/delete.ts b/src/actions/tickets/delete.ts
index c14cf0c..d86396a 100644
--- a/src/actions/tickets/delete.ts
+++ b/src/actions/tickets/delete.ts
@@ -10,7 +10,7 @@
let thread = false; let threadChannel
if (interaction.channel instanceof Discord.ThreadChannel) thread = true; threadChannel = interaction.channel as Discord.ThreadChannel
let channel = (interaction.channel as Discord.TextChannel)
- if (!channel.parent || config.tickets.category != channel.parent.id || (thread ? (threadChannel.parent.parent.id != config.tickets.category) : false)) {
+ if (!channel.parent || config.tickets.category !== channel.parent.id || (thread ? (threadChannel.parent.parent.id !== config.tickets.category) : false)) {
return interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Deleting Ticket...")
.setDescription("This ticket is not in your tickets category, so cannot be deleted. You cannot run close in a thread.")
@@ -19,7 +19,7 @@
], ephemeral: true});
}
let status = channel.topic.split(" ")[1];
- if (status == "Archived") {
+ if (status === "Archived") {
await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Delete Ticket")
.setDescription("Your ticket is being deleted...")
@@ -47,7 +47,7 @@
log(data);
interaction.channel.delete();
return;
- } else if (status == "Active") {
+ } else if (status === "Active") {
await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Close Ticket")
.setDescription("Your ticket is being closed...")
@@ -66,7 +66,7 @@
type: "role"
}
] as Discord.OverwriteResolvable[];
- if (config.tickets.supportRole != null) {
+ if (config.tickets.supportRole !== null) {
overwrites.push({
id: interaction.guild.roles.cache.get(config.tickets.supportRole),
allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
@@ -127,8 +127,8 @@
let ticketChannels = tickets.children;
let deleted = 0
ticketChannels.forEach(element => {
- if (element.type != "GUILD_TEXT") return;
- if (element.topic.split(" ")[0] == member) {
+ if (element.type !== "GUILD_TEXT") return;
+ if (element.topic.split(" ")[0] === member) {
try { element.delete(); } catch {}
deleted++
}
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;
}
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index 2d48255..fa66755 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -4,8 +4,8 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger
let auditLog = await getAuditLog(channel.guild, 'CHANNEL_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
+ if (audit.executor.id === client.user.id) return;
let emoji;
let readableType;
let displayName;
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index ffe3eae..25c9ce5 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -7,8 +7,8 @@
const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger
let auditLog = await getAuditLog(channel.guild, 'CHANNEL_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
+ if (audit.executor.id === client.user.id) return;
let emoji;
let readableType;
@@ -49,7 +49,7 @@
deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
deletedBy: entry(audit.executor.id, renderUser(audit.executor))
}
- if (channel.topic != null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
+ if (channel.topic !== null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
else delete list.topic;
if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
else delete list.nsfw;
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 50a3de1..568af0b 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -8,11 +8,11 @@
let config = await client.memory.readGuildInfo(nc.guild.id);
const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger
- if (nc.parent && (nc.parent.id == config.tickets.category)) return
+ if (nc.parent && (nc.parent.id === config.tickets.category)) return
let auditLog = await getAuditLog(nc.guild, 'CHANNEL_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == nc.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === nc.id).first();
+ if (audit.executor.id === client.user.id) return;
let emoji:string;
let readableType:string;
@@ -23,8 +23,8 @@
edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
}
- if (oc.name != nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
- if (oc.position != nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
+ if (oc.name !== nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
+ if (oc.position !== nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
switch (nc.type) {
case 'GUILD_TEXT': {
@@ -43,9 +43,9 @@
let nsfw = ["", ""]
nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
- if (oc.topic != nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
- if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
- if (oc.rateLimitPerUser != nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
+ if (oc.topic !== nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
+ if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
+ if (oc.rateLimitPerUser !== nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
[oc.rateLimitPerUser, nc.rateLimitPerUser],
`${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
);
@@ -65,16 +65,16 @@
if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
} else { newTopic = "None"; }
- if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
+ if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
break;
}
case 'GUILD_VOICE': {
emoji = "CHANNEL.VOICE.EDIT";
readableType = "Voice";
displayName = "Voice Channel"
- if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
- if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
- if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
+ if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+ if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+ if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
[oc.rtcRegion, nc.rtcRegion],
`${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
);
@@ -93,9 +93,9 @@
if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
} else { newTopic = "None"; }
- if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
- if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
- if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
+ if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+ if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+ if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
[oc.rtcRegion, nc.rtcRegion],
`${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
);
@@ -114,7 +114,7 @@
}
}
let t = oc.type.split("_")[1];
- if (oc.type != nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
+ if (oc.type !== nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
if (!(Object.values(changes).length - 4)) return
let data = {
meta:{
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 25d1b62..9e91012 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -4,8 +4,8 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
let auditLog = await getAuditLog(emoji.guild, 'EMOJI_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'emojiCreate',
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index 2dcb685..0c39542 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -4,8 +4,8 @@
try{
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
let auditLog = await getAuditLog(emoji.guild, 'EMOJI_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'emojiDelete',
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index 79fb171..a90de9a 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -6,10 +6,10 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
- if (oe.name == ne.name) return
+ if (oe.name === ne.name) return
let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
let audit = auditLog.entries.first();
- if (audit.executor.id == client.user.id) return;
+ if (audit.executor.id === client.user.id) return;
let changes = {
emojiId: entry(ne.id, `\`${ne.id}\``),
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index d095049..06163a9 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -9,8 +9,8 @@
try {
const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_ADD')
- let audit = auditLog.entries.filter(entry => entry.target.id == ban.user.id).first();
- if (audit.executor.id == client.user.id) return
+ let audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+ if (audit.executor.id === client.user.id) return
try { await client.database.history.create("ban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
let data = {
meta: {
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 4d6d1f8..2a1b6de 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -10,8 +10,8 @@
try {
const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_REMOVE')
- let audit = auditLog.entries.filter(entry => entry.target.id == ban.user.id).first();
- if (audit.executor.id == client.user.id) return
+ let audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+ if (audit.executor.id === client.user.id) return
try { await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
let data = {
meta: {
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index e68aee4..d555647 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -4,9 +4,9 @@
try {
const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger
let auditLog = await getAuditLog(after.guild, 'MEMBER_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first();
- if (audit.executor.id == client.user.id) return;
- if (before.nickname != after.nickname) {
+ let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+ if (audit.executor.id === client.user.id) return;
+ if (before.nickname !== after.nickname) {
try { await client.database.history.create(
"nickname", after.guild.id, after.user, audit.executor,
null, before.nickname || before.user.username, after.nickname || after.user.username) } catch {}
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index ee02b66..e27975b 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -1,11 +1,14 @@
+import { callback as statsChannelUpdate } from '../reflex/statsChannelUpdate.js';
+
export const event = 'guildUpdate'
export async function callback(client, before, after) {
+ try { await statsChannelUpdate(client, after.me); } catch(e) { console.log(e)}
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger
let auditLog = await getAuditLog(after, 'GUILD_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+ if (audit.executor.id === client.user.id) return;
let list = {}
const verificationLevels = {
@@ -27,14 +30,14 @@
ELEVATED: 'Enabled'
}
- if (before.name != after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
- if (before.icon != after.icon) list["icon"] = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
- if (before.splash != after.splash) list["splash"] = entry([before.splash, after.splash], `[Before](${before.splashURL()}) -> [After](${after.splashURL()})`);
- if (before.banner != after.banner) list["banner"] = entry([before.banner, after.banner], `[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`);
- if (before.owner != after.owner) list["owner"] = entry([before.owner, after.owner], `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`);
- if (before.verificationLevel != after.verificationLevel) list["verificationLevel"] = entry([verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]], `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`);
- if (before.explicitContentFilter != after.explicitContentFilter) list["explicitContentFilter"] = entry([explicitContentFilterLevels[before.explicitContentFilter], explicitContentFilterLevels[after.explicitContentFilter]], `${explicitContentFilterLevels[before.explicitContentFilter]} -> ${explicitContentFilterLevels[after.explicitContentFilter]}`);
- if (before.mfaLevel != after.mfaLevel) list["2 factor authentication"] = entry([MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]], `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`);
+ if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+ if (before.icon !== after.icon) list["icon"] = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
+ if (before.splash !== after.splash) list["splash"] = entry([before.splash, after.splash], `[Before](${before.splashURL()}) -> [After](${after.splashURL()})`);
+ if (before.banner !== after.banner) list["banner"] = entry([before.banner, after.banner], `[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`);
+ if (before.owner !== after.owner) list["owner"] = entry([before.owner, after.owner], `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`);
+ if (before.verificationLevel !== after.verificationLevel) list["verificationLevel"] = entry([verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]], `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`);
+ if (before.explicitContentFilter !== after.explicitContentFilter) list["explicitContentFilter"] = entry([explicitContentFilterLevels[before.explicitContentFilter], explicitContentFilterLevels[after.explicitContentFilter]], `${explicitContentFilterLevels[before.explicitContentFilter]} -> ${explicitContentFilterLevels[after.explicitContentFilter]}`);
+ if (before.mfaLevel !== after.mfaLevel) list["2 factor authentication"] = entry([MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]], `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`);
if (!(Object.keys(list).length)) return;
list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index 5081dd1..5d47bf8 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -5,8 +5,8 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
let auditLog = await getAuditLog(invite.guild, 'INVITE_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == invite.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'inviteCreate',
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index b6ddd22..acfc9dd 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -5,8 +5,8 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
let auditLog = await getAuditLog(invite.guild, 'INVITE_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id == invite.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'inviteDelete',
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 122e01a..5dff86f 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,4 +1,3 @@
-import humanizeDuration from 'humanize-duration';
import { purgeByUser } from '../actions/tickets/delete.js';
import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
@@ -6,10 +5,11 @@
export async function callback(client, member) {
try { purgeByUser(member.id, member.guild); } catch {}
+ try { await statsChannelRemove(client, member); } catch {}
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
let auditLog = await getAuditLog(member.guild, 'MEMBER_KICK');
- let audit = auditLog.entries.filter(entry => entry.target.id == member.id).first();
+ let audit = auditLog.entries.filter(entry => entry.target.id === member.id).first();
let type = "leave"
if (audit) {
if (audit.executor.id === client.user.id) return
@@ -18,7 +18,7 @@
}
}
let data
- if (type == "kick") {
+ if (type === "kick") {
try { await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason) } catch {}
data = {
meta: {
@@ -36,7 +36,6 @@
kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
kickedBy: entry(audit.executor.id, renderUser(audit.executor)),
reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
- timeInServer: entry(new Date().getTime() - member.joinedAt, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })),
accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
serverMemberCount: member.guild.memberCount,
},
@@ -60,7 +59,6 @@
name: entry(member.id, renderUser(member.user)),
joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- timeInServer: entry(new Date().getTime() - member.joinedTimestamp, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })),
accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
serverMemberCount: member.guild.memberCount,
},
@@ -71,5 +69,4 @@
}
log(data);
} catch (e) { console.log(e) }
- try { await statsChannelRemove(client, member); } catch {}
}
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index dce1959..cbb1fa2 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -1,14 +1,17 @@
import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from '../reflex/scanners.js'
import logAttachment from '../premium/attachmentLogs.js'
import createLogException from '../utils/createLogException.js'
-import getEmojiByName from '../utils/getEmojiByName.js'
+import getEmojiByName from '../utils/getEmojiByName.js';
+import client from '../utils/client.js';
+import {callback as a} from '../reflex/statsChannelUpdate.js'
export const event = 'messageCreate'
-export async function callback(client, message) {
+export async function callback(_, message) {
if(!message) return;
if (message.author.bot) return
if (message.channel.type === 'dm') return
+ try { await a(client, await message.guild.members.fetch(message.author.id)); } catch(e) { console.log(e)}
const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger
@@ -66,7 +69,7 @@
for (let element of fileNames.files) {
if(!message) return;
let url = element.url ? element.url : element.local
- if (url != undefined) {
+ if (url !== undefined) {
if(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(url)) {
if (config.filters.images.NSFW && !message.channel.nsfw) {
if (await NSFWCheck(url)) {
@@ -94,30 +97,28 @@
}
if (config.filters.wordFilter.enabled) {
let text = await TestImage(url)
- if (config.filters.wordFilter.enabled) {
- let check = TestString(text, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
- if(check !== null) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
- meta: {
- type: 'messageDelete',
- displayName: 'Message Deleted',
- calculateType: 'autoModeratorDeleted',
- color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
- timestamp: new Date().getTime()
- },
- separate: {
- start: filter + " Image contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
- },
- list: list,
- hidden: {
- guild: message.channel.guild.id
- }
+ let check = TestString(text, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
+ if(check !== null) {
+ createLogException(message.guild.id, message.channel.id, message.id)
+ await message.delete()
+ let data = {
+ meta: {
+ type: 'messageDelete',
+ displayName: 'Message Deleted',
+ calculateType: 'autoModeratorDeleted',
+ color: NucleusColors.red,
+ emoji: 'MESSAGE.DELETE',
+ timestamp: new Date().getTime()
+ },
+ separate: {
+ start: filter + " Image contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+ },
+ list: list,
+ hidden: {
+ guild: message.channel.guild.id
}
- return log(data);
}
+ return log(data);
}
}
if (config.filters.images.size) {
@@ -199,6 +200,7 @@
}
return log(data);
}
+
if (config.filters.wordFilter.enabled) {
let check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
if(check !== null) {
@@ -225,78 +227,73 @@
}
}
- if (!config.filters.pings.allowed.users.includes(message.author.id) ||
- !config.filters.pings.allowed.channels.includes(message.channel.id) ||
- !message.author.roles.cache.some(role => config.filters.pings.allowed.roles.includes(role.id))
- ) {
- if (config.filters.pings.everyone && message.mentions.everyone) {
- let data = {
- meta: {
- type: 'everyonePing',
- displayName: 'Everyone Pinged',
- calculateType: 'messageMassPing',
- color: NucleusColors.yellow,
- emoji: 'MESSAGE.PING.EVERYONE',
- timestamp: new Date().getTime()
- },
- separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
- },
- list: list,
- hidden: {
- guild: message.channel.guild.id
- }
+ if (config.filters.pings.everyone && message.mentions.everyone) {
+ let data = {
+ meta: {
+ type: 'everyonePing',
+ displayName: 'Everyone Pinged',
+ calculateType: 'messageMassPing',
+ color: NucleusColors.yellow,
+ emoji: 'MESSAGE.PING.EVERYONE',
+ timestamp: new Date().getTime()
+ },
+ separate: {
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+ },
+ list: list,
+ hidden: {
+ guild: message.channel.guild.id
}
- return log(data);
}
- if (config.filters.pings.roles) {
- for(let role of message.mentions.roles) {
- if(!message) return;
- if (!config.filters.pings.allowed.roles.includes(role.id)) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
- meta: {
- type: 'rolePing',
- displayName: 'Role Pinged',
- calculateType: 'messageMassPing',
- color: NucleusColors.yellow,
- emoji: 'MESSAGE.PING.ROLE',
- timestamp: new Date().getTime()
- },
- separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
- },
- list: list,
- hidden: {
- guild: message.channel.guild.id
- }
+ return log(data);
+ }
+ if (config.filters.pings.roles) {
+ for(let role of message.mentions.roles) {
+ if(!message) return;
+ if (!config.filters.pings.allowed.roles.includes(role.id)) {
+ createLogException(message.guild.id, message.channel.id, message.id)
+ await message.delete()
+ let data = {
+ meta: {
+ type: 'rolePing',
+ displayName: 'Role Pinged',
+ calculateType: 'messageMassPing',
+ color: NucleusColors.yellow,
+ emoji: 'MESSAGE.PING.ROLE',
+ timestamp: new Date().getTime()
+ },
+ separate: {
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+ },
+ list: list,
+ hidden: {
+ guild: message.channel.guild.id
}
- return log(data);
}
+ return log(data);
}
}
- if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
- meta: {
- type: 'massPing',
- displayName: `Mass Ping`,
- calculateType: 'messageMassPing',
- color: NucleusColors.yellow,
- emoji: 'MESSAGE.PING.MASS',
- timestamp: new Date().getTime()
- },
- separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
- },
- list: list,
- hidden: {
- guild: message.channel.guild.id
- }
+ }
+ if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
+ createLogException(message.guild.id, message.channel.id, message.id)
+ await message.delete()
+ let data = {
+ meta: {
+ type: 'massPing',
+ displayName: `Mass Ping`,
+ calculateType: 'messageMassPing',
+ color: NucleusColors.yellow,
+ emoji: 'MESSAGE.PING.MASS',
+ timestamp: new Date().getTime()
+ },
+ separate: {
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+ },
+ list: list,
+ hidden: {
+ guild: message.channel.guild.id
}
- return log(data);
}
+ return log(data);
}
}
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 3c23739..b139297 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -2,11 +2,11 @@
export async function callback(client, message) {
try {
- if (message.author.id == client.user.id) return;
+ if (message.author.id === client.user.id) return;
if (client.noLog.includes(`${message.guild.id}/${message.channel.id}/${message.id}`)) return;
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger
let auditLog = await getAuditLog(message.guild, 'MEMBER_BAN_ADD')
- let audit = auditLog.entries.filter(entry => entry.target.id == message.author.id).first();
+ let audit = auditLog.entries.filter(entry => entry.target.id === message.author.id).first();
if (audit) {
if (audit.createdAt - 100 < new Date().getTime()) return;
}
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index 5e63797..9e0e521 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -2,7 +2,7 @@
export async function callback(client, oldMessage, newMessage) {
try {
- if (newMessage.author.id == client.user.id) return;
+ if (newMessage.author.id === client.user.id) return;
const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger
newMessage.reference = newMessage.reference || {}
let newContent = newMessage.cleanContent.replaceAll("`", "‘")
@@ -10,7 +10,7 @@
let attachmentJump = "";
let config = (await client.database.guilds.read(newMessage.guild.id)).logging.attachments.saved[newMessage.channel.id + newMessage.id];
if (config) { attachmentJump = ` [[View attachments]](${config})` }
- if (newContent == oldContent) {
+ if (newContent === oldContent) {
if (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
let data = {
meta: {
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index 6fded26..2f159ac 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -5,8 +5,8 @@
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
if (role.managed) return;
let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'roleCreate',
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index 6a23d9e..3b43a55 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -7,8 +7,8 @@
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
if (role.managed) return;
let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'roleDelete',
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 7c6ca75..7c03c97 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -8,7 +8,7 @@
let auditLog = await getAuditLog(nr.guild, 'ROLE_UPDATE');
let audit = auditLog.entries.first();
- if (audit.executor.id == client.user.id) return;
+ if (audit.executor.id === client.user.id) return;
let changes = {
roleId: entry(nr.id, `\`${nr.id}\``),
@@ -22,13 +22,13 @@
mentionable[1] = nr.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
hoist[0] = or.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
hoist[1] = nr.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- if (or.name != nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
- if (or.position != nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
- if (or.hoist != nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
- if (or.mentionable != nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
- if (or.hexColor != nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
+ if (or.name !== nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
+ if (or.position !== nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
+ if (or.hoist !== nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
+ if (or.mentionable !== nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
+ if (or.hexColor !== nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
- if (Object.keys(changes).length == 4) return
+ if (Object.keys(changes).length === 4) return
let data = {
meta:{
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index b9511b0..669de32 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -4,8 +4,8 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger
let auditLog = await getAuditLog(emoji.guild, 'STICKER_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'stickerCreate',
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index 7490851..0431bda 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -4,8 +4,8 @@
try{
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger
let auditLog = await getAuditLog(emoji.guild, 'STICKER_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'stickerDelete',
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index 7cb745f..363e072 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -4,10 +4,10 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
- if (oe.name == ne.name) return
+ if (oe.name === ne.name) return
let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
let audit = auditLog.entries.first();
- if (audit.executor.id == client.user.id) return;
+ if (audit.executor.id === client.user.id) return;
let changes = {
stickerId:entry(ne.id, `\`${ne.id}\``),
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index ff69e35..ef7246d 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -5,8 +5,8 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
let auditLog = await getAuditLog(thread.guild, 'THREAD_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == thread.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'channelCreate',
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index 14c5820..9574826 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -5,8 +5,8 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
let auditLog = await getAuditLog(thread.guild, 'THREAD_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == thread.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
+ if (audit.executor.id === client.user.id) return;
let data = {
meta: {
type: 'channelDelete',
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 4e13193..8550ffe 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -5,20 +5,20 @@
try {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger
let auditLog = await getAuditLog(after.guild, 'THREAD_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first();
- if (audit.executor.id == client.user.id) return;
+ let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+ if (audit.executor.id === client.user.id) return;
let list = {
threadId:entry(after.id, `\`${after.id}\``),
thread: entry(after.name, renderChannel(after)),
parentChannel: entry(after.parentId, renderChannel(after.parent)),
}
- if (before.name != after.name) {
+ if (before.name !== after.name) {
list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
}
- if (before.autoArchiveDuration != after.autoArchiveDuration) {
+ if (before.autoArchiveDuration !== after.autoArchiveDuration) {
list["autoArchiveDuration"] = entry([before.autoArchiveDuration, after.autoArchiveDuration], `${humanizeDuration(before.autoArchiveDuration * 60 * 1000, { round: true })} -> ${humanizeDuration(after.autoArchiveDuration * 60 * 1000, { round: true })}`);
}
- if (before.rateLimitPerUser != after.rateLimitPerUser) {
+ if (before.rateLimitPerUser !== after.rateLimitPerUser) {
list["slowmode"] = entry([before.rateLimitPerUser, after.rateLimitPerUser], `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`);
}
if (!(Object.keys(list).length - 3)) return;
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index 66b1cd0..28768b2 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -8,9 +8,9 @@
let auditLogUpdate = getAuditLog(channel.guild, 'WEBHOOK_UPDATE');
let auditLogDelete = getAuditLog(channel.guild, 'WEBHOOK_DELETE');
[auditLogCreate, auditLogUpdate, auditLogDelete] = await Promise.all([auditLogCreate, auditLogUpdate, auditLogDelete]);
- let auditCreate = auditLogCreate.entries.filter(entry => entry.target.channelId == channel.id).first();
- let auditUpdate = auditLogUpdate.entries.filter(entry => entry.target.channelId == channel.id).first();
- let auditDelete = auditLogDelete.entries.filter(entry => entry.target.channelId == channel.id).first();
+ let auditCreate = auditLogCreate.entries.filter(entry => entry.target.channelId === channel.id).first();
+ let auditUpdate = auditLogUpdate.entries.filter(entry => entry.target.channelId === channel.id).first();
+ let auditDelete = auditLogDelete.entries.filter(entry => entry.target.channelId === channel.id).first();
if (!auditCreate && !auditUpdate && !auditDelete) return;
let audit = auditCreate;
let action = "Create";
diff --git a/src/premium/attachmentLogs.ts b/src/premium/attachmentLogs.ts
index e1dfcc0..ed9a4ab 100644
--- a/src/premium/attachmentLogs.ts
+++ b/src/premium/attachmentLogs.ts
@@ -18,7 +18,7 @@
attachments.push({local: await saveAttachment(link), url: link})
}
}
- if (attachments.length == 0) return {files: []}
+ if (attachments.length === 0) return {files: []}
if (client.database.premium.hasPremium(message.guild.id)) {
let channel = (await client.database.guilds.read(message.guild.id)).logging.attachments.channel;
if (!channel) {
diff --git a/src/premium/createTranscript.ts b/src/premium/createTranscript.ts
index 92b268c..55697b9 100644
--- a/src/premium/createTranscript.ts
+++ b/src/premium/createTranscript.ts
@@ -13,7 +13,7 @@
let messages = []
let deleted = 100;
- while (deleted == 100) {
+ while (deleted === 100) {
let fetched;
await (interaction.channel as TextChannel).messages.fetch({limit: 100}).then(async (ms) => {
fetched = await (interaction.channel as TextChannel).bulkDelete(ms, true);
diff --git a/src/reflex/guide.ts b/src/reflex/guide.ts
index 39974e7..517d7f4 100644
--- a/src/reflex/guide.ts
+++ b/src/reflex/guide.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../utils/defaultEmbeds.js';
import { SelectMenuOption } from '@discordjs/builders';
import Discord, { MessageActionRow, MessageButton } from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
@@ -126,23 +127,8 @@
).setTitle("Premium").setDescription("Premium features").setPageId(7),
]
let m;
- if (interaction) {
- m = await interaction.reply({embeds: [
- new EmojiEmbed()
- .setTitle("Welcome")
- .setDescription(`One moment...`)
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], fetchReply: true, ephemeral: true});
- } else {
- m = await c.send({embeds: [
- new EmojiEmbed()
- .setTitle("Welcome")
- .setDescription(`One moment...`)
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], fetchReply: true });
- }
+ if (interaction) { m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true}); }
+ else { m = await c.send({embeds: LoadingEmbed }); }
let page = 0;
let f = async (component) => {
@@ -174,8 +160,7 @@
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),
- new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER")
+ new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1)
])])
if (interaction) {
let em = new Discord.MessageEmbed(pages[page].embed)
@@ -198,56 +183,53 @@
i = await m.awaitMessageComponent({filter: interaction ? () => { return true } : f, 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 {
if (interaction) {
let em = new Discord.MessageEmbed(pages[page].embed)
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message closed");
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
+ em.setFooter({text: "Message closed"})
interaction.editReply({embeds: [em], components: [new MessageActionRow().addComponents([
new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
- ])], fetchReply: true});
+ new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true)
+ ])]});
} else {
m.delete();
}
return;
}
}
- const { NucleusColors } = client.logger
if (interaction) {
let em = new Discord.MessageEmbed(pages[page].embed)
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out").setColor(NucleusColors.Danger);
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({text: "Message timed out"});
await interaction.editReply({
embeds: [em],
components: [new MessageActionRow().addComponents([
new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
+ new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true)
])]
});
} else {
let em = new Discord.MessageEmbed(pages[page].embed)
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out").setColor(NucleusColors.Danger);
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({text: "Message timed out"});
await m.edit({
embeds: [em],
components: [new MessageActionRow().addComponents([
new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
+ new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true)
])]
});
}
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index a1a5974..3b80816 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -84,7 +84,7 @@
}
export async function SizeCheck(element): Promise<boolean> {
- if (element.height == undefined || element.width == undefined) return true
+ if (element.height === undefined || element.width === undefined) return true
if (element.height < 20 || element.width < 20) return false
return true
}
@@ -105,7 +105,7 @@
}
for(let word of soft) {
for(let word2 of string.match(/[a-z]+/gi) || []) {
- if (word2 == word) {
+ if (word2 === word) {
return {word: word, type: "strict"}
}
}
diff --git a/src/reflex/statsChannelUpdate.ts b/src/reflex/statsChannelUpdate.ts
index 7d04c8f..b306ecc 100644
--- a/src/reflex/statsChannelUpdate.ts
+++ b/src/reflex/statsChannelUpdate.ts
@@ -17,15 +17,20 @@
fetchedChannel = await guild.channels.fetch(channel)
} catch (e) { fetchedChannel = null }
if (!fetchedChannel) {
+ let deleted = config.getKey("stats")[channel]
+ console.log(`stats.${channel}`)
+ console.log(guild.id)
+ await client.database.guilds.write(guild.id, null, `stats.${channel}`)
return singleNotify(
"statsChannelDeleted",
guild.id,
- "One or more of your stats channels have been deleted. Please open the settings menu to change this.",
+ "One or more of your stats channels have been deleted. Please use `/settings stats` if you wish to add the channel again.\n" +
+ `The channels name was: ${deleted.name}`,
"Critical"
)
}
try {
- await fetchedChannel.setName(string)
+ await fetchedChannel.setName(string.slice(0, 100))
} catch (e) {
console.error(e)
}
diff --git a/src/reflex/verify.ts b/src/reflex/verify.ts
index 9d90dde..b95cdb7 100644
--- a/src/reflex/verify.ts
+++ b/src/reflex/verify.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../utils/defaultEmbeds.js';
import Discord, { GuildMember } from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import fetch from "node-fetch";
@@ -11,12 +12,7 @@
export default async function(interaction) {
let verify = client.verify
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Loading")
- .setDescription(step(-1))
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], ephemeral: true, fetchReply: true});
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
let config = await client.database.guilds.read(interaction.guild.id);
if ((!config.verify.enabled ) || (!config.verify.role)) return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify")
@@ -40,7 +36,7 @@
]});
try {
let status = await fetch(client.config.baseUrl).then(res => res.status);
- if (status != 200) {
+ if (status !== 200) {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify")
.setDescription(`Our servers appear to be down, please try again later` + step(0))
diff --git a/src/utils/calculate.ts b/src/utils/calculate.ts
index 6b8c058..8badc58 100644
--- a/src/utils/calculate.ts
+++ b/src/utils/calculate.ts
@@ -49,7 +49,7 @@
let permissions = [];
let int = (BigInt("0x" + permissionsHex)).toString(2).split('').reverse();
for (let index in int) {
- if (int[index] == "1" && array.length > index) {
+ if (int[index] === "1" && array.length > index) {
permissions.push(array[index]);
}
}
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index 988fd37..dfdc3fb 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -148,7 +148,7 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id == this.interaction.channel.id, (m) => m.customId == "reason")
+ out = await modalInteractionCollector(m, (m) => m.channel.id === this.interaction.channel.id, (m) => m.customId === "reason")
} catch (e) { return {} }
if (out.fields) { return { newReason: out.fields.getTextInputValue("reason") ?? "" }; }
else { return { newReason: this.reason } }
diff --git a/src/utils/createPageIndicator.ts b/src/utils/createPageIndicator.ts
index 8e18e30..fa203dc 100644
--- a/src/utils/createPageIndicator.ts
+++ b/src/utils/createPageIndicator.ts
@@ -3,13 +3,13 @@
function pageIndicator(amount: number, selected: number, showDetails?: boolean | true) {
let out = "";
- if (amount == 1) {
- out += getEmojiByName("TRACKS.SINGLE." + (selected == 0 ? "ACTIVE" : "INACTIVE"));
+ if (amount === 1) {
+ out += getEmojiByName("TRACKS.SINGLE." + (selected === 0 ? "ACTIVE" : "INACTIVE"));
} else {
for (let i = 0; i < amount; i++) {
out += getEmojiByName("TRACKS.HORIZONTAL." +
- (i == 0 ? "LEFT" : (i == amount - 1 ? "RIGHT" : "MIDDLE")) + "." +
- (i == selected ? "ACTIVE" : "INACTIVE")
+ (i === 0 ? "LEFT" : (i === amount - 1 ? "RIGHT" : "MIDDLE")) + "." +
+ (i === selected ? "ACTIVE" : "INACTIVE")
);
}
}
diff --git a/src/utils/database.ts b/src/utils/database.ts
index d24c7bf..2f04198 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -40,14 +40,16 @@
return new Proxy(structuredClone(this.defaultData), Entry(entry)) as unknown as GuildConfig
}
- async write(guild: string, set: object = {}, unset: string[] = []) {
+ async write(guild: string, set: object | null, unset: string[] | string = []) {
let uo = {}
+ if (!Array.isArray(unset)) unset = [unset]
for (let key of unset) {
uo[key] = null;
}
- let out = {}
+ let out = {$set: {}, $unset: {}}
if (set) out["$set"] = set;
if (unset.length) out["$unset"] = uo;
+ console.log(out)
await this.guilds.updateOne({ id: guild }, out, { upsert: true });
}
@@ -79,6 +81,10 @@
}, { upsert: true });
}
}
+
+ async delete(guild: string) {
+ await this.guilds.deleteOne({ id: guild });
+ }
}
@@ -116,6 +122,10 @@
}).toArray()) as HistorySchema[];
return entry;
}
+
+ async delete(guild: string) {
+ await this.histories.deleteMany({ guild: guild });
+ }
}
export class ModNotes {
@@ -147,7 +157,7 @@
async hasPremium(guild: string) {
let entry = await this.premium.findOne({ appliesTo: { $in: [guild] } });
- return entry != null;
+ return entry !== null;
}
}
diff --git a/src/utils/defaultEmbeds.ts b/src/utils/defaultEmbeds.ts
new file mode 100644
index 0000000..0f226da
--- /dev/null
+++ b/src/utils/defaultEmbeds.ts
@@ -0,0 +1,8 @@
+import EmojiEmbed from "./generateEmojiEmbed.js"
+
+export const LoadingEmbed = [new EmojiEmbed()
+ .setTitle("Loading")
+ .setDescription("One moment...")
+ .setStatus("Danger")
+ .setEmoji("NUCLEUS.LOADING")]
+
diff --git a/src/utils/log.ts b/src/utils/log.ts
index 987e256..22da837 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -11,7 +11,7 @@
export class Logger {
renderUser(user: Discord.User | string) {
- if (typeof user == 'string') return `${user} [<@${user}>]`;
+ if (typeof user === 'string') return `${user} [<@${user}>]`;
return `${user.username} [<@${user.id}>]`;
}
renderTime(t: number) {
@@ -55,7 +55,7 @@
async log(log: any): Promise<void> {
let config = await client.database.guilds.read(log.hidden.guild);
if (!config.logging.logs.enabled) return;
- if (!(log.meta.calculateType == true)) {
+ if (!(log.meta.calculateType === true)) {
if(!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType)) return console.log('Not logging this type of event');
}
if (config.logging.logs.channel) {
@@ -84,20 +84,8 @@
channel.send({embeds: [embed]});
}
}
- saveLog(log);
}
}
export default {}
-
-async function saveLog(log: any): Promise<void> {
-}
-
-export function readLogs(guild: string) {
-
-}
-
-export function readSpecificLog(guild: string, id: number) {
-
-}
diff --git a/src/utils/singleNotify.ts b/src/utils/singleNotify.ts
index 051ec4d..f29d775 100644
--- a/src/utils/singleNotify.ts
+++ b/src/utils/singleNotify.ts
@@ -7,11 +7,13 @@
"Info": "Success"
}
-export default async function(type: string, guild: string, message: string, severity: string) {
+export default async function(type: string, guild: string, message: string | true, severity?: string) {
let data = await client.database.guilds.read(guild);
+ if (message === true) {
+ return await client.database.guilds.write(guild, {[`singleEventNotifications.${type}`]: false});
+ }
if (data.singleEventNotifications[type]) return;
- data.singleEventNotifications[type] = true;
- client.database.guilds.write(guild, data);
+ await client.database.guilds.write(guild, {[`singleEventNotifications.${type}`]: true});
try {
let channel = await client.channels.fetch(data.logging.staff.channel);
if (!channel) return;