diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-09 09:31:55 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-09 09:31:55 -0500 |
commit | e26413dde461729694c36a92e01970df15eb68a5 (patch) | |
tree | 3591852bd988e5fc0aa5a60850ed75666c66209c | |
parent | 522a629a945ecaf1c53aae55fd2d5dfe7346aad4 (diff) | |
download | tanzanite-e26413dde461729694c36a92e01970df15eb68a5.tar.gz tanzanite-e26413dde461729694c36a92e01970df15eb68a5.tar.bz2 tanzanite-e26413dde461729694c36a92e01970df15eb68a5.zip |
this is a really bad idea
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClientUtil.ts | 4 | ||||
-rw-r--r-- | src/lib/models/Shared.ts | 10 | ||||
-rw-r--r-- | src/lib/utils/BushCache.ts | 1 | ||||
-rw-r--r-- | src/listeners/bush/joinAutoBan.ts | 10 | ||||
-rw-r--r-- | 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<K extends Exclude<keyof typeof client['cache']['shared'], 'badWords'>>( + public async insertOrRemoveFromShared<K extends Exclude<keyof typeof client['cache']['shared'], 'badWords' | 'autoBanCode'>>( 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<K extends Exclude<keyof typeof client['cache']['shared'], 'badWords'>>( + public async setShared<K extends Exclude<keyof typeof client['cache']['shared'], 'badWords' | 'autoBanCode'>>( key: K, value: typeof client['cache']['shared'][K] ): Promise<Shared | void> { 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<SharedModel, SharedModelCreationAttributes> implements SharedModel { @@ -54,6 +56,11 @@ export class Shared extends BaseModel<SharedModel, SharedModelCreationAttributes public declare badWords: BadWords; /** + * Code that is used to match for auto banning users in moulberry's bush + */ + public declare autoBanCode: string; + + /** * Initializes the model. * @param sequelize The sequelize instance. */ @@ -65,7 +72,8 @@ export class Shared extends BaseModel<SharedModel, SharedModelCreationAttributes privilegedUsers: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] }, badLinksSecret: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] }, badLinks: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] }, - badWords: { type: DataTypes.JSONB, allowNull: false, defaultValue: {} } + badWords: { type: DataTypes.JSONB, allowNull: false, defaultValue: {} }, + autoBanCode: { type: DataTypes.TEXT } }, { sequelize, freezeTableName: true } ); diff --git a/src/lib/utils/BushCache.ts b/src/lib/utils/BushCache.ts index 1f50fba..22a13ef 100644 --- a/src/lib/utils/BushCache.ts +++ b/src/lib/utils/BushCache.ts @@ -20,6 +20,7 @@ export class SharedCache implements Omit<SharedModel, 'primaryKey'> { public badLinksSecret: string[] = []; public badLinks: string[] = []; public badWords: BadWords = {}; + public autoBanCode: string | null = null; } export class GuildCache extends Collection<Snowflake, Guild> {} 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<void> { 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, |