I’m working on a react command to make the bot react to the given message ID, but the problem is that it works fine if it’s an emoji, but if it’s not an emoji, it says Please use a valid emoji!
and then says Reacted with (emoji)
, despite the fact that I made the catch function return after saying Please use a valid emoji!
, so I’m pretty confused, is there any way around it?
The code:
const { MessageEmbed } = require('discord.js')
module.exports = {
name: 'react',
category: 'Staff',
aliases: [],
description: 'Reacts to a message.',
usage: 'react <messageID> <emoji>',
userperms: [],
botperms: [],
run: async (client, message, args) => {
if (message.author.bot) return;
let emoji = args[1];
let messageID = args[0];
if (!messageID) return message.reply('Please state the messageID!')
if (!emoji) return message.reply('Please state the emoji')
if (messageID && emoji) {
message.channel.messages.fetch(messageID)
.catch(err => {
if (err.code === 10008){
message.channel.send('I cannot find this message!');
return;
}
if (err.code === 50035){
message.channel.send('Please state a valid Message ID!');
return;
}
});
message.channel.messages.fetch(messageID)
.then(msg => {
msg.react(emoji)
.catch(() => {
message.channel.send('Please use a valid emoji!')
return
})
setTimeout(function(){
message.channel.send('Please wait...').then(m =>
setTimeout(function(){
m.edit('Reacted with ' + emoji)
return
}, 1500)
)
}, 2000)
})
}
}
}
Thanks 😀