aboutsummaryrefslogtreecommitdiff
path: root/src/inhibitors/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/inhibitors/command')
-rw-r--r--src/inhibitors/command/dm.ts19
-rw-r--r--src/inhibitors/command/globalDisabledCommand.ts20
-rw-r--r--src/inhibitors/command/guild.ts19
-rw-r--r--src/inhibitors/command/guildDisabledCommand.ts22
-rw-r--r--src/inhibitors/command/nsfw.ts20
-rw-r--r--src/inhibitors/command/owner.ts21
-rw-r--r--src/inhibitors/command/restrictedChannel.ts21
-rw-r--r--src/inhibitors/command/restrictedGuild.ts21
-rw-r--r--src/inhibitors/command/superUser.ts21
9 files changed, 184 insertions, 0 deletions
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<boolean> {
+ 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<boolean> {
+ 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<boolean> {
+ 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<boolean> {
+ 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<boolean> {
+ 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<boolean> {
+ 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<boolean> {
+ 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<boolean> {
+ 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<boolean> {
+ if (command.superUserOnly) {
+ if (!client.isSuperUser(message.author)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}