我一直在尝试通过命令让我的机器人对表情符号做出反应以更改嵌入的消息,但我无法更改消息,因为我收到了一些我不明白的错误:>
TypeError: message.clearReactions is not a function
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
module.exports = class TestCommand extends Command {
constructor(client) {
super(client, {
name: 'test',
group: 'asd',
memberName: 'test',
description: 'hehe',
throttling: {
usages: 1,
duration: 5
}
});
}
async run(message, args) {
const prefix = message.guild ? message.guild.commandPrefix : this.client.commandPrefix;
const embed = new MessageEmbed()
.setTitle('Messaged testing')
.setColor("#5d62ff")
.setDescription('Test embed')
.setTimestamp();
message.channel.send(embed)
.then(message => {
message.react('➡️');
const filter = (reaction, user) => reaction.emoji.name === '➡️' && user.id === message.author.id;
const collector = message.createReactionCollector(filter, {time: 1500 });
collector.on('collect', () => {
message.clearReactions();
const embed = new MessageEmbed()
.setColor('#007FFF')
.setDescription('Test #2');
message.channel.edit(embed);
});
})
.catch(err => console.error(err));
}
};
答案 0 :(得分:0)
如果您使用的是 discord.js v12,则不能再使用 message.clearReactions
。您需要使用 message.reactions.removeAll()
。您可以check the docs参考。
const collector = message.createReactionCollector(filter, {time: 1500 });
collector.on('collect', () => {
message.reactions.removeAll();
// ...