For the past few days I've been trying to make a command where it reacts to a message with a custom emote. It gives me an error in the console saying this:
TypeError [EMOJI_TYPE]: Emoji must be a string or GuildEmoji/ReactionEmoji
at Message.react (E:\Projects\DiscordBots\node_modules\discord.js\src\structures\Message.js:546:23)
at Client.<anonymous> (E:\Projects\DiscordBots\LordMoth\moth.js:98:17)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (E:\Projects\DiscordBots\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (E:\Projects\DiscordBots\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (E:\Projects\DiscordBots\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (E:\Projects\DiscordBots\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (E:\Projects\DiscordBots\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (E:\Projects\DiscordBots\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20) {
[Symbol(code)]: 'EMOJI_TYPE'
}
I've tried the answers from How Find Emojis By Name In Discord.js and Emoji must be a string or Emoji/ReactionEmoji from getting a custom emote but no luck. I'm also sending the message in a channel from the guild where the emote is from.
My current code:
client.on("message", message => {
if (message.content === "ok") {
const mfi = message.guild.emojis.cache.find(emoji => emoji.name === "MOTHIFEST");
message.react(mfi);
}
});
And another solution I've tried to do with the emote's ID that's actually in the discord.js documentation (https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=react):
client.on("message", message => {
if (message.content === "ok") {
message.react(message.guild.emojis.cache.get("824436212034830356"));
.then(console.log)
.catch(console.error);
}
});
I'm confused so much. Please help me.
mfi
is? – Zsolt Meszarosmessage.guild.emojis.cache.each((e) => console.log(
${e.id}: ${e.name}))
so you could see if the one you're looking for exists. – Zsolt Meszaros