2022-09-27 16:45:50 -04:00
|
|
|
//NOTE: THIS FUNCTION REQUIRES REPLIES, AND I CAN'T FIGURE OUT HOW TO LINK THEM TO SLASH COMMANDS
|
|
|
|
|
|
2022-05-13 22:03:05 +03:00
|
|
|
module.exports = {
|
2022-05-19 21:31:40 +03:00
|
|
|
name: 'react',
|
2022-05-13 22:03:05 +03:00
|
|
|
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
|
|
|
|
2022-09-27 16:45:50 -04:00
|
|
|
try {
|
|
|
|
|
let emoji = [...new Set(args[0])];
|
|
|
|
|
if (emoji.length > 15 /*|| message.IndexOf(":") != -1*/) { return message.reply("Please enter less than 15 emojis"); }
|
|
|
|
|
let notused = new Array(15);
|
|
|
|
|
let counter = 0;
|
2022-05-14 14:57:06 +03:00
|
|
|
|
2022-09-27 16:45:50 -04:00
|
|
|
for (let i = 0; i < emoji.length; i ++) {
|
|
|
|
|
try {
|
|
|
|
|
await msg.react(emoji[i]);
|
|
|
|
|
} catch(err) {
|
|
|
|
|
//The emoji wasn't a valid one
|
|
|
|
|
notused[counter] = emoji[i];
|
|
|
|
|
counter ++;
|
|
|
|
|
}
|
2022-05-14 14:57:06 +03:00
|
|
|
}
|
|
|
|
|
|
2022-09-27 16:45:50 -04:00
|
|
|
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");
|
|
|
|
|
}
|
2022-05-13 22:03:05 +03:00
|
|
|
}
|
2022-09-27 16:45:50 -04:00
|
|
|
} catch (err) {
|
|
|
|
|
console.log(err);
|
|
|
|
|
return message.reply("Uh oh, there's been an error");
|
2022-05-13 22:03:05 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|