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/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;