From 4a44d9081de6ec948fe5830772a78edb141d4844 Mon Sep 17 00:00:00 2001 From: TheCodedProf Date: Fri, 21 Apr 2023 22:43:17 -0400 Subject: [PATCH 1/6] moved extended tsconfig into our tsconfig to remove errors --- package.json | 3 +-- tsconfig.json | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 2ff313c..08ca2f2 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "@tensorflow/tfjs": "^3.18.0", "@tensorflow/tfjs-node": "^3.18.0", "@total-typescript/ts-reset": "^0.3.7", - "@tsconfig/node18-strictest-esm": "^1.0.0", "@types/gm": "^1.25.0", "@types/node": "^18.14.6", "@ungap/structured-clone": "^1.0.1", @@ -82,7 +81,7 @@ "prettier": "^2.7.1", "prettier-eslint": "^15.0.1", "tsc-suppress": "^1.0.7", - "typescript": "^4.9.4", + "typescript": "^5.0.0", "yarn-audit-fix": "^9.3.9" } } diff --git a/tsconfig.json b/tsconfig.json index 1df2f7d..2c396b0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,21 @@ { - "extends": "@tsconfig/node18-strictest-esm/tsconfig.json", + "$schema": "https://json.schemastore.org/tsconfig", + "display": "Node 18 + ESM + Strictest", "compilerOptions": { + "lib": [ + "es2022" + ], + "strict": true, + "exactOptionalPropertyTypes": true, + "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "forceConsistentCasingInFileNames": true, + "allowUnusedLabels": false, + "allowUnreachableCode": false, "module": "NodeNext", "target": "es2020", "sourceMap": true, @@ -11,7 +26,8 @@ "resolveJsonModule": true, "moduleResolution": "NodeNext", "skipLibCheck": true, - "noImplicitReturns": false + "noImplicitReturns": false, + "checkJs": true }, "include": ["src/**/*", "src/*", "src/config/main.d.ts", "src/config/main.ts"], "exclude": ["src/Unfinished/**/*", "src/reflex/nsfwjs/**/*"] From 1cb23cf083eecc6bc99f79f288ee559969774c4b Mon Sep 17 00:00:00 2001 From: TheCodedProf Date: Fri, 21 Apr 2023 22:44:59 -0400 Subject: [PATCH 2/6] updated some mod checks to allow for running of commands (warn, about) if mod only has manageMessages --- src/commands/mod/about.ts | 2 +- src/commands/mod/warn.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/mod/about.ts b/src/commands/mod/about.ts index 6f8b74c..d346156 100644 --- a/src/commands/mod/about.ts +++ b/src/commands/mod/about.ts @@ -444,7 +444,7 @@ const callback = async (interaction: CommandInteraction): Promise => { const check = (interaction: CommandInteraction) => { const member = interaction.member as GuildMember; - if (!member.permissions.has("ModerateMembers")) return "You do not have the *Moderate Members* permission"; + if (!member.permissions.has("ManageMessages")) return "You do not have the *Moderate Members* permission"; return true; }; diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts index 0424d48..4d333d2 100644 --- a/src/commands/mod/warn.ts +++ b/src/commands/mod/warn.ts @@ -300,7 +300,7 @@ const callback = async ( const check = (interaction: CommandInteraction | ButtonInteraction, partial: boolean = false, target?: GuildMember) => { if (!interaction.guild) return; const member = interaction.member as GuildMember; - if (!member.permissions.has("ModerateMembers")) return "You do not have the *Moderate Members* permission"; + if (!member.permissions.has("ManageMessages")) return "You do not have the *Moderate Members* permission"; if (partial) return true; let apply: GuildMember; if (interaction.isButton()) { From 122b062cf394b5c258864ee11c9f1c000227358a Mon Sep 17 00:00:00 2001 From: TheCodedProf Date: Fri, 21 Apr 2023 22:45:53 -0400 Subject: [PATCH 3/6] prettier --- src/reflex/scanners.ts | 10 ++-------- tsconfig.json | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts index cdfb56b..0ae285a 100644 --- a/src/reflex/scanners.ts +++ b/src/reflex/scanners.ts @@ -219,7 +219,7 @@ export async function doMemberChecks(member: Discord.GuildMember): Promise // Does the username contain filtered words // Does the nickname contain filtered words let nameCheck; - if(member.nickname) { + if (member.nickname) { nameCheck = TestString(member.nickname ?? "", loose, strict, guildData.filters.wordFilter.enabled); } else { nameCheck = TestString(member.user.username, loose, strict, guildData.filters.wordFilter.enabled); @@ -239,13 +239,7 @@ export async function doMemberChecks(member: Discord.GuildMember): Promise // Does the nickname contain an invite const nicknameInviteCheck = guildData.filters.invite.enabled && /discord\.gg\/[a-zA-Z0-9]+/gi.test(member.nickname ?? ""); - if ( - nameCheck !== null || - avatarCheck || - inviteCheck || - nicknameInviteCheck || - avatarTextCheck !== null - ) { + if (nameCheck !== null || avatarCheck || inviteCheck || nicknameInviteCheck || avatarTextCheck !== null) { const infractions = []; if (nameCheck !== null) { infractions.push(`Name contains a ${nameCheck.type}ly filtered word (${nameCheck.word})`); diff --git a/tsconfig.json b/tsconfig.json index 2c396b0..1da4a03 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,9 +2,7 @@ "$schema": "https://json.schemastore.org/tsconfig", "display": "Node 18 + ESM + Strictest", "compilerOptions": { - "lib": [ - "es2022" - ], + "lib": ["es2022"], "strict": true, "exactOptionalPropertyTypes": true, "noFallthroughCasesInSwitch": true, From 7ee6c13acf168d99f3efee88ec3c487c34557e53 Mon Sep 17 00:00:00 2001 From: TheCodedProf Date: Fri, 21 Apr 2023 22:57:46 -0400 Subject: [PATCH 4/6] fixed automod settings not saving properly & prettier --- src/commands/settings/automod.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/commands/settings/automod.ts b/src/commands/settings/automod.ts index a854fc5..522d928 100644 --- a/src/commands/settings/automod.ts +++ b/src/commands/settings/automod.ts @@ -1087,34 +1087,34 @@ const callback = async (interaction: CommandInteraction): Promise => { if (i.isButton()) { await client.database.guilds.write(interaction.guild.id, { filters: current }); await client.memory.forceUpdate(interaction.guild.id); - config = current; + config = _.cloneDeep(current); current = _.cloneDeep(config); } else { switch (i.values[0]) { case "invites": { - config.invite = await inviteMenu(i, m, _.isEqual(config, current), config.invite); + current.invite = await inviteMenu(i, m, _.isEqual(config, current), current.invite); break; } case "mentions": { - config.pings = await mentionMenu(i, m, _.isEqual(config, current), config.pings); + current.pings = await mentionMenu(i, m, _.isEqual(config, current), current.pings); break; } case "words": { - config.wordFilter = await wordMenu(i, m, _.isEqual(config, current), config.wordFilter); + current.wordFilter = await wordMenu(i, m, _.isEqual(config, current), current.wordFilter); break; } case "malware": { - config.malware = !config.malware; + current.malware = !current.malware; break; } case "images": { - const next = await imageMenu(i, m, _.isEqual(config, current), config.images); - config.images = next; + const next = await imageMenu(i, m, _.isEqual(config, current), current.images); + current.images = next; break; } case "clean": { const next = await cleanMenu(i, m, _.isEqual(config, current), config.clean); - config.clean = next; + current.clean = next; break; } } From a9e3e0332dd7ab41f4fc244727984738ba26d4ae Mon Sep 17 00:00:00 2001 From: TheCodedProf Date: Sat, 22 Apr 2023 17:32:19 -0400 Subject: [PATCH 5/6] fixed error text --- src/commands/mod/about.ts | 2 +- src/commands/mod/warn.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/mod/about.ts b/src/commands/mod/about.ts index d346156..9630288 100644 --- a/src/commands/mod/about.ts +++ b/src/commands/mod/about.ts @@ -444,7 +444,7 @@ const callback = async (interaction: CommandInteraction): Promise => { const check = (interaction: CommandInteraction) => { const member = interaction.member as GuildMember; - if (!member.permissions.has("ManageMessages")) return "You do not have the *Moderate Members* permission"; + if (!member.permissions.has("ManageMessages")) return "You do not have the *Manage Messages* permission"; return true; }; diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts index 4d333d2..7790fa8 100644 --- a/src/commands/mod/warn.ts +++ b/src/commands/mod/warn.ts @@ -300,7 +300,7 @@ const callback = async ( const check = (interaction: CommandInteraction | ButtonInteraction, partial: boolean = false, target?: GuildMember) => { if (!interaction.guild) return; const member = interaction.member as GuildMember; - if (!member.permissions.has("ManageMessages")) return "You do not have the *Moderate Members* permission"; + if (!member.permissions.has("ManageMessages")) return "You do not have the *Manage Messages* permission"; if (partial) return true; let apply: GuildMember; if (interaction.isButton()) { From 21ec2aacd7f17a7f048c4750785ab54cdfca76ea Mon Sep 17 00:00:00 2001 From: TheCodedProf Date: Sat, 22 Apr 2023 17:32:48 -0400 Subject: [PATCH 6/6] fixed double mutations --- src/commands/settings/automod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/settings/automod.ts b/src/commands/settings/automod.ts index 522d928..5b4198f 100644 --- a/src/commands/settings/automod.ts +++ b/src/commands/settings/automod.ts @@ -1087,7 +1087,7 @@ const callback = async (interaction: CommandInteraction): Promise => { if (i.isButton()) { await client.database.guilds.write(interaction.guild.id, { filters: current }); await client.memory.forceUpdate(interaction.guild.id); - config = _.cloneDeep(current); + config = current; current = _.cloneDeep(config); } else { switch (i.values[0]) {