better error logging

This commit is contained in:
Erik 2021-11-28 19:31:17 +02:00
parent 944dd95936
commit 3279d69ed3
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589

View File

@ -225,7 +225,7 @@ class Modmail {
this.log({ author, action: `${author.tag} replied to ${targetMember.user.tag}`, content, target: targetMember.user }); this.log({ author, action: `${author.tag} replied to ${targetMember.user.tag}`, content, target: targetMember.user });
await message.delete().catch(this.client.logger.warn.bind(this.client.logger)); await message.delete().catch(this.client.logger.warn.bind(this.client.logger));
return this.send({ target: targetMember, staff: member, content, anon }); return this.send({ target: targetMember, staff: member, content, anon }).catch((err) => this.client.logger.error(`Error during Modmail.send:\n${err.stack}`));
} }
@ -241,11 +241,11 @@ class Modmail {
const { member: staff, author } = message; const { member: staff, author } = message;
// Send to channel in server & target // Send to channel in server & target
const sent = await this.send({ target: targetMember, staff, anon, content }); const sent = await this.send({ target: targetMember, staff, anon, content }).catch((err) => this.client.logger.error(`Error during Modmail.sendModmail:\n${err.stack}`));
if (sent.error) return sent; if (sent.error) return sent;
// Inline response // Inline response
await message.channel.send('Delivered.').catch(this.client.logger.error.bind(this.client.logger)); await message.channel.send('Delivered.').catch((err) => this.client.logger.error(`Error during Modmail.sendModmail:\n${err.stack}`));
this.log({ author, action: `${author.tag} sent a message to ${targetMember.user.tag}`, content, target: targetMember.user }); this.log({ author, action: `${author.tag} sent a message to ${targetMember.user.tag}`, content, target: targetMember.user });
} }
@ -367,7 +367,7 @@ class Modmail {
const str = `${amount} modmail in queue.`; const str = `${amount} modmail in queue.`;
this.client.logger.debug(`Sending modmail reminder, #mm: ${amount}`); this.client.logger.debug(`Sending modmail reminder, #mm: ${amount}`);
if (this.lastReminder) { if (this.lastReminder) {
if (channel.lastMessage.id === this.lastReminder.id) return this.lastReminder.edit(str); if (channel.lastMessage?.id === this.lastReminder?.id) return this.lastReminder.edit(str);
await this.lastReminder.delete(); await this.lastReminder.delete();
} }
this.lastReminder = await channel.send(str); this.lastReminder = await channel.send(str);
@ -392,7 +392,7 @@ class Modmail {
}; };
} }
this.logChannel.send({ embed }).catch(this.client.logger.error.bind(this.client.logger)); this.logChannel.send({ embed }).catch((err) => this.client.logger.error(`Error during logging of modmail:\n${err.stack}`));
} }