From 97da87e917d0930588852bb48348895b70da9f69 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sun, 4 Apr 2021 11:34:19 -0500 Subject: [PATCH] Move reaction collector location --- index.js | 66 +++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/index.js b/index.js index a170df6..da05940 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,34 @@ client.on("ready", () => { }); client.on("message", async message => { - if (message.author.bot) { + const collector = message.createReactionCollector(filter); + + collector.on('collect', (reaction, user) => { + if (reaction.count === 1) { + const kulboardEmbed = new Discord.MessageEmbed() + .setTitle("Very kül message") + .setURL(message.url) + .setAuthor(message.author ? message.author.tag : "Unknown: click on the link to find out", message.author ? message.author.avatarURL() : client.user.defaultAvatarURL) + .addField("Message", message.content) + .addField("Channel", message.channel) + .setFooter("Message ID: " + message.id) + .setColor("00c5ff") + .setTimestamp(); + collection.findOne({ guild_id: message.guild.id }, (error, result) => { + if (error) { + console.error; + } + if (result.kulboard_id) { + kulboardChannel = result.kulboard_id; + if (message.guild.channels.cache.get(kulboardChannel)) { + message.guild.channels.cache.get(kulboardChannel).send(kulboardEmbed).catch(console.error); + } + } + }); + } + }); + + if (!message.content.startsWith(prefix) || message.author.bot) { return; } @@ -88,6 +115,10 @@ client.on("message", async message => { } else if (message.content.toLowerCase().startsWith(`${prefix}aboutbot`)) { aboutBot(message); } + + const filter = reaction => { + return reaction.emoji.name === '😎'; + }; }); async function aboutBot(message) { @@ -689,39 +720,6 @@ client.on('messageDelete', message => { }); }); -client.on('message', message => { - const filter = reaction => { - return reaction.emoji.name === '😎'; - }; - - const collector = message.createReactionCollector(filter); - - collector.on('collect', (reaction, user) => { - if (reaction.count === 1) { - const kulboardEmbed = new Discord.MessageEmbed() - .setTitle("Very kül message") - .setURL(message.url) - .setAuthor(message.author ? message.author.tag : "Unknown: click on the link to find out", message.author ? message.author.avatarURL() : client.user.defaultAvatarURL) - .addField("Message", message.content) - .addField("Channel", message.channel) - .setFooter("Message ID: " + message.id) - .setColor("00c5ff") - .setTimestamp(); - collection.findOne({ guild_id: message.guild.id }, (error, result) => { - if (error) { - console.error; - } - if (result.kulboard_id) { - kulboardChannel = result.kulboard_id; - if (message.guild.channels.cache.get(kulboardChannel)) { - message.guild.channels.cache.get(kulboardChannel).send(kulboardEmbed).catch(console.error); - } - } - }); - } - }); -}); - client.on('messageDeleteBulk', messages => { const numMessages = messages.array().length; const messagesChannel = messages.array()[0].channel;