From ab54c6b8063da8ac15f60894c420d2069ccccda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sevilla=20Mart=C3=ADn?= Date: Sat, 17 Feb 2018 09:38:59 -0500 Subject: [PATCH] fix(discord): fix DM's not working --- lib/Discord/Client.js | 4 ++-- lib/Discord/Modules/UnhandledError.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Discord/Client.js b/lib/Discord/Client.js index 72dbd4f..711a4f4 100644 --- a/lib/Discord/Client.js +++ b/lib/Discord/Client.js @@ -184,8 +184,8 @@ class Client extends DiscordClient { */ async execute(msg) { if (msg.author.equals(this.user) || msg.author.bot) return; - const serverConf = msg.guild.available ? ServerConfig.get(msg.guild.id) : await ServerConfig.add(msg.guild); - const prefix = serverConf.prefix || Math.random(); + const serverConf = msg.guild && msg.guild.available ? ServerConfig.get(msg.guild.id) || await ServerConfig.add(msg.guild) : null; + const prefix = serverConf ? serverConf.prefix : Math.random(); if (msg.channel.type !== 'dm' && !msg.content.startsWith(this.user.toString()) && !msg.content.startsWith(prefix) && !msg.content.startsWith(this.prefix)) return false; const content = (msg.content.startsWith(prefix) && msg.content.replace(prefix, '')) || (msg.content.startsWith(this.user.toString()) && msg.content.replace(`${this.user.toString()} `, '')) || (msg.content.startsWith(this.prefix) && msg.content.replace(this.prefix, '')) || msg.content; diff --git a/lib/Discord/Modules/UnhandledError.js b/lib/Discord/Modules/UnhandledError.js index 8a71cae..9cec228 100644 --- a/lib/Discord/Modules/UnhandledError.js +++ b/lib/Discord/Modules/UnhandledError.js @@ -6,6 +6,8 @@ class UnhandledErrorModule extends Module { let embed = this.textToEmbed(`Yappy, the GitLab Monitor - Unhandled Error: \`${middleware ? middleware.constructor.name : msg.cleanContent}\``, '', '#CE0814'); if (typeof error === 'string') embed.setDescription(error); + Log.error(error); + return msg.channel.send({ embed }); } }