Files
selmerBot/commands/misc/react.js
T

38 lines
1.3 KiB
JavaScript
Raw Normal View History

module.exports = {
2022-05-19 21:31:40 +03:00
name: 'react',
description: "Reacts with a phrase or single emoji",
async execute(message, args, Discord, Client, bot) {
// if (!message.reference) { return; }
let msg;
if (message.reference) {
msg = await message.channel.messages.fetch(message.reference.messageId);
} else { msg = message; }
2022-05-19 21:31:40 +03:00
//Get rid of any custom emojis
console.log("IMPLEMENT THIS");
2022-05-14 14:57:06 +03:00
let emoji = [...new Set(args[0])];
2022-05-19 21:31:40 +03:00
if (emoji.length > 15 || message.IndexOf(":") != -1) { return message.reply("Please enter less than 15 emojis"); }
2022-05-14 14:57:06 +03:00
let notused = new Array(15);
let counter = 0;
for (let i = 0; i < emoji.length; i ++) {
2022-05-19 21:31:40 +03:00
try {
2022-05-14 14:57:06 +03:00
await msg.react(emoji[i]);
} catch(err) {
//The emoji wasn't a valid one
2022-05-14 14:57:06 +03:00
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");
}
}
}
}