Skip to content

Commit

Permalink
fix(discord): fix DM's not working
Browse files Browse the repository at this point in the history
  • Loading branch information
dsevillamartin committed Feb 17, 2018
1 parent bc7ef63 commit ab54c6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Discord/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/Discord/Modules/UnhandledError.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}
Expand Down

0 comments on commit ab54c6b

Please sign in to comment.