From b2ea3e7f142d47d19819893eb1c5fe9e8a31f87c Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 6 Sep 2021 11:30:16 -0400 Subject: change channel overrides to not use superusers --- src/inhibitors/blacklist/channelGlobalBlacklist.ts | 2 +- src/inhibitors/blacklist/channelGuildBlacklist.ts | 3 ++- src/lib/extensions/discord-akairo/BushClientUtil.ts | 2 +- src/lib/models/Guild.ts | 21 ++++++++++++++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/inhibitors/blacklist/channelGlobalBlacklist.ts b/src/inhibitors/blacklist/channelGlobalBlacklist.ts index 36a6757..d870307 100644 --- a/src/inhibitors/blacklist/channelGlobalBlacklist.ts +++ b/src/inhibitors/blacklist/channelGlobalBlacklist.ts @@ -12,7 +12,7 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { public override exec(message: BushMessage | BushSlashMessage): boolean { if (!message.author || !message.guild) return false; - if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) + if (client.isOwner(message.author) || /* client.isSuperUser(message.author) ||*/ client.user!.id === message.author.id) return false; if (client.cache.global.blacklistedChannels.includes(message.channel!.id)) { return true; diff --git a/src/inhibitors/blacklist/channelGuildBlacklist.ts b/src/inhibitors/blacklist/channelGuildBlacklist.ts index 54acb34..d02408c 100644 --- a/src/inhibitors/blacklist/channelGuildBlacklist.ts +++ b/src/inhibitors/blacklist/channelGuildBlacklist.ts @@ -12,8 +12,9 @@ export default class ChannelGuildBlacklistInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage): Promise { if (!message.author || !message.guild) return false; - if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) + if (client.isOwner(message.author) || /* client.isSuperUser(message.author) || */ client.user!.id === message.author.id) return false; + if ((await message.guild.getSetting('bypassChannelBlacklist'))?.includes(message.author.id)) return false; if ((await message.guild.getSetting('blacklistedChannels'))?.includes(message.channel!.id)) { return true; } diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index 91d5eb6..4028517 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -1169,7 +1169,7 @@ export class BushClientUtil extends ClientUtil { if (!getCaseNumber) return { log: saveResult, caseNum: null }; - const caseNum = (await ModLog.findAll({ where: { type: options.type, user: user, guild: guild } }))?.length; + const caseNum = (await ModLog.findAll({ where: { type: options.type, user: user, guild: guild, hidden: false } }))?.length; return { log: saveResult, caseNum }; } diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts index a4780fd..b155330 100644 --- a/src/lib/models/Guild.ts +++ b/src/lib/models/Guild.ts @@ -46,6 +46,12 @@ export const guildSettingsObj = { description: 'Roles assigned to users on join who do not have sticky role information.', type: 'role-array', configurable: true + }, + bypassChannelBlacklist: { + name: 'Bypass Channel Blacklist', + description: 'These users will be able to use commands in channels blacklisted.', + type: 'user-array', + configurable: true } }; export type GuildSettings = keyof typeof guildSettingsObj; @@ -130,6 +136,7 @@ export interface GuildModel { enabledFeatures: GuildFeatures[]; joinRoles: Snowflake[]; logChannels: LogChannelDB; + bypassChannelBlacklist: Snowflake[]; } export interface GuildModelCreationAttributes { @@ -147,6 +154,7 @@ export interface GuildModelCreationAttributes { enabledFeatures?: GuildFeatures[]; joinRoles?: Snowflake[]; logChannels?: LogChannelDB; + bypassChannelBlacklist?: Snowflake[]; } export class Guild extends BaseModel implements GuildModel { @@ -290,6 +298,16 @@ export class Guild extends BaseModel i throw new Error(NEVER_USED); } + /** + * These users will be able to use commands in channels blacklisted + */ + public get bypassChannelBlacklist(): Snowflake[] { + throw new Error(NEVER_USED); + } + public set bypassChannelBlacklist(_: Snowflake[]) { + throw new Error(NEVER_USED); + } + public static initModel(sequelize: Sequelize, client: BushClient): void { Guild.init( { @@ -332,7 +350,8 @@ export class Guild extends BaseModel i }, allowNull: false, defaultValue: '{}' - } + }, + bypassChannelBlacklist: jsonArrayInit('bypassChannelBlacklist') }, { sequelize: sequelize } ); -- cgit