发送消息后如何使机器人不再反应

时间:2020-05-11 20:46:28

标签: javascript node.js discord.js

我希望僵尸程序无法再次反应,当我单击该僵尸程序将发送消息的反应时,问题在于该僵尸程序始终会做出反应

async function emojiMessage(message, validReactions) {
            for (const reaction of validReactions) await message.react(reaction);
        const filter = (reaction, user) => validReactions.includes(reaction.emoji.name) && (!user.bot)

        return message
            .awaitReactions(filter, {
                max: 1,
                time: 10000
            })
            .then(collected => collected.first() && collected.first().emoji.name);
}async function deleteMessage(message) {

    const emoji = await emojiMessage(message, ["❌","✅"]);
    console.log(emoji)
        // if the emoji is a tick:
    if (emoji === "✅") {
        // delete their message
        console.log("tick")
        if (message.deletable == true) {
            console.log("can delete")
            console.log("attempting to delete")
            message.delete()
            message.channel.send("Baik, Kami akan Mengganti Nickname Anda.")
        }
        if (!message.deletable == false) {
            "cannot delete"
        }
    } else if (emoji === "❌") { // if the emoji is a cross
       message.channel.send("Maaf Kami Tidak Bisa Mengubah Nickname Anda.")
        return;
    }
}
music.on('message', message => {

    if (message.channel.id === emojiChannelID) {
        // runs the function
        deleteMessage(message)
    }
})

0 个答案:

没有答案