diff --git a/squad-server/plugins/discord-base-plugin.js b/squad-server/plugins/discord-base-plugin.js index 46e5ad1..65c5883 100644 --- a/squad-server/plugins/discord-base-plugin.js +++ b/squad-server/plugins/discord-base-plugin.js @@ -15,10 +15,21 @@ export default class DiscordBasePlugin extends BasePlugin { } async prepareToMount() { - this.channel = await this.options.discordClient.channels.fetch(this.options.channelID); + try { + this.channel = await this.options.discordClient.channels.fetch(this.options.channelID); + } catch (error) { + this.channel = null; + this.verbose(1, `Could not fetch Discord channel with channelID "${this.options.channelID}". Error: ${error.message}`); + this.verbose(2, `${error.stack}`); + } } async sendDiscordMessage(message) { + if (!this.channel) { + this.verbose(1, `Could not send Discord Message. Channel not initialized.`) + return; + } + if (typeof message === 'object' && 'embed' in message) message.embed.footer = message.embed.footer || { text: COPYRIGHT_MESSAGE };