Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
209 views
in Technique[技术] by (71.8m points)

javascript - 等待其他用户的反应(Await reaction by a different user)

I'm making a verification system that if you send a message.

(我正在建立一个验证系统,如果您发送消息。)

In a different channel, an embed shows up with 2 emoji's: 1 to accept, and 1 to deny.

(在不同的频道中,嵌入会显示2种表情符号:1表示接受,1表示拒绝。)

The .awaitReaction has to be triggered by a different user then the author.

(.awaitReaction必须由不同于作者的其他用户触发。)

But when I change the filter.

(但是当我更换过滤器时。)

It triggers the message if the bot reacts to it.

(如果机器人对此作出反应,它将触发该消息。)

How can I fix this?

(我怎样才能解决这个问题?)

Here is my code:

(这是我的代码:)

    let register = args.join(" ").slice(7)

const filter = (reaction, user) => ["?", "?"].includes(reaction.emoji.name) && !bot.user;

let test = new Discord.RichEmbed()
.addField("User:", message.author.username && message.author.tag, true)
.addField("Requested nickname:", register)
.setColor("#ed0c75")
.setImage(message.author.displayAvatarURL)

let acceptordeny = message.guild.channels.find(`name`, "accept-or-deny");
if(!acceptordeny) return message.channel.send("Can't find accept or deny channel.");

acceptordeny.send(test).then(async message => {

    await message.react("?")
    await message.react("?")

    message.awaitReactions(filter, {
        max: 1,
        time: 60000,
        errors: ["time"]
    }).then(collected => {

        const reaction = collected.first();

        switch (reaction.emoji.name) {
            case "?":
                console.log("Accepted")
                break;
            case '?':
                console.log("Denied")
                break;
        }
    }).catch(collected => {
        return acceptordeny.send("Failed")
    })
})

Hope someone can help me with this.

(希望有人可以帮助我。)

  ask by Kieran Julien translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...