aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/commands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
commit661e4c9935aeb8760dafc7ced4bbec6cc356a033 (patch)
treebb4c12bdef067d203f100e13e05ccb705b299834 /src/listeners/commands
parenteaf592b72eb5b1d66aa2bde5151a8947570a506c (diff)
downloadtanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.gz
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.bz2
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.zip
remove the war crimes that I previously committed
- Remove custom typings and replace with declaration merging - Fix the typings for args - Replace all discord-api-types imports with discord.js imports - Fix discord.js breaking changes
Diffstat (limited to 'src/listeners/commands')
-rw-r--r--src/listeners/commands/commandBlocked.ts16
-rw-r--r--src/listeners/commands/commandError.ts26
-rw-r--r--src/listeners/commands/commandMissingPermissions.ts2
3 files changed, 22 insertions, 22 deletions
diff --git a/src/listeners/commands/commandBlocked.ts b/src/listeners/commands/commandBlocked.ts
index 0d3c1d9..feb85d1 100644
--- a/src/listeners/commands/commandBlocked.ts
+++ b/src/listeners/commands/commandBlocked.ts
@@ -1,5 +1,5 @@
-import { BushListener, type BushCommand, type BushCommandHandlerEvents, type BushMessage, type BushSlashMessage } from '#lib';
-import { type InteractionReplyOptions, type Message, type MessagePayload, type ReplyMessageOptions } from 'discord.js';
+import { BushListener, type BushCommand, type BushCommandHandlerEvents, type CommandMessage, type SlashMessage } from '#lib';
+import { type InteractionReplyOptions, type MessagePayload, type ReplyMessageOptions } from 'discord.js';
export default class CommandBlockedListener extends BushListener {
public constructor() {
@@ -14,11 +14,7 @@ export default class CommandBlockedListener extends BushListener {
return await CommandBlockedListener.handleBlocked(message, command, reason);
}
- public static async handleBlocked(
- message: Message | BushMessage | BushSlashMessage,
- command: BushCommand | null,
- reason?: string
- ) {
+ public static async handleBlocked(message: CommandMessage | SlashMessage, command: BushCommand | null, reason?: string) {
const isSlash = !!command && !!message.util?.isSlash;
void client.console.info(
@@ -64,7 +60,7 @@ export default class CommandBlockedListener extends BushListener {
content: `${util.emojis.error} You cannot use this bot in this channel.`,
ephemeral: true
})
- : await (message as BushMessage).react(util.emojis.cross);
+ : await (message as CommandMessage).react(util.emojis.cross);
case reasons.USER_GLOBAL_BLACKLIST:
case reasons.USER_GUILD_BLACKLIST:
return isSlash
@@ -72,14 +68,14 @@ export default class CommandBlockedListener extends BushListener {
content: `${util.emojis.error} You are blacklisted from using this bot.`,
ephemeral: true
})
- : await (message as BushMessage).react(util.emojis.cross);
+ : await (message as CommandMessage).react(util.emojis.cross);
case reasons.ROLE_BLACKLIST: {
return isSlash
? await respond({
content: `${util.emojis.error} One of your roles blacklists you from using this bot.`,
ephemeral: true
})
- : await (message as BushMessage).react(util.emojis.cross);
+ : await (message as CommandMessage).react(util.emojis.cross);
}
case reasons.RESTRICTED_CHANNEL: {
if (!command) break;
diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts
index f830cca..878e459 100644
--- a/src/listeners/commands/commandError.ts
+++ b/src/listeners/commands/commandError.ts
@@ -1,6 +1,6 @@
-import { type BushCommandHandlerEvents } from '#lib';
+import { SlashMessage, type BushCommandHandlerEvents } from '#lib';
import { type AkairoMessage, type Command } from 'discord-akairo';
-import { EmbedBuilder, Formatters, GuildTextBasedChannel, type Message } from 'discord.js';
+import { ChannelType, EmbedBuilder, Formatters, GuildTextBasedChannel, type Message } from 'discord.js';
import { BushListener } from '../../lib/extensions/discord-akairo/BushListener.js';
export default class CommandErrorListener extends BushListener {
@@ -20,10 +20,13 @@ export default class CommandErrorListener extends BushListener {
...[error, message, _command]: BushCommandHandlerEvents['error'] | BushCommandHandlerEvents['slashError']
) {
try {
- const isSlash = message.util.isSlash;
+ const isSlash = message.util?.isSlash;
const errorNum = Math.floor(Math.random() * 6969696969) + 69; // hehe funny number
- const channel = message.channel?.isDM() ? message.channel.recipient?.tag : (<GuildTextBasedChannel>message.channel)?.name;
- const command = _command ?? message.util.parsed?.command;
+ const channel =
+ message.channel?.type === ChannelType.DM
+ ? message.channel.recipient?.tag
+ : (<GuildTextBasedChannel>message.channel)?.name;
+ const command = _command ?? message.util?.parsed?.command;
client.sentry.captureException(error, {
level: 'error',
@@ -31,9 +34,10 @@ export default class CommandErrorListener extends BushListener {
extra: {
'command.name': command?.id,
'message.id': message.id,
- 'message.type': message.util.isSlash ? 'slash' : 'normal',
- 'message.parsed.content': message.util.parsed?.content,
- 'channel.id': (message.channel?.isDM() ? message.channel.recipient?.id : message.channel?.id) ?? '¯\\_(ツ)_/¯',
+ 'message.type': message.util ? (message.util.isSlash ? 'slash' : 'normal') : 'unknown',
+ 'message.parsed.content': message.util?.parsed?.content,
+ 'channel.id':
+ (message.channel?.type === ChannelType.DM ? message.channel.recipient?.id : message.channel?.id) ?? '¯\\_(ツ)_/¯',
'channel.name': channel,
'guild.id': message.guild?.id ?? '¯\\_(ツ)_/¯',
'guild.name': message.guild?.name ?? '¯\\_(ツ)_/¯',
@@ -87,7 +91,7 @@ export default class CommandErrorListener extends BushListener {
| {
message: Message | AkairoMessage;
error: Error | any;
- isSlash: boolean;
+ isSlash?: boolean;
type: 'command-log' | 'command-dev' | 'command-user';
errorNum: number;
command?: Command;
@@ -105,9 +109,9 @@ export default class CommandErrorListener extends BushListener {
private static _generateErrorEmbed(
options:
| {
- message: Message | AkairoMessage;
+ message: Message | SlashMessage;
error: Error | any;
- isSlash: boolean;
+ isSlash?: boolean;
type: 'command-log' | 'command-dev' | 'command-user';
errorNum: number;
command?: Command;
diff --git a/src/listeners/commands/commandMissingPermissions.ts b/src/listeners/commands/commandMissingPermissions.ts
index 19c0860..2cbf17c 100644
--- a/src/listeners/commands/commandMissingPermissions.ts
+++ b/src/listeners/commands/commandMissingPermissions.ts
@@ -1,5 +1,5 @@
import { BushListener, type BushCommandHandlerEvents } from '#lib';
-import { PermissionsString } from 'discord.js';
+import { type PermissionsString } from 'discord.js';
export default class CommandMissingPermissionsListener extends BushListener {
public constructor() {