From 10f2be27ef197365c9fdbf29760dc105ed7d5f03 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 8 May 2020 01:26:09 +0200 Subject: [PATCH] Fixed the ability to unblacklist Signed-off-by: loicbersier --- commands/admin/bye.js | 2 +- commands/admin/log.js | 2 +- commands/admin/tag.js | 4 ++-- commands/admin/welcome.js | 2 +- commands/owner/addResponse.js | 2 +- commands/owner/blacklist.js | 8 +++++--- commands/owner/serverblacklist.js | 2 +- commands/owner/twitterBlacklist.js | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/commands/admin/bye.js b/commands/admin/bye.js index 7e4c5bbd..877ac5f7 100644 --- a/commands/admin/bye.js +++ b/commands/admin/bye.js @@ -56,7 +56,7 @@ class byeCommand extends Command { message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] }) .then(async messages => { let messageContent = messages.map(messages => messages.content); - if (messageContent == 'y' || messageContent == 'yes') { + if (messageContent[0] === 'y' || messageContent[0] === 'yes') { const body = {guildID: message.guild.id, channelID: message.channel.id, message: args.message}; await leaveChannel.update(body, {where: {guildID: message.guild.id}}); return message.channel.send(`The leave message have been set with ${args.message}`); diff --git a/commands/admin/log.js b/commands/admin/log.js index dc4ff1d7..03bfb9be 100644 --- a/commands/admin/log.js +++ b/commands/admin/log.js @@ -30,7 +30,7 @@ class logCommand extends Command { message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] }) .then(async messages => { let messageContent = messages.map(messages => messages.content.toLowerCase()); - if (messageContent == 'y' || messageContent == 'yes') { + if (messageContent[0] === 'y' || messageContent[0] === 'yes') { await LogStats.destroy({where: {guild: message.guild.id}}); return message.channel.send('Log channel has been disabled!'); } else { diff --git a/commands/admin/tag.js b/commands/admin/tag.js index 9366a306..c8ee6212 100644 --- a/commands/admin/tag.js +++ b/commands/admin/tag.js @@ -49,7 +49,7 @@ class TagCommand extends Command { return message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] }) .then(async messages => { let messageContent = messages.map(messages => messages.content.toLowerCase()); - if (messageContent == 'y' || messageContent == 'yes') { + if (messageContent[0] === 'y' || messageContent[0] === 'yes') { Tag.destroy({where: {serverID: message.guild.id}}); return message.channel.send('Tags have been reset.'); } else { @@ -93,7 +93,7 @@ class TagCommand extends Command { message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] }) .then(async messages => { let messageContent = messages.map(messages => messages.content.toLowerCase()); - if (messageContent == 'y' || messageContent == 'yes') { + if (messageContent[0] === 'y' || messageContent[0] === 'yes') { const body = {trigger: args.trigger, response: args.response, ownerID: message.author.id, serverID: message.guild.id}; await Tag.update(body, {where: {trigger: args.trigger, serverID: message.guild.id}}); return message.channel.send(`tag have been set to ${args.trigger} : ${args.response}`); diff --git a/commands/admin/welcome.js b/commands/admin/welcome.js index 167ed81e..aae9e52d 100644 --- a/commands/admin/welcome.js +++ b/commands/admin/welcome.js @@ -55,7 +55,7 @@ class welcomeCommand extends Command { message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] }) .then(async messages => { let messageContent = messages.map(messages => messages.content); - if (messageContent == 'y' || messageContent == 'yes') { + if (messageContent[0] === 'y' || messageContent[0] === 'yes') { const body = {guildID: message.guild.id, channelID: message.channel.id, message: args.message}; await joinChannel.update(body, {where: {guildID: message.guild.id}}); return message.channel.send(`The join message have been set with ${args.message}`); diff --git a/commands/owner/addResponse.js b/commands/owner/addResponse.js index 32b76f27..2900159f 100644 --- a/commands/owner/addResponse.js +++ b/commands/owner/addResponse.js @@ -53,7 +53,7 @@ class addResponseCommand extends Command { message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] }) .then(messages => { let messageContent = messages.map(messages => messages.content); - if (messageContent == 'y' || messageContent == 'yes') { + if (messageContent[0] === 'y' || messageContent[0] === 'yes') { const body = {trigger: args.trigger, response: args.response, type: args.type}; autoResponse.update(body, {where: {trigger: args.trigger}}); return message.channel.send(`autoresponse have been set to ${args.trigger} : ${args.response} with type: ${args.type}`); diff --git a/commands/owner/blacklist.js b/commands/owner/blacklist.js index 0d55ff64..d1be3ab9 100644 --- a/commands/owner/blacklist.js +++ b/commands/owner/blacklist.js @@ -32,16 +32,18 @@ class blacklistCommand extends Command { if (!blacklist) { const body = {userID: args.userID}; userBlacklist.create(body); - return message.channel.send(`The following user have been blacklisted: ${this.client.users.resolve(args.userID).tag} (${args.userID})`); + return message.channel.send(`The following ID have been blacklisted: ${args.userID}`); } else { message.channel.send('This user is already blacklisted, do you want to unblacklist him? y/n'); const filter = m => m.content && m.author.id === message.author.id; message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] }) .then(messages => { + console.log(messages); let messageContent = messages.map(messages => messages.content); - if (messageContent === 'y' || messageContent === 'yes') { + console.log(messageContent); + if (messageContent[0] === 'y' || messageContent[0] === 'yes') { userBlacklist.destroy({where: {userID:args.userID}}); - return message.channel.send(`The following user have been unblacklisted: ${this.client.users.resolve(args.userID).tag} (${args.userID})`); + return message.channel.send(`The following ID have been unblacklisted: ${args.userID}`); } }) .catch(err => { diff --git a/commands/owner/serverblacklist.js b/commands/owner/serverblacklist.js index 7d62c9f5..0ac5be83 100644 --- a/commands/owner/serverblacklist.js +++ b/commands/owner/serverblacklist.js @@ -39,7 +39,7 @@ class serverBlacklistCommand extends Command { message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] }) .then(messages => { let messageContent = messages.map(messages => messages.content); - if (messageContent == 'y' || messageContent == 'yes') { + if (messageContent[0] === 'y' || messageContent[0] === 'yes') { guildBlacklist.destroy({where: {guildID:args.guildID}}); return message.channel.send(`The guild with the following id have been unblacklisted: ${args.guildID}`); } diff --git a/commands/owner/twitterBlacklist.js b/commands/owner/twitterBlacklist.js index 83295ab3..ab8e42da 100644 --- a/commands/owner/twitterBlacklist.js +++ b/commands/owner/twitterBlacklist.js @@ -48,7 +48,7 @@ class TwitterBlacklistCommand extends Command { message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] }) .then(messages => { let messageContent = messages.map(messages => messages.content); - if (messageContent == 'y' || messageContent == 'yes') { + if (messageContent[0] === 'y' || messageContent[0] === 'yes') { TwitterBlacklist.destroy({where: {userID:args.userID}}); return message.channel.send(`The user with the following id have been unblacklisted: ${args.userID}`); }