【发布时间】:2021-02-10 01:46:51
【问题描述】:
抱歉我的英语不好。
我想让角色反应机器人我的问题是我的机器人在重启之前看不到消息发送
我收到了这个代码,但他没有看到对旧消息的反应。
我该怎么做才能让这段代码看到对旧消息的反应。
const Discord = require('discord.js');
const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
client.once('ready', () => {
console.log('Ready!');
});
client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.message.partial) {
try {
await reaction.message.fetch();
}
catch (error) {
console.error('Something went wrong when fetching the message: ', error);
}
}
console.log(`${user.username} reacted with "${reaction.emoji.name}".`);
});
client.on('messageReactionRemove', async (reaction, user) => {
if (reaction.message.partial) {
try {
await reaction.message.fetch();
}
catch (error) {
console.error('Something went wrong when fetching the message: ', error);
}
}
console.log(`${user.username} removed their "${reaction.emoji.name}" reaction.`);
});
client.login('my token');
【问题讨论】:
标签: javascript node.js discord.js