From 04b40cec00c21a98b2adbc612858e2d9b239921e Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 28 Feb 2020 14:04:42 -0500 Subject: [PATCH] Only send to owners DMs if report channel fails --- .env.example | 1 - commands/util/report.js | 18 +++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 61bb2328..75750ca4 100644 --- a/.env.example +++ b/.env.example @@ -9,7 +9,6 @@ XIAO_WEBHOOK_TOKEN= POSTER_ID= POSTER_TOKEN= POSTER_TIME= -HOME_GUILD_ID= REPORT_CHANNEL_ID= # Emoji IDs diff --git a/commands/util/report.js b/commands/util/report.js index 4f594733..b9dda372 100644 --- a/commands/util/report.js +++ b/commands/util/report.js @@ -4,7 +4,7 @@ const { list } = require('../../util/Util'); const reasons = ['bug', 'feedback', 'suggestion']; const reasonColors = ['RED', 'GREEN', 'YELLOW']; const displayReasons = ['🐛 Bug Report', '📬 Feedback', '❓ Suggestion']; -const { HOME_GUILD_ID, REPORT_CHANNEL_ID } = process.env; +const { REPORT_CHANNEL_ID } = process.env; module.exports = class ReportCommand extends Command { constructor(client) { @@ -40,14 +40,18 @@ module.exports = class ReportCommand extends Command { .setFooter(`ID: ${msg.author.id}`) .setTimestamp() .setColor(reasonColors[reason]); - if (HOME_GUILD_ID && REPORT_CHANNEL_ID) { - await this.client.guilds.cache.get(HOME_GUILD_ID).channels.cache.get(REPORT_CHANNEL_ID).send({ embed }); - } - for (const owner of this.client.owners) { + if (REPORT_CHANNEL_ID) { try { - await owner.send({ embed }); + const channel = await this.client.channels.fetch(REPORT_CHANNEL_ID); + await channel.send({ embed }); } catch (err) { - continue; + for (const owner of this.client.owners) { + try { + await owner.send({ embed }); + } catch (err) { + continue; + } + } } } return msg.say(`${displayReasons[reason]} sent! Thank you!`);