diff --git a/src/middleware/BaseClient.js b/src/middleware/BaseClient.js index afde573..0c56608 100644 --- a/src/middleware/BaseClient.js +++ b/src/middleware/BaseClient.js @@ -55,7 +55,7 @@ class BaseClient extends EventEmitter { this.logger.status(`Starting bot shards`); await this.shardingManager.spawn().catch((error) => { - this.logger.error(`Fatal error during shard spawning:\n${error.stack || error}`); + this.logger.error(`Fatal error during shard spawning:\n${error.stack || inspect(error)}`); // eslint-disable-next-line no-process-exit process.exit(); // Prevent a boot loop when shards die due to an error in the client }); diff --git a/src/structure/client/Dispatcher.js b/src/structure/client/Dispatcher.js index ac6648d..3d2915a 100644 --- a/src/structure/client/Dispatcher.js +++ b/src/structure/client/Dispatcher.js @@ -29,7 +29,7 @@ class Dispatcher { const observers = this.client.registry.components .filter((c) => c._type === 'observer' && !c.disabled) - .sort((a, b) => a.priority - b.priority); + .sort((a, b) => a.priority - b.priority); // Lowest number first this.logger.debug(`Starting dispatch on ${observers.size} observers.`); for(const observer of observers.values()) { diff --git a/src/structure/client/ModerationManager.js b/src/structure/client/ModerationManager.js index 919c973..dbdc9ab 100644 --- a/src/structure/client/ModerationManager.js +++ b/src/structure/client/ModerationManager.js @@ -170,18 +170,22 @@ class ModerationManager { if (!silent) { for (const [, data] of Object.entries(successes)) { const { dictionary, targetType } = data.infraction; - const reason = data.escalation ? - invoker.format('INFRACTION_ESCALATIONREASON') : - Util.escapeMarkdown(data.infraction.reason); - const str = `${Emojis.success} ${invoker.format('INFRACTION_SUCCESS', { + const reason = Util.escapeMarkdown(data.infraction.reason); + // data.escalation ? + // invoker.format('INFRACTION_ESCALATIONREASON') : + // Util.escapeMarkdown(data.infraction.reason); + const str = `${data.escalation ? Emojis.escalated : Emojis.success} ${invoker.format('INFRACTION_SUCCESS', { infraction: dictionary.past, targetType: `${targetType.toLowerCase()}${data.targets.length === 1 ? '' : 's'}`, target: data.targets.map((t) => `**${Util.escapeMarkdown(t)}**`).join(' '), - text: !data.escalation ? - ` ${reason.length > 120 ? - `for: \`${reason.substring(0, 117)}...\`` : - `for: \`${reason}\``}` : - ` because \`${reason}\`` + text: ` ${reason.length > 120 ? + `for: \`${reason.substring(0, 117)}...\`` : + `for: \`${reason}\``}` + // !data.escalation ? + // ` ${reason.length > 120 ? + // `for: \`${reason.substring(0, 117)}...\`` : + // `for: \`${reason}\``}` : + // ` because \`${reason}\`` })}`; data.escalation ? string += str : string = `${str}\n${string}`; //eslint-disable-line } @@ -199,15 +203,11 @@ class ModerationManager { } } - if(silent) await invoker.deleteReply(); - // if (success && silent) { //Delete message if silent. - // try { - // await interaction.delete(); - // } catch (e) { } //eslint-disable-line no-empty - // } - - //if (string) interaction.reply(string); - // return succeeded; + if (silent) { + await invoker.deleteReply(); + await invoker.delete().catch(() => null); + } + return string.length ? string : null; } diff --git a/src/structure/components/observers/Automoderation.js b/src/structure/components/observers/Automoderation.js index 903c785..176e05d 100644 --- a/src/structure/components/observers/Automoderation.js +++ b/src/structure/components/observers/Automoderation.js @@ -159,10 +159,6 @@ module.exports = class AutoModeration extends Observer { } log += `\nNormalised: ${content}`; - const catcher = (ln) => { - return (error) => this.logger.debug(`Issue with promise on line ${ln}:\n${error.stack}`); - }; - // match: what was matched | // matched: did it match at all ? | // matcher: what gets shown in the message logs | @@ -616,6 +612,7 @@ module.exports = class AutoModeration extends Observer { const { guild, author, guildWrapper: wrapper } = message; let { channel } = message; + if (!channel) return; // Idk how or why but the channel is sometimes null? I have absolutely no clue how this could ever be the case if (channel.partial) channel = await channel.fetch(); if (!guild || author.bot || message.filtered) return; diff --git a/src/structure/components/observers/CommandHandler.js b/src/structure/components/observers/CommandHandler.js index d48a0ee..e18a873 100644 --- a/src/structure/components/observers/CommandHandler.js +++ b/src/structure/components/observers/CommandHandler.js @@ -188,7 +188,7 @@ class CommandHandler extends Observer { this._generateError(invoker, { error, type: 'command' }); } else { if (!(invoker.command instanceof SettingsCommand)) invoker.command.error(now); - this.logger.error(`Command ${debugstr} errored:\nOptions:\n${Object.keys(options).map((key) => `[${key}: ${options[key]._rawValue}]`).join('\n')}\n${error.stack || error}`); + this.logger.error(`Command ${debugstr} errored:\nGuild: ${invoker.guild?.name || 'dms'} (${invoker.guild?.id || ''})\nOptions:\n${Object.keys(options).map((key) => `[${key}: ${options[key]._rawValue}]`).join('\n')}\n${error.stack || error}`); this._generateError(invoker, { type: 'commandHandler' }); } return; diff --git a/src/structure/components/settings/moderation/InviteFilter.js b/src/structure/components/settings/moderation/InviteFilter.js index dd9eb8c..08c79e5 100644 --- a/src/structure/components/settings/moderation/InviteFilter.js +++ b/src/structure/components/settings/moderation/InviteFilter.js @@ -168,17 +168,17 @@ class InviteFilterSetting extends FilterSetting { }, { name: 'GENERAL_IGNORED', - value: setting.ignore.map((channel) => `<#${channel}>`).join(', ') || '**N/A**', + value: setting.ignore?.map((channel) => `<#${channel}>`).join(', ') || '**N/A**', inline: true }, { name: 'GENERAL_BYPASS', - value: setting.bypass.map((role) => `<@&${role}>`).join(', ') || '**N/A**', + value: setting.bypass?.map((role) => `<@&${role}>`).join(', ') || '**N/A**', inline: true }, { name: 'SETTING_FILTER_ACTIONS', - value: setting.actions.reduce((acc, val) => { + value: setting.actions?.reduce((acc, val) => { let str = `**${val.type}**`; if (val.points) str += ` (${val.points} points)`; if (val.duration) str += ` for ${Util.humanise(val.duration)}`;