From 44d65fce987e055ee11600859b2911b561a25f40 Mon Sep 17 00:00:00 2001 From: ION606 Date: Sat, 14 May 2022 14:57:06 +0300 Subject: [PATCH] Added the 'react' command --- commands/anime/search.js | 2 +- commands/misc/reactions.js | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/commands/anime/search.js b/commands/anime/search.js index 860cad3..4504086 100644 --- a/commands/anime/search.js +++ b/commands/anime/search.js @@ -9,7 +9,7 @@ module.exports = { let s = `Title: ${s.title}\n`; s += `` } else if (args[0] != 'full') { - + } else { } diff --git a/commands/misc/reactions.js b/commands/misc/reactions.js index d970acf..d5d6d0a 100644 --- a/commands/misc/reactions.js +++ b/commands/misc/reactions.js @@ -9,12 +9,27 @@ module.exports = { msg = await message.channel.messages.fetch(message.reference.messageId); } else { msg = message; } - for (let i = 0; i < args.length; i ++) { + let emoji = [...new Set(args[0])]; + if (emoji.length > 15) { return message.reply("Please enter less than 15 emojis"); } + let notused = new Array(15); + let counter = 0; + + for (let i = 0; i < emoji.length; i ++) { try { - await msg.react(args[i]); + await msg.react(emoji[i]); } catch(err) { //The emoji wasn't a valid one - message.reply("Please enter a valid emoji"); + notused[counter] = emoji[i]; + counter ++; + } + } + + if (notused.length > 0) { + notused = notused.filter(element => element !== undefined); + if (notused.length > 1) { + message.reply("These are not valid reaction emoji(s): " + notused.toString()); + } else { + message.reply(notused.toString() + " is not a valid reaction emoji"); } } }