From 5d33e1aa43444850084b4794b7d870e67dbb474e Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 23 Aug 2021 20:17:13 -0400 Subject: bunch of shit --- src/inhibitors/blacklist/channelGlobalBlacklist.ts | 4 ++-- src/inhibitors/blacklist/channelGuildBlacklist.ts | 4 ++-- src/inhibitors/blacklist/guildBlacklist.ts | 4 ++-- src/inhibitors/blacklist/userGlobalBlacklist.ts | 4 ++-- src/inhibitors/blacklist/userGuildBlacklist.ts | 4 ++-- src/inhibitors/checks/fatal.ts | 22 ++++++++++++++++++++++ src/inhibitors/checks/guildUnavailable.ts | 19 +++++++++++++++++++ src/inhibitors/command/dm.ts | 19 +++++++++++++++++++ src/inhibitors/command/globalDisabledCommand.ts | 20 ++++++++++++++++++++ src/inhibitors/command/guild.ts | 19 +++++++++++++++++++ src/inhibitors/command/guildDisabledCommand.ts | 22 ++++++++++++++++++++++ src/inhibitors/command/nsfw.ts | 20 ++++++++++++++++++++ src/inhibitors/command/owner.ts | 21 +++++++++++++++++++++ src/inhibitors/command/restrictedChannel.ts | 21 +++++++++++++++++++++ src/inhibitors/command/restrictedGuild.ts | 21 +++++++++++++++++++++ src/inhibitors/command/superUser.ts | 21 +++++++++++++++++++++ src/inhibitors/commands/globalDisabledCommand.ts | 20 -------------------- src/inhibitors/commands/guildDisabledCommand.ts | 22 ---------------------- src/inhibitors/noCache.ts | 22 ---------------------- 19 files changed, 235 insertions(+), 74 deletions(-) create mode 100644 src/inhibitors/checks/fatal.ts create mode 100644 src/inhibitors/checks/guildUnavailable.ts create mode 100644 src/inhibitors/command/dm.ts create mode 100644 src/inhibitors/command/globalDisabledCommand.ts create mode 100644 src/inhibitors/command/guild.ts create mode 100644 src/inhibitors/command/guildDisabledCommand.ts create mode 100644 src/inhibitors/command/nsfw.ts create mode 100644 src/inhibitors/command/owner.ts create mode 100644 src/inhibitors/command/restrictedChannel.ts create mode 100644 src/inhibitors/command/restrictedGuild.ts create mode 100644 src/inhibitors/command/superUser.ts delete mode 100644 src/inhibitors/commands/globalDisabledCommand.ts delete mode 100644 src/inhibitors/commands/guildDisabledCommand.ts delete mode 100644 src/inhibitors/noCache.ts (limited to 'src/inhibitors') diff --git a/src/inhibitors/blacklist/channelGlobalBlacklist.ts b/src/inhibitors/blacklist/channelGlobalBlacklist.ts index 9bbf30f..36a6757 100644 --- a/src/inhibitors/blacklist/channelGlobalBlacklist.ts +++ b/src/inhibitors/blacklist/channelGlobalBlacklist.ts @@ -5,7 +5,8 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { super('channelGlobalBlacklist', { reason: 'channelGlobalBlacklist', category: 'blacklist', - type: 'all' + type: 'post', + priority: 500 }); } @@ -14,7 +15,6 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { 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)) { - // client.console.debug(`channelGlobalBlacklist blocked message.`); return true; } return false; diff --git a/src/inhibitors/blacklist/channelGuildBlacklist.ts b/src/inhibitors/blacklist/channelGuildBlacklist.ts index b4c6f3f..54acb34 100644 --- a/src/inhibitors/blacklist/channelGuildBlacklist.ts +++ b/src/inhibitors/blacklist/channelGuildBlacklist.ts @@ -5,7 +5,8 @@ export default class ChannelGuildBlacklistInhibitor extends BushInhibitor { super('channelGuildBlacklist', { reason: 'channelGuildBlacklist', category: 'blacklist', - type: 'all' + type: 'post', + priority: 499 }); } @@ -14,7 +15,6 @@ export default class ChannelGuildBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) return false; if ((await message.guild.getSetting('blacklistedChannels'))?.includes(message.channel!.id)) { - // client.console.debug(`channelGuildBlacklist blocked message.`); return true; } return false; diff --git a/src/inhibitors/blacklist/guildBlacklist.ts b/src/inhibitors/blacklist/guildBlacklist.ts index de15d76..ec78995 100644 --- a/src/inhibitors/blacklist/guildBlacklist.ts +++ b/src/inhibitors/blacklist/guildBlacklist.ts @@ -5,7 +5,8 @@ export default class GuildBlacklistInhibitor extends BushInhibitor { super('guildBlacklist', { reason: 'guildBlacklist', category: 'blacklist', - type: 'all' + type: 'all', + priority: 50 }); } @@ -17,7 +18,6 @@ export default class GuildBlacklistInhibitor extends BushInhibitor { ) return false; if (client.cache.global.blacklistedGuilds.includes(message.guild.id)) { - // client.console.debug(`GuildBlacklistInhibitor blocked message.`); return true; } return false; diff --git a/src/inhibitors/blacklist/userGlobalBlacklist.ts b/src/inhibitors/blacklist/userGlobalBlacklist.ts index 967943d..65d763d 100644 --- a/src/inhibitors/blacklist/userGlobalBlacklist.ts +++ b/src/inhibitors/blacklist/userGlobalBlacklist.ts @@ -5,7 +5,8 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { super('userGlobalBlacklist', { reason: 'userGlobalBlacklist', category: 'blacklist', - type: 'all' + type: 'pre', + priority: 30 }); } @@ -14,7 +15,6 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) return false; if (client.cache.global.blacklistedUsers.includes(message.author.id)) { - // client.console.debug(`userGlobalBlacklist blocked message.`); return true; } return false; diff --git a/src/inhibitors/blacklist/userGuildBlacklist.ts b/src/inhibitors/blacklist/userGuildBlacklist.ts index 0e28ba4..34a24d3 100644 --- a/src/inhibitors/blacklist/userGuildBlacklist.ts +++ b/src/inhibitors/blacklist/userGuildBlacklist.ts @@ -5,7 +5,8 @@ export default class UserGuildBlacklistInhibitor extends BushInhibitor { super('userGuildBlacklist', { reason: 'userGuildBlacklist', category: 'blacklist', - type: 'all' + type: 'pre', + priority: 20 }); } @@ -14,7 +15,6 @@ export default class UserGuildBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) return false; if ((await message.guild.getSetting('blacklistedUsers'))?.includes(message.author.id)) { - // client.console.debug(`userGuildBlacklist blocked message.`); return true; } return false; diff --git a/src/inhibitors/checks/fatal.ts b/src/inhibitors/checks/fatal.ts new file mode 100644 index 0000000..6b62507 --- /dev/null +++ b/src/inhibitors/checks/fatal.ts @@ -0,0 +1,22 @@ +import { BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class FatalInhibitor extends BushInhibitor { + public constructor() { + super('fatal', { + reason: 'fatal', + type: 'all', + category: 'checks', + priority: 100 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage): Promise { + if (client.isOwner(message.author)) return false; + for (const property in client.cache.global) { + if (!client.cache.global[property as keyof typeof client.cache.global]) { + return true; + } + } + return false; + } +} diff --git a/src/inhibitors/checks/guildUnavailable.ts b/src/inhibitors/checks/guildUnavailable.ts new file mode 100644 index 0000000..0bd1bec --- /dev/null +++ b/src/inhibitors/checks/guildUnavailable.ts @@ -0,0 +1,19 @@ +import { BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class GuildUnavailableInhibitor extends BushInhibitor { + public constructor() { + super('guildUnavailable', { + reason: 'guildUnavailable', + type: 'all', + category: 'checks', + priority: 70 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage): Promise { + if (message.guild && !message.guild.available) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/command/dm.ts b/src/inhibitors/command/dm.ts new file mode 100644 index 0000000..4e9c53e --- /dev/null +++ b/src/inhibitors/command/dm.ts @@ -0,0 +1,19 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class DMInhibitor extends BushInhibitor { + public constructor() { + super('dm', { + reason: 'dm', + category: 'command', + type: 'post', + priority: 75 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { + if (command.channel === 'dm' && message.guild) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/command/globalDisabledCommand.ts b/src/inhibitors/command/globalDisabledCommand.ts new file mode 100644 index 0000000..a6e24c7 --- /dev/null +++ b/src/inhibitors/command/globalDisabledCommand.ts @@ -0,0 +1,20 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class DisabledGuildCommandInhibitor extends BushInhibitor { + public constructor() { + super('disabledGlobalCommand', { + reason: 'disabledGlobal', + category: 'command', + type: 'post', + priority: 300 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { + if (message.author.isOwner()) return false; + if (client.cache.global.disabledCommands?.includes(command?.id)) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/command/guild.ts b/src/inhibitors/command/guild.ts new file mode 100644 index 0000000..b960439 --- /dev/null +++ b/src/inhibitors/command/guild.ts @@ -0,0 +1,19 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class GuildInhibitor extends BushInhibitor { + public constructor() { + super('guild', { + reason: 'guild', + category: 'command', + type: 'post', + priority: 80 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { + if (command.channel === 'guild' && !message.guild) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/command/guildDisabledCommand.ts b/src/inhibitors/command/guildDisabledCommand.ts new file mode 100644 index 0000000..d56e42c --- /dev/null +++ b/src/inhibitors/command/guildDisabledCommand.ts @@ -0,0 +1,22 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class DisabledGuildCommandInhibitor extends BushInhibitor { + public constructor() { + super('disabledGuildCommand', { + reason: 'disabledGuild', + category: 'command', + type: 'post', + priority: 250 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { + if (!message.guild || !message.guild) return false; + if (message.author.isOwner() || message.author.isSuperUser()) return false; // super users bypass guild disabled commands + + if ((await message.guild.getSetting('disabledCommands'))?.includes(command?.id)) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/command/nsfw.ts b/src/inhibitors/command/nsfw.ts new file mode 100644 index 0000000..563cb7a --- /dev/null +++ b/src/inhibitors/command/nsfw.ts @@ -0,0 +1,20 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; +import { TextChannel } from 'discord.js'; + +export default class NsfwInhibitor extends BushInhibitor { + public constructor() { + super('nsfw', { + reason: 'notNsfw', + category: 'command', + type: 'post', + priority: 25 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { + if (command.onlyNsfw && !(message.channel as TextChannel).nsfw) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/command/owner.ts b/src/inhibitors/command/owner.ts new file mode 100644 index 0000000..22ac913 --- /dev/null +++ b/src/inhibitors/command/owner.ts @@ -0,0 +1,21 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class OwnerInhibitor extends BushInhibitor { + public constructor() { + super('owner', { + reason: 'owner', + category: 'command', + type: 'post', + priority: 100 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { + if (command.ownerOnly) { + if (!client.isOwner(message.author)) { + return true; + } + } + return false; + } +} diff --git a/src/inhibitors/command/restrictedChannel.ts b/src/inhibitors/command/restrictedChannel.ts new file mode 100644 index 0000000..4578d95 --- /dev/null +++ b/src/inhibitors/command/restrictedChannel.ts @@ -0,0 +1,21 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class RestrictedChannelInhibitor extends BushInhibitor { + public constructor() { + super('restrictedChannel', { + reason: 'restrictedChannel', + category: 'command', + type: 'post', + priority: 10 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { + if (command.restrictedChannels?.length && message.channel) { + if (!command.restrictedChannels.includes(message.channel.id)) { + return true; + } + } + return false; + } +} diff --git a/src/inhibitors/command/restrictedGuild.ts b/src/inhibitors/command/restrictedGuild.ts new file mode 100644 index 0000000..7ec6926 --- /dev/null +++ b/src/inhibitors/command/restrictedGuild.ts @@ -0,0 +1,21 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class RestrictedGuildInhibitor extends BushInhibitor { + public constructor() { + super('restrictedGuild', { + reason: 'restrictedGuild', + category: 'command', + type: 'post', + priority: 5 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { + if (command.restrictedChannels?.length && message.channel) { + if (!command.restrictedChannels.includes(message.channel.id)) { + return true; + } + } + return false; + } +} diff --git a/src/inhibitors/command/superUser.ts b/src/inhibitors/command/superUser.ts new file mode 100644 index 0000000..28674ea --- /dev/null +++ b/src/inhibitors/command/superUser.ts @@ -0,0 +1,21 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class SuperUserInhibitor extends BushInhibitor { + public constructor() { + super('superUser', { + reason: 'superUser', + category: 'command', + type: 'post', + priority: 99 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { + if (command.superUserOnly) { + if (!client.isSuperUser(message.author)) { + return true; + } + } + return false; + } +} diff --git a/src/inhibitors/commands/globalDisabledCommand.ts b/src/inhibitors/commands/globalDisabledCommand.ts deleted file mode 100644 index 9a750cc..0000000 --- a/src/inhibitors/commands/globalDisabledCommand.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; - -export default class DisabledGuildCommandInhibitor extends BushInhibitor { - public constructor() { - super('disabledGlobalCommand', { - reason: 'disabledGlobal', - type: 'pre', - priority: 4 - }); - } - - public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { - if (message.author.isOwner()) return false; - if (client.cache.global.disabledCommands?.includes(command?.id)) { - client.console.debug(`disabledGlobalCommand blocked message.`); - return true; - } - return false; - } -} diff --git a/src/inhibitors/commands/guildDisabledCommand.ts b/src/inhibitors/commands/guildDisabledCommand.ts deleted file mode 100644 index ee798e5..0000000 --- a/src/inhibitors/commands/guildDisabledCommand.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; - -export default class DisabledGuildCommandInhibitor extends BushInhibitor { - public constructor() { - super('disabledGuildCommand', { - reason: 'disabledGuild', - type: 'pre', - priority: 3 - }); - } - - public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { - if (!message.guild || !message.guild) return false; - if (message.author.isOwner() || message.author.isSuperUser()) return false; // super users bypass guild disabled commands - - if ((await message.guild.getSetting('disabledCommands'))?.includes(command?.id)) { - client.console.debug(`disabledGuildCommand blocked message.`); - return true; - } - return false; - } -} diff --git a/src/inhibitors/noCache.ts b/src/inhibitors/noCache.ts deleted file mode 100644 index 673f3ac..0000000 --- a/src/inhibitors/noCache.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; - -export default class NoCacheInhibitor extends BushInhibitor { - public constructor() { - super('noCache', { - reason: 'noCache', - type: 'all', - priority: 100 - }); - } - - public override async exec(message: BushMessage | BushSlashMessage): Promise { - if (client.isOwner(message.author)) return false; - for (const property in client.cache.global) { - if (!client.cache.global[property as keyof typeof client.cache.global]) { - client.console.debug(`NoCacheInhibitor blocked message.`); - return true; - } - } - return false; - } -} -- cgit