【问题标题】:How to tell a user its not their turn when clicking button interaction discord.js单击按钮交互discord.js时如何告诉用户轮到他们了
【发布时间】:2021-10-28 06:09:41
【问题描述】:

这就是我所拥有的,一个简单的过滤器,用于过滤组件收集器中应允许的用户。 这就是我在逻辑上会做的事情,检查 id 是否相等,但是当过滤器只允许用户 id 进入时我该怎么做?

如果我在过滤器中传递两个 id,它将允许两个用户在轮到他们时点击。

任何答案都会有所帮助!谢谢

const filter = (button) => {
          button.deferUpdate()
          return button.user.id === info.userid;
}
collector.on('collect', b => {
if (b.user.id !== info.userid) //reply and tell them its not their turn
}

【问题讨论】:

    标签: javascript discord discord.js discord-buttons


    【解决方案1】:

    您可以使用 ephemeral 属性向用户发送消息。只有他们才能看到该消息。

    discord.js: ButtonInteraction.reply()

    例如:

    collector.on('collect', b => {
        if (b.user.id !== info.userid) {
            b.reply({content: "It's not your turn", ephemeral: true})
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 2020-11-21
      • 2018-12-21
      • 1970-01-01
      • 2019-02-24
      • 1970-01-01
      相关资源
      最近更新 更多