diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-04 15:25:32 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-04 15:25:32 -0400 |
commit | cf564dbb6435886f97e2e9870363144386af368d (patch) | |
tree | d535cd73f24a145ca9d7ce1a0e1174cba0d38b31 /src/listeners/commands | |
parent | 34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a (diff) | |
download | tanzanite-cf564dbb6435886f97e2e9870363144386af368d.tar.gz tanzanite-cf564dbb6435886f97e2e9870363144386af368d.tar.bz2 tanzanite-cf564dbb6435886f97e2e9870363144386af368d.zip |
mute command
Diffstat (limited to 'src/listeners/commands')
-rw-r--r-- | src/listeners/commands/commandError.ts | 17 | ||||
-rw-r--r-- | src/listeners/commands/commandMissingPermissions.ts | 12 | ||||
-rw-r--r-- | src/listeners/commands/slashCommandError.ts | 17 |
3 files changed, 37 insertions, 9 deletions
diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts index 3cb5046..20132dd 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -22,7 +22,7 @@ export default class CommandErrorListener extends BushListener { **Channel:** ${message.channel} (${message.channel?.id}) **Message:** [link](${message.url})` ) - .addField('Error', await this.client.util.codeblock(`${error?.stack}`, 1024, 'js')) + .addField('Error', await this.client.util.codeblock(`${typeof error === 'object' ? error?.stack : error}`, 1024, 'js')) .setColor(this.client.util.colors.error) .setTimestamp(); @@ -41,7 +41,10 @@ export default class CommandErrorListener extends BushListener { ); await message.util.send({ embeds: [errorUserEmbed] }).catch((e) => { const channel = message.channel.type === 'dm' ? message.channel.recipient.tag : message.channel.name; - this.client.console.warn('CommandError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack); + this.client.console.warn( + 'CommandError', + `Failed to send user error embed in <<${channel}>>:\n` + typeof e === 'object' ? e?.stack : e + ); }); } else { const errorDevEmbed = new MessageEmbed() @@ -51,7 +54,10 @@ export default class CommandErrorListener extends BushListener { .setDescription(await this.client.util.codeblock(`${error?.stack}`, 2048, 'js')); await message.util.send({ embeds: [errorDevEmbed] }).catch((e) => { const channel = message.channel.type === 'dm' ? message.channel.recipient.tag : message.channel.name; - this.client.console.warn('CommandError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack); + this.client.console.warn( + 'CommandError', + `Failed to send owner error stack in <<${channel}>>.` + typeof e === 'object' ? e?.stack : e + ); }); } } @@ -59,7 +65,10 @@ export default class CommandErrorListener extends BushListener { this.client.console.error( 'CommandError', `an error occurred with the <<${command}>> command in <<${channel}>> triggered by <<${message?.author?.tag}>>:\n` + - error?.stack, + typeof error === + 'object' + ? error?.stack + : error, false ); } diff --git a/src/listeners/commands/commandMissingPermissions.ts b/src/listeners/commands/commandMissingPermissions.ts index e3420ae..bef8e9c 100644 --- a/src/listeners/commands/commandMissingPermissions.ts +++ b/src/listeners/commands/commandMissingPermissions.ts @@ -1,3 +1,4 @@ +import { PermissionString } from 'discord.js'; import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import { BushListener } from '../../lib/extensions/discord-akairo/BushListener'; import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; @@ -15,8 +16,17 @@ export default class CommandMissingPermissionsListener extends BushListener { message: BushMessage, command: BushCommand | null | undefined, type: 'client' | 'user', - missing: Array<string> + missing: Array<PermissionString> ): Promise<void> { + this.client.console.debug(message.guild.me.permissions.toArray()); + missing.forEach((permission) => { + this.client.console.debug(message.guild.me.permissions.has(permission)); + }); + message.guild.me.permissions; + this.client.console.debug(type); + this.client.console.debug(command.clientPermissions); + this.client.console.debug(command.userPermissions); + this.client.console.debug(missing); const niceMissing = []; missing.forEach((missing) => { if (this.client.consts.mappings.permissions[missing]) { diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts index 767bd3d..b172670 100644 --- a/src/listeners/commands/slashCommandError.ts +++ b/src/listeners/commands/slashCommandError.ts @@ -21,7 +21,7 @@ export default class SlashCommandErrorListener extends BushListener { **Channel:** ${message.channel || message.interaction.user?.tag} ${message.channel ? `(${message.channel?.id})` : ''} **Message:** [link](https://discord.com/${message.guild?.id}/${message.channel?.id}/${message.id})` ) - .addField('Error', await this.client.util.codeblock(`${error?.stack}`, 1024, 'js')) + .addField('Error', await this.client.util.codeblock(`${typeof error === 'object' ? error?.stack : error}`, 1024, 'js')) .setColor(this.client.util.colors.error) .setTimestamp(); @@ -40,7 +40,10 @@ export default class SlashCommandErrorListener extends BushListener { `Oh no! While running the command \`${command.id}\`, an error occurred. Please give the developers code \`${errorNo}\`.` ); await message.util.send({ embeds: [errorUserEmbed] }).catch((e) => { - this.client.console.warn('SlashError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack); + this.client.console.warn( + 'SlashError', + `Failed to send user error embed in <<${channel}>>:\n` + typeof e === 'object' ? e?.stack : e + ); }); } else { const errorDevEmbed = new MessageEmbed() @@ -49,7 +52,10 @@ export default class SlashCommandErrorListener extends BushListener { .setTimestamp() .setDescription(await this.client.util.codeblock(`${error?.stack}`, 2048, 'js')); await message.util.send({ embeds: [errorDevEmbed] }).catch((e) => { - this.client.console.warn('SlashError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack); + this.client.console.warn( + 'SlashError', + `Failed to send owner error stack in <<${channel}>>.` + typeof e === 'object' ? e?.stack : e + ); }); } } @@ -57,7 +63,10 @@ export default class SlashCommandErrorListener extends BushListener { this.client.console.error( 'SlashError', `an error occurred with the <<${command}>> command in <<${channel}>> triggered by <<${message?.author?.tag}>>:\n` + - error?.stack, + typeof error === + 'object' + ? error?.stack + : error, false ); } |