This commit is contained in:
Erik 2021-11-29 12:25:38 +02:00
parent 3279d69ed3
commit 62d5eaae5c
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589
3 changed files with 16 additions and 11 deletions

View File

@ -157,7 +157,7 @@ class ChannelHandler {
inline: false inline: false
}); });
await channel.send({ embed }); await channel.send({ embed }).catch(err => this.client.logger.error(`ChannelHandler.load errored at channel.send:\n${err.stack}`));
// Load in context // Load in context
const len = history.length; const len = history.length;
@ -194,7 +194,7 @@ class ChannelHandler {
value: entry.attachments.join('\n').substring(0, 1000) value: entry.attachments.join('\n').substring(0, 1000)
}); });
await channel.send({ embed }); await channel.send({ embed }).catch(err => this.client.logger.error(`ChannelHandler.load errored at channel.send:\n${err.stack}`));
} }

View File

@ -62,6 +62,10 @@ class ModmailClient extends Client {
process.exit(); process.exit();
}); });
process.on('unhandledRejection', (reason, prom) => {
this.logger.error(`Unhandled promise rejection at: ${prom}\nReason: ${reason}`);
});
this._ready = true; this._ready = true;
} }
@ -106,13 +110,14 @@ class ModmailClient extends Client {
let helpStr = `**${command.name}**\nUsage: ${this.prefix}${command.name} ${command.usage}`; let helpStr = `**${command.name}**\nUsage: ${this.prefix}${command.name} ${command.usage}`;
if (command.aliases) helpStr += `\nAliases: ${command.aliases.join(', ')}`; if (command.aliases) helpStr += `\nAliases: ${command.aliases.join(', ')}`;
return channel.send(helpStr).catch(this.logger.error.bind(this.logger)); return channel.send(helpStr).catch(err => this.client.logger.error(`Client.handleMessage errored at channel.send:\n${err.stack}`));
} }
this.logger.debug(`${message.author.tag} is executing command ${command.name}`); this.logger.debug(`${message.author.tag} is executing command ${command.name}`);
const result = await command.execute(message, { args, clean: message.content.replace(`${this.prefix}${commandName}`, '').trim() }).catch((err) => { const clean = message.content.replace(`${this.prefix}${commandName}`, '').trim();
this.logger.error(`Command ${command.name} errored during execution:\n${err.stack}`); const result = await command.execute(message, { args, clean }).catch((err) => {
this.logger.error(`Command ${command.name} errored during execution:\nARGS: [${args.join(', ')}]\n${err.stack}`);
return { return {
error: true, error: true,
msg: `Command ${command.name} ran into an error during execution. This has been logged.` msg: `Command ${command.name} ran into an error during execution. This has been logged.`
@ -121,9 +126,9 @@ class ModmailClient extends Client {
if (!result) return; if (!result) return;
if (result.error) return channel.send(result.msg).catch(this.logger.error.bind(this.logger)); if (result.error) return channel.send(result.msg).catch(err => this.client.logger.error(`Client.load errored at channel.send:\n${err.stack}`));
else if (result.response) return channel.send(result.response).catch(this.logger.error.bind(this.logger)); else if (result.response) return channel.send(result.response).catch(err => this.client.logger.error(`Client.load errored at channel.send:\n${err.stack}`));
else if (typeof result === 'string') return channel.send(result).catch(this.logger.error.bind(this.logger)); else if (typeof result === 'string') return channel.send(result).catch(err => this.client.logger.error(`Client.load errored at channel.send:\n${err.stack}`));
} }
@ -147,7 +152,7 @@ class ModmailClient extends Client {
if (!channel && author) channel = await author.createDM(); if (!channel && author) channel = await author.createDM();
if (!channel) throw new Error(`Missing channel for prompt, must pass at least author.`); if (!channel) throw new Error(`Missing channel for prompt, must pass at least author.`);
await channel.send(str); await channel.send(str).catch(err => this.client.logger.error(`Client.prompt errored at channel.send:\n${err.stack}`));
return channel.awaitMessages((m) => m.author.id === author.id, { max: 1, time: time || 30000, errors: [ 'time' ] }) return channel.awaitMessages((m) => m.author.id === author.id, { max: 1, time: time || 30000, errors: [ 'time' ] })
.then((collected) => { .then((collected) => {
return collected.first(); return collected.first();

View File

@ -31,12 +31,12 @@ class CannedReply extends Command {
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
for (const [ name, content ] of list) { for (const [ name, content ] of list) {
if (str.length + content.length > 2000) { if (str.length + content.length > 2000) {
await channel.send(str).catch(this.client.logger.error.bind(this.client.logger)); await channel.send(str).catch(err => this.client.logger.error(`CannedReply.execute errored at channel.send:\n${err.stack}`));
str = ''; str = '';
} }
str += `**${name}:** ${content}\n`; str += `**${name}:** ${content}\n`;
} }
if (str.length) return channel.send(str).catch(this.client.logger.error.bind(this.client.logger)); if (str.length) return channel.send(str).catch(err => this.client.logger.error(`CannedReply.execute errored at channel.send:\n${err.stack}`));
return '**__None__**'; return '**__None__**';
} }
return this.client.modmail.sendCannedResponse({ message, responseName: content.trim(), anon }); return this.client.modmail.sendCannedResponse({ message, responseName: content.trim(), anon });