styling fixes and some typing
diff --git a/src/utils/calculate.ts b/src/utils/calculate.ts
index 6bbbe2e..98d82c3 100644
--- a/src/utils/calculate.ts
+++ b/src/utils/calculate.ts
@@ -23,7 +23,7 @@
const tickets = ["support", "report", "question", "issue", "suggestion", "other"];
-const toHexInteger = (permissions, array?) => {
+const toHexInteger = (permissions: string[], array?: string[]) => {
if (!array) {
array = logs;
}
@@ -35,7 +35,7 @@
return int.toString(16);
};
-const toHexArray = (permissionsHex, array?) => {
+const toHexArray = (permissionsHex: string, array?: string[]) => {
if (!array) {
array = logs;
}
@@ -45,7 +45,7 @@
.split("")
.reverse();
for (const index in int) {
- if (int[index] === "1" && array.length > index) {
+ if (int[index] === "1" && array.length > parseInt(index)) {
permissions.push(array[index]);
}
}
diff --git a/src/utils/client.ts b/src/utils/client.ts
index 0ce61f1..1795cfa 100644
--- a/src/utils/client.ts
+++ b/src/utils/client.ts
@@ -1,3 +1,4 @@
+// @ts-expect-error
import { HaikuClient } from "jshaiku";
import { Intents } from "discord.js";
import config from "../config/main.json" assert { type: "json" };
diff --git a/src/utils/convertCurlyBracketString.ts b/src/utils/convertCurlyBracketString.ts
index 53c3267..5d2c23d 100644
--- a/src/utils/convertCurlyBracketString.ts
+++ b/src/utils/convertCurlyBracketString.ts
@@ -1,6 +1,14 @@
-async function convertCurlyBracketString(str, memberID, memberName, serverName, members): Promise<string> {
+import type { GuildMember, GuildMemberManager } from "discord.js";
+
+async function convertCurlyBracketString(
+ str: string,
+ memberID: string,
+ memberName: string,
+ serverName: string,
+ members: GuildMemberManager
+): Promise<string> {
const memberCount = (await members.fetch()).size;
- const bots = (await members.fetch()).filter((m) => m.user.bot).size;
+ const bots = (await members.fetch()).filter((m: GuildMember) => m.user.bot).size;
str = str
.replace("{member:mention}", memberID ? `<@${memberID}>` : "{member:mention}")
.replace("{member:name}", memberName ? `${memberName}` : "{member:name}")
diff --git a/src/utils/createLogException.ts b/src/utils/createLogException.ts
index 7a6c492..329f422 100644
--- a/src/utils/createLogException.ts
+++ b/src/utils/createLogException.ts
@@ -3,7 +3,7 @@
export default function (guild: string, channel: string, message: string) {
client.noLog.push(`${guild}/${channel}/${message}`);
setTimeout(() => {
- client.noLog = client.noLog.filter((i) => {
+ client.noLog = client.noLog.filter((i: string) => {
return i !== `${guild}/${channel}/${message}`;
});
}, 500);
diff --git a/src/utils/database.ts b/src/utils/database.ts
index 04c9e24..cda63d6 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -32,7 +32,6 @@
constructor() {
this.guilds = database.collection<GuildConfig>("guilds");
this.defaultData = null;
- return this;
}
async setup() {
@@ -122,11 +121,9 @@
export class History {
histories: Collection<HistorySchema>;
- defaultData: GuildConfig;
- async setup() {
+ constructor() {
this.histories = database.collection<HistorySchema>("history");
- return this;
}
async create(
@@ -135,20 +132,20 @@
user: Discord.User,
moderator: Discord.User | null,
reason: string | null,
- before?: null,
- after?: null,
- amount?: null
+ before?: string | null,
+ after?: string | null,
+ amount?: string | null
) {
await this.histories.insertOne({
type: type,
guild: guild,
user: user.id,
- moderator: moderator.id,
+ moderator: moderator ? moderator.id : null,
reason: reason,
occurredAt: new Date(),
- before: before,
- after: after,
- amount: amount
+ before: before ?? null,
+ after: after ?? null,
+ amount: amount ?? null
});
}
@@ -173,11 +170,9 @@
export class ModNotes {
modNotes: Collection<ModNoteSchema>;
- defaultData: GuildConfig;
- async setup() {
+ constructor() {
this.modNotes = database.collection<ModNoteSchema>("modNotes");
- return this;
}
async create(guild: string, user: string, note: string | null) {
@@ -193,9 +188,8 @@
export class Premium {
premium: Collection<PremiumSchema>;
- async setup() {
+ constructor() {
this.premium = database.collection<PremiumSchema>("premium");
- return this;
}
async hasPremium(guild: string) {
@@ -342,7 +336,7 @@
guild: string;
user: string;
moderator: string | null;
- reason: string;
+ reason: string | null;
occurredAt: Date;
before: string | null;
after: string | null;
@@ -352,7 +346,7 @@
export interface ModNoteSchema {
guild: string;
user: string;
- note: string;
+ note: string | null;
}
export interface PremiumSchema {
diff --git a/src/utils/generateKeyValueList.ts b/src/utils/generateKeyValueList.ts
index 54b8d99..b2b33e6 100644
--- a/src/utils/generateKeyValueList.ts
+++ b/src/utils/generateKeyValueList.ts
@@ -14,8 +14,8 @@
}
export function toCapitals(s: string) {
- if (s.startsWith(undefined)) return "";
- return s[0].toUpperCase() + s.slice(1).toLowerCase();
+ if (s === "") return "";
+ return s[0]!.toUpperCase() + s.slice(1).toLowerCase();
}
function keyValueList(data: Record<string, string>) {
diff --git a/src/utils/log.ts b/src/utils/log.ts
index cd2f3c7..d831a4b 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -37,7 +37,7 @@
return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
}
- public readonly NucleusColors = {
+ public readonly NucleusColors: Record<string, number> = {
red: 0xf27878,
yellow: 0xf2d478,
green: 0x68d49e