From 4f1f672d32e36a3cd2a85557944070f7275e2339 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 4 Sep 2020 18:47:39 +0200 Subject: [PATCH] Fixed some errors Signed-off-by: loicbersier --- event/listeners/commandstarted.js | 3 ++- event/listeners/message.js | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/event/listeners/commandstarted.js b/event/listeners/commandstarted.js index 5c8b9949..9fd3e571 100644 --- a/event/listeners/commandstarted.js +++ b/event/listeners/commandstarted.js @@ -51,10 +51,11 @@ class commandStartedListener extends Listener { if (dailyStats) { if (command.category.id === 'owner') return; // Don't count owner command let obj = { - guild: message.guild.id, command: command.id }; + if (message.guild) obj.guild = message.guild.id; + report.push(obj); let uniqueGuild = []; diff --git a/event/listeners/message.js b/event/listeners/message.js index cbe45bdc..0291d1ae 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -41,8 +41,12 @@ class messageListener extends Listener { */ // Banned words - const bannedWords = await BannedWords.findAll({where: {word: Sequelize.where(Sequelize.fn('LOCATE', Sequelize.col('word'), message.content.replace(/\u200B/g, '').replace(/[\u0250-\ue007]/g, '')), Sequelize.Op.ne, 0), serverID: message.guild.id}}); - const whitelistWord = await WhitelistWord.findAll({where: {word: Sequelize.where(Sequelize.fn('LOCATE', Sequelize.col('word'), message.content.replace(/\u200B/g, '').replace(/[\u0250-\ue007]/g, '')), Sequelize.Op.ne, 0), serverID: message.guild.id}}); + let bannedWords; + let whitelistWord; + if (message.guild) { + bannedWords = await BannedWords.findAll({where: {word: Sequelize.where(Sequelize.fn('LOCATE', Sequelize.col('word'), message.content.replace(/\u200B/g, '').replace(/[\u0250-\ue007]/g, '')), Sequelize.Op.ne, 0), serverID: message.guild.id}}); + whitelistWord = await WhitelistWord.findAll({where: {word: Sequelize.where(Sequelize.fn('LOCATE', Sequelize.col('word'), message.content.replace(/\u200B/g, '').replace(/[\u0250-\ue007]/g, '')), Sequelize.Op.ne, 0), serverID: message.guild.id}}); + } if (whitelistWord[0]) { return; // If word is whitelisted just return