diff --git a/event/listeners/commandstarted.js b/event/listeners/commandstarted.js index 5c8b994..9fd3e57 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 cbe45bd..0291d1a 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