反应后删除消息 |不和谐JS

时间:2021-02-21 12:14:22

标签: javascript npm discord discord.js bots

你好,我发出这个命令:


module.exports = {
    name: "react",
    category: "fun",
    description: "Sends a reaction",
    run: async (client, message, args) => {
        message.react('✅');

    const filter = (reaction, user) => {
        return ['✅'].includes(reaction.emoji.name) && user.id === message.author.id;
    };

    message.awaitReactions(filter, { max: 1, time: 5000, errors: ['time'] })
        .then(collected => {
            const reaction = collected.first();

            if (reaction.emoji.name === '✅') {
                return message.delete();
            }
        })
        .catch(collected => {
            return message.delete();
        });
        }
}

... 删除有关反应的消息。 但我希望,当我的机器人发送消息时,我们可以通过反应删除它

如果有人可以帮助我,那将非常友好!

1 个答案:

答案 0 :(得分:0)

我已经设法像这样完成这项工作

module.exports.run = async(client, message, args) => {
    
message.react('✅');

const filter = (reaction, user) => {
    return ['✅'].includes(reaction.emoji.name) && user.id === message.author.id;
};

message.awaitReactions(filter, { max: 1, time: 5000, errors: ['time'] })
    .then(collected => {
        const reaction = collected.first();

        if (reaction.emoji.name === '✅') {
            return message.delete();
        }
    })
    .catch(collected => {
        return message.delete();
    });
}

module.exports.help = {
    name: "react",
    category: "fun",
    description: "Sends a reaction",
}