将自定义表情符号的反应添加到消息中 [英] Add reaction of custom emoji to a message

查看:89
本文介绍了将自定义表情符号的反应添加到消息中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在代码中进行哪些调整,使我可以使用自定义表情符号来响应消息?

What can I tweak in my code that will allow me to use custom emojis to react to a message?

我已经尝试过:

 let suggestions = message.guild.channels.find("name", "suggestions");
  if (message.channel === suggestions) {
    message.channel.send().then(newMessage => {
       newMessage.react('<:information :412438127148531723>')
   })
  }

但我收到错误消息:


emoji_id:值 412438127148531723>不是雪花。


推荐答案

编辑:我没有注意到您试图通过 .send(),这样做会引发错误。请检查@Blundering哲学家的答案。

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.

由于错误指出 emoji_id:值 412438127148531723>不是雪花。,表明您试图通过 .react()传递的不是雪花的东西:

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

作为文档指出 Emoji id 是< a href = https://discord.js.org/#/docs/main/stable/typedef/Snowflake rel = nofollow noreferrer>雪花。

因此,您需要通过传递 Emoji id 。 react(); ,因此只需替换以下行: newMessage.react('<:information:412438127148531723>'),并替换为: newMessage.react('412438127148531723')

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')
   })
  }

此外,请记住,这只会起作用如果机器人本身可以访问表情符号,即-共享具有这些表情符号的服务器;与Discord Nitro的工作方式相同。

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.

这篇关于将自定义表情符号的反应添加到消息中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆