From e26413dde461729694c36a92e01970df15eb68a5 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 9 Jan 2022 09:31:55 -0500 Subject: this is a really bad idea --- src/lib/extensions/discord-akairo/BushClientUtil.ts | 4 ++-- src/lib/models/Shared.ts | 10 +++++++++- src/lib/utils/BushCache.ts | 1 + src/listeners/bush/joinAutoBan.ts | 10 +++++++--- src/listeners/bush/userUpdateAutoBan.ts | 10 +++++++--- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index 3e066c8..12becd3 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -476,7 +476,7 @@ export class BushClientUtil extends ClientUtil { * @param key The key of the element in the shared cache to update. * @param value The value to add/remove from the array. */ - public async insertOrRemoveFromShared>( + public async insertOrRemoveFromShared>( action: 'add' | 'remove', key: K, value: typeof client['cache']['shared'][K][0] @@ -510,7 +510,7 @@ export class BushClientUtil extends ClientUtil { * @param key The key in the shared cache to update. * @param value The value to set the key to. */ - public async setShared>( + public async setShared>( key: K, value: typeof client['cache']['shared'][K] ): Promise { diff --git a/src/lib/models/Shared.ts b/src/lib/models/Shared.ts index a240ef9..acb5c1e 100644 --- a/src/lib/models/Shared.ts +++ b/src/lib/models/Shared.ts @@ -11,6 +11,7 @@ export interface SharedModel { badLinksSecret: string[]; badLinks: string[]; badWords: BadWords; + autoBanCode: string | null; } export interface SharedModelCreationAttributes { @@ -20,6 +21,7 @@ export interface SharedModelCreationAttributes { badLinksSecret?: string[]; badLinks?: string[]; badWords?: BadWords; + autoBanCode?: string; } export class Shared extends BaseModel implements SharedModel { @@ -53,6 +55,11 @@ export class Shared extends BaseModel { public badLinksSecret: string[] = []; public badLinks: string[] = []; public badWords: BadWords = {}; + public autoBanCode: string | null = null; } export class GuildCache extends Collection {} diff --git a/src/listeners/bush/joinAutoBan.ts b/src/listeners/bush/joinAutoBan.ts index 3a85d17..031c989 100644 --- a/src/listeners/bush/joinAutoBan.ts +++ b/src/listeners/bush/joinAutoBan.ts @@ -14,7 +14,11 @@ export default class JoinAutoBanListener extends BushListener { if (member.guild.id !== client.consts.mappings.guilds.bush) return; const guild = member.guild; - if (member.user.username.toLowerCase().includes('notenoughupdates')) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const user = member.user; + const code = util.getShared('autoBanCode'); + if (!code) return; + if (eval(code)) { const res = await member.bushBan({ reason: '[AutoBan] Impersonation is not allowed.', moderator: member.guild.me! @@ -23,7 +27,7 @@ export default class JoinAutoBanListener extends BushListener { if (!['success', 'failed to dm'].includes(res)) { return await guild.error( 'nameAutoBan', - `Failed to autoban ${util.format.input(member.user.tag)} for 'NotEnoughUpdates', with error: ${util.format.input(res)}.` + `Failed to auto ban ${util.format.input(member.user.tag)} for blacklisted name, with error: ${util.format.input(res)}.` ); } @@ -32,7 +36,7 @@ export default class JoinAutoBanListener extends BushListener { embeds: [ { title: 'Name Auto Ban - User Join', - description: `**User:** ${member.user} (${member.user.tag})\n **Action:** Banned for using the blacklisted name 'NotEnoughUpdates'.`, + description: `**User:** ${member.user} (${member.user.tag})\n **Action:** Banned for blacklisted name.`, color: client.consts.colors.red, author: { name: member.user.tag, diff --git a/src/listeners/bush/userUpdateAutoBan.ts b/src/listeners/bush/userUpdateAutoBan.ts index cd10144..c829cc3 100644 --- a/src/listeners/bush/userUpdateAutoBan.ts +++ b/src/listeners/bush/userUpdateAutoBan.ts @@ -12,7 +12,11 @@ export default class UserUpdateAutoBanListener extends BushListener { public override async exec(...[_oldUser, newUser]: BushClientEvents['userUpdate']): Promise { if (!client.config.isProduction) return; - if (newUser.username.toLowerCase().includes('notenoughupdates')) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const user = newUser; + const code = util.getShared('autoBanCode'); + if (!code) return; + if (eval(code)) { const member = await client.guilds.cache .get(client.consts.mappings.guilds.bush) ?.members.fetch(newUser.id) @@ -29,7 +33,7 @@ export default class UserUpdateAutoBanListener extends BushListener { if (!['success', 'failed to dm'].includes(res)) { return await guild.error( 'nameAutoBan', - `Failed to autoban ${util.format.input(member.user.tag)} for 'NotEnoughUpdates', with error: ${util.format.input(res)}.` + `Failed to auto ban ${util.format.input(member.user.tag)} for blacklisted name, with error: ${util.format.input(res)}.` ); } @@ -38,7 +42,7 @@ export default class UserUpdateAutoBanListener extends BushListener { embeds: [ { title: 'Name Auto Ban - User Update', - description: `**User:** ${member.user} (${member.user.tag})\n **Action:** Banned for using the blacklisted name 'NotEnoughUpdates'.`, + description: `**User:** ${member.user} (${member.user.tag})\n **Action:** Banned for using blacklisted name.`, color: client.consts.colors.red, author: { name: member.user.tag, -- cgit