From f8d20ac2eeb3883dd5d63894a2b26a855bce2f22 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Mon, 24 Jan 2022 22:15:25 +0200 Subject: [PATCH] error handling for failed channel creation --- structure/ChannelHandler.js | 9 +++++++++ structure/Modmail.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/structure/ChannelHandler.js b/structure/ChannelHandler.js index 191f02a..2659b1c 100644 --- a/structure/ChannelHandler.js +++ b/structure/ChannelHandler.js @@ -124,7 +124,16 @@ class ChannelHandler { if (!channel) { // Create and populate channel channel = await guild.channels.create(`${user.username}_${user.discriminator}`, { 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 const embed = { diff --git a/structure/Modmail.js b/structure/Modmail.js index 4bd4a69..4d487ec 100644 --- a/structure/Modmail.js +++ b/structure/Modmail.js @@ -156,7 +156,7 @@ class Modmail { const channel = await this.channels.load(member, pastModmail) .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 }; }); if (channel.error) return author.send(`Internal error, this has been logged.`);