aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/contextCommands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-09-05 17:36:42 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-09-05 17:36:42 -0400
commit048f99752550c6e03d1990a03cad78f3ac7d73aa (patch)
treec238ac29b1b526e86bcbc4989036df981c860187 /src/listeners/contextCommands
parent6f8a4d13a490eda7a195d14833c83810f7b5a789 (diff)
downloadtanzanite-048f99752550c6e03d1990a03cad78f3ac7d73aa.tar.gz
tanzanite-048f99752550c6e03d1990a03cad78f3ac7d73aa.tar.bz2
tanzanite-048f99752550c6e03d1990a03cad78f3ac7d73aa.zip
revamp command permissions, fix permission exploit for some command when used in forum channels, use enums more
Diffstat (limited to 'src/listeners/contextCommands')
-rw-r--r--src/listeners/contextCommands/contextCommandBlocked.ts13
-rw-r--r--src/listeners/contextCommands/contextCommandError.ts23
-rw-r--r--src/listeners/contextCommands/contextCommandNotFound.ts8
-rw-r--r--src/listeners/contextCommands/contextCommandStarted.ts8
4 files changed, 33 insertions, 19 deletions
diff --git a/src/listeners/contextCommands/contextCommandBlocked.ts b/src/listeners/contextCommands/contextCommandBlocked.ts
index d8d002e..93b53c7 100644
--- a/src/listeners/contextCommands/contextCommandBlocked.ts
+++ b/src/listeners/contextCommands/contextCommandBlocked.ts
@@ -1,15 +1,16 @@
-import { BlockedReasons, BotListener, emojis, format } from '#lib';
+import { BotListener, ContextCommandHandlerEvent, Emitter, emojis, format } from '#lib';
import { type ContextMenuCommandHandlerEvents } from 'discord-akairo';
+import { BuiltInReasons } from 'discord-akairo/dist/src/util/Constants.js';
export default class ContextCommandBlockedListener extends BotListener {
public constructor() {
super('contextCommandBlocked', {
- emitter: 'contextMenuCommandHandler',
- event: 'blocked'
+ emitter: Emitter.ContextMenuCommandHandler,
+ event: ContextCommandHandlerEvent.Blocked
});
}
- public async exec(...[interaction, command, reason]: ContextMenuCommandHandlerEvents['blocked']) {
+ public async exec(...[interaction, command, reason]: ContextMenuCommandHandlerEvents[ContextCommandHandlerEvent.Blocked]) {
void this.client.console.info(
`ContextCommandBlocked`,
`<<${interaction.user.tag}>> tried to run <<${command}>> but was blocked because <<${reason}>>.`,
@@ -17,13 +18,13 @@ export default class ContextCommandBlockedListener extends BotListener {
);
switch (reason) {
- case BlockedReasons.OWNER: {
+ case BuiltInReasons.OWNER: {
return await interaction.reply({
content: `${emojis.error} Only my developers can run the ${format.input(command!.id)} command.`,
ephemeral: true
});
}
- case BlockedReasons.SUPER_USER: {
+ case BuiltInReasons.SUPER_USER: {
return await interaction.reply({
content: `${emojis.error} You must be a superuser to run the ${format.input(command!.id)} command.`,
ephemeral: true
diff --git a/src/listeners/contextCommands/contextCommandError.ts b/src/listeners/contextCommands/contextCommandError.ts
index 091bee9..24e5cef 100644
--- a/src/listeners/contextCommands/contextCommandError.ts
+++ b/src/listeners/contextCommands/contextCommandError.ts
@@ -1,20 +1,33 @@
-import { BotListener, colors, format, formatError, getErrorHaste, getErrorStack, IFuckedUpError } from '#lib';
+import {
+ BotListener,
+ colors,
+ ContextCommandHandlerEvent,
+ Emitter,
+ format,
+ formatError,
+ getErrorHaste,
+ getErrorStack,
+ IFuckedUpError
+} from '#lib';
import { type ContextMenuCommand, type ContextMenuCommandHandlerEvents } from 'discord-akairo';
import { ChannelType, Client, ContextMenuCommandInteraction, EmbedBuilder, GuildTextBasedChannel } from 'discord.js';
export default class ContextCommandErrorListener extends BotListener {
public constructor() {
super('contextCommandError', {
- emitter: 'contextMenuCommandHandler',
- event: 'error'
+ emitter: Emitter.ContextMenuCommandHandler,
+ event: ContextCommandHandlerEvent.Error
});
}
- public exec(...[error, interaction, command]: ContextMenuCommandHandlerEvents['error']) {
+ public exec(...[error, interaction, command]: ContextMenuCommandHandlerEvents[ContextCommandHandlerEvent.Error]) {
return ContextCommandErrorListener.handleError(this.client, error, interaction, command);
}
- public static async handleError(client: Client, ...[error, interaction, command]: ContextMenuCommandHandlerEvents['error']) {
+ public static async handleError(
+ client: Client,
+ ...[error, interaction, command]: ContextMenuCommandHandlerEvents[ContextCommandHandlerEvent.Error]
+ ) {
try {
const errorNum = Math.floor(Math.random() * 6969696969) + 69; // hehe funny number
const channel =
diff --git a/src/listeners/contextCommands/contextCommandNotFound.ts b/src/listeners/contextCommands/contextCommandNotFound.ts
index 4bb397e..da364ed 100644
--- a/src/listeners/contextCommands/contextCommandNotFound.ts
+++ b/src/listeners/contextCommands/contextCommandNotFound.ts
@@ -1,15 +1,15 @@
-import { BotListener } from '#lib';
+import { BotListener, ContextCommandHandlerEvent, Emitter } from '#lib';
import { type ContextMenuCommandHandlerEvents } from 'discord-akairo';
export default class ContextCommandNotFoundListener extends BotListener {
public constructor() {
super('contextCommandNotFound', {
- emitter: 'contextMenuCommandHandler',
- event: 'notFound'
+ emitter: Emitter.ContextMenuCommandHandler,
+ event: ContextCommandHandlerEvent.NotFound
});
}
- public async exec(...[interaction]: ContextMenuCommandHandlerEvents['notFound']) {
+ public async exec(...[interaction]: ContextMenuCommandHandlerEvents[ContextCommandHandlerEvent.NotFound]) {
void this.client.console.info('contextCommandNotFound', `<<${interaction?.commandName}>> could not be found.`);
}
}
diff --git a/src/listeners/contextCommands/contextCommandStarted.ts b/src/listeners/contextCommands/contextCommandStarted.ts
index 867af54..bf7cc58 100644
--- a/src/listeners/contextCommands/contextCommandStarted.ts
+++ b/src/listeners/contextCommands/contextCommandStarted.ts
@@ -1,16 +1,16 @@
-import { BotListener } from '#lib';
+import { BotListener, ContextCommandHandlerEvent, Emitter } from '#lib';
import { ContextMenuCommandHandlerEvents } from 'discord-akairo';
import { ApplicationCommandType, ChannelType } from 'discord.js';
export default class ContextCommandStartedListener extends BotListener {
public constructor() {
super('contextCommandStarted', {
- emitter: 'contextMenuCommandHandler',
- event: 'started'
+ emitter: Emitter.ContextMenuCommandHandler,
+ event: ContextCommandHandlerEvent.Started
});
}
- public async exec(...[interaction, command]: ContextMenuCommandHandlerEvents['started']) {
+ public async exec(...[interaction, command]: ContextMenuCommandHandlerEvents[ContextCommandHandlerEvent.Started]) {
this.client.sentry.addBreadcrumb({
message: `[contextCommandStarted] The ${command.id} was started by ${interaction.user.tag}.`,
level: 'info',