Node.js 将自定义表情符号的反应添加到消息中
我可以在我的代码中调整什么,使我能够使用自定义表情对消息做出反应 我试过这个:Node.js 将自定义表情符号的反应添加到消息中,node.js,discord.js,Node.js,Discord.js,我可以在我的代码中调整什么,使我能够使用自定义表情对消息做出反应 我试过这个: let suggestions = message.guild.channels.find("name", "suggestions"); if (message.channel === suggestions) { message.channel.send().then(newMessage => { newMessage.react('<:information :4124
let suggestions = message.guild.channels.find("name", "suggestions");
if (message.channel === suggestions) {
message.channel.send().then(newMessage => {
newMessage.react('<:information :412438127148531723>')
})
}
let suggestions=message.guild.channels.find(“名称”、“建议”);
如果(message.channel==建议){
message.channel.send().then(newMessage=>{
newMessage.react(“”)
})
}
但我收到了错误:
表情符号id:Value“412438127148531723>”不是雪花。
编辑:我没有注意到您试图通过.send()
发送一条空消息,这样做将抛出一个错误。检查“浮躁的哲学家”的答案
由于错误说明emoji\u id:Value“412438127148531723>”不是雪花。
,这表明您试图通过.react()
传递的不是雪花,您有:
newMessage('<:information :412438127148531723>') //here
此外,请记住,只有当机器人本身能够访问表情符号时,这才有效,也就是说,共享具有这些表情符号的服务器;与Discord Nitro的工作方式相同。编辑:我没有注意到您试图通过发送空消息。send()
,这样做将抛出错误。检查“浮躁的哲学家”的答案
由于错误说明emoji\u id:Value“412438127148531723>”不是雪花。
,这表明您试图通过.react()
传递的不是雪花,您有:
newMessage('<:information :412438127148531723>') //here
此外,请记住,只有当机器人本身能够访问表情符号时,这才有效,也就是说,共享具有这些表情符号的服务器;与Discord Nitro的工作方式相同。首先,您不能在没有任何字符串或括号的情况下使用
.send()
。尝试发送如下基本字符串:
message.channel.send('Test message!').then(...)
message.channel.send(...).then(...)
.catch(console.error);
// and later in your code...
newMessage.react(...)
.catch(console.error);
其次,正如@newbie所提到的,你不应该在表情符号id周围放置”
,只要这样做:
// enter your emoji id inside the quotes
newMessage.react('...');
最后,您应该将.catch
语句添加到任何返回承诺的Discord函数中(如.send
或.react
),如下所示:
message.channel.send('Test message!').then(...)
message.channel.send(...).then(...)
.catch(console.error);
// and later in your code...
newMessage.react(...)
.catch(console.error);
因此,要将所有代码放在一起,请执行以下操作:
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);
}
首先,不能在没有任何字符串或括号的情况下使用
.send()
。尝试发送如下基本字符串:
message.channel.send('Test message!').then(...)
message.channel.send(...).then(...)
.catch(console.error);
// and later in your code...
newMessage.react(...)
.catch(console.error);
其次,正如@newbie所提到的,你不应该在表情符号id周围放置”
,只要这样做:
// enter your emoji id inside the quotes
newMessage.react('...');
最后,您应该将.catch
语句添加到任何返回承诺的Discord函数中(如.send
或.react
),如下所示:
message.channel.send('Test message!').then(...)
message.channel.send(...).then(...)
.catch(console.error);
// and later in your code...
newMessage.react(...)
.catch(console.error);
因此,要将所有代码放在一起,请执行以下操作:
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);
}
因为这是你在谷歌上搜索这个问题时的唯一反应,所以我会回答它,即使它已经1年了 表情符号id:Value“412438127148531723>”不是雪花。 最后只需删除>即可
newMessage.react('<:information :412438127148531723')
newMessage.react(“因为这是你在谷歌上搜索这个问题时唯一的回应,所以我会回答它,即使它已经1年了
表情符号id:Value“412438127148531723>”不是雪花。
最后只需删除>即可
newMessage.react('<:information :412438127148531723')
newMessage.react('