问题
What can I tweak in my code that will allow me to use custom emojis to react to a message?
I have tried this:
let suggestions = message.guild.channels.find("name", "suggestions");
if (message.channel === suggestions) {
message.channel.send().then(newMessage => {
newMessage.react('<:information :412438127148531723>')
})
}
But I receive the error:
emoji_id: Value "412438127148531723>" is not snowflake.
回答1:
EDIT: I didn't notice that you were trying to send an empty message via .send(), doing this will throw an error. Check @Blundering Philosopher's answer.
As the error states emoji_id: Value "412438127148531723>" is not snowflake., that is indicated that you tried to pass something through the .react() that wasn't a snowflake which you have:
newMessage('<:information :412438127148531723>') //here
As the docs state the Emoji's id is a type of snowflake.
So, you need to pass the Emoji's id through the .react();, so simply replace this line: newMessage.react('<:information :412438127148531723>'), with this: newMessage.react('412438127148531723')
So your code should look like this as a result:
let suggestions = message.guild.channels.find("name", "suggestions");
if (message.channel === suggestions) {
message.channel.send('your message').then(newMessage => {
newMessage.react('412438127148531723')
})
}
Also, keep in mind that this will only work if the bot itself has access to the emoji, i.e - shares a server that has these emojis; the same way that Discord Nitro works.
回答2:
First, you cannot use .send() without any string or StringResolvable in the parenthesis. Try sending a basic string like this:
message.channel.send('Test message!').then(...)
Second, as @newbie mentioned, you shouldn't put '<:information... :>' around the emoji id, just do this:
// enter your emoji id inside the quotes
newMessage.react('...');
Finally, you should add .catch statements to any Discord function that returns a promise (like .send or .react) like this:
message.channel.send(...).then(...)
.catch(console.error);
// and later in your code...
newMessage.react(...)
.catch(console.error);
So to put all of your code together, do this:
let suggestions = message.guild.channels.find("name", "suggestions");
if (message.channel === suggestions) {
// (send some text to channel)
message.channel.send('Test message!').then(newMessage => {
// (add your emoji id inside quotes -> probably '412438127148531723'
newMessage.react('...')
// (catch errors)
.catch(console.error);
})
// (catch errors)
.catch(console.error);
}
回答3:
Since this is the only response when you search this problem on google i'll answer it even if its 1 year old.
emoji_id: Value "412438127148531723>" is not snowflake.
Just remove the > in the end so it is
newMessage.react('<:information :412438127148531723')
Worked for me. Hope it helps if someone is googling the same problem
来源:https://stackoverflow.com/questions/48759006/add-reaction-of-custom-emoji-to-a-message