error handling for failed channel creation

This commit is contained in:
Erik 2022-01-24 22:15:25 +02:00
parent 11b852a6f2
commit f8d20ac2ee
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589
2 changed files with 10 additions and 1 deletions

View File

@ -124,7 +124,16 @@ class ChannelHandler {
if (!channel) { // Create and populate channel if (!channel) { // Create and populate channel
channel = await guild.channels.create(`${user.username}_${user.discriminator}`, { channel = await guild.channels.create(`${user.username}_${user.discriminator}`, {
parent: this.newMail.id parent: this.newMail.id
}).catch(err => {
this.client.logger.warn(`Failed to create channel for ${user.tag}, trying again.\n${err.stack || err}`);
}); });
if (!channel) channel = await guild.channels.create(`${user.id}`, {
parent: this.newMail.id
}).catch(err => {
// this.client.logger.error(`Failed on second create:\n${err.stack || err}`);
return { err };
});
if (!channel.err) return reject(channel.err);
// Start with user info embed // Start with user info embed
const embed = { const embed = {

View File

@ -156,7 +156,7 @@ class Modmail {
const channel = await this.channels.load(member, pastModmail) const channel = await this.channels.load(member, pastModmail)
.catch((err) => { .catch((err) => {
this.client.logger.error(`Error during channel handling:\n${err.stack}`); this.client.logger.error(`Error during channel handling:\n${err.stack || err}`);
return { error: true }; return { error: true };
}); });
if (channel.error) return author.send(`Internal error, this has been logged.`); if (channel.error) return author.send(`Internal error, this has been logged.`);