Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用Discord.js中的反应让用户回答问题?_Javascript_Node.js_Discord_Discord.js - Fatal编程技术网

Javascript 如何使用Discord.js中的反应让用户回答问题?

Javascript 如何使用Discord.js中的反应让用户回答问题?,javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,我希望用户使用反应回答“是或否”问题。下面是我的代码 var emojiArray = ['you should use a ReactionCollector: var emojiArray = ['First of all, you kinda messed up while getting the user object of the mentioned user, so just so you know it's negotiate.mentions.users.first()! Whi

我希望用户使用反应回答“是或否”问题。下面是我的代码

var emojiArray = ['you should use a 
ReactionCollector
:

var emojiArray = ['First of all, you kinda messed up while getting the user object of the mentioned user, so just so you know it's 
negotiate.mentions.users.first()
!

While wanting to request user input through reactions, we'd usually want to use either one of the following:

  • awaitReactions()
  • createReactionCollector
Since I personally prefer
awaitReactions()
, here's a quick explanation on how to use it:

awaitReactions is a
message
object extension and creates a reaction collector over the message that we pick. In addition, this feature also comes with the option of adding a filter to it. Here's the filter I usually like to use:

const filter = (reaction, user) => {
   return emojiArray.includes(reaction.emoji.name) && user.id === mention.id;
   // The first thing we wanna do is make sure the reaction is one of our desired emojis!
   // The second thing we wanna do is make sure the user who reacted is the mentioned user.
};

var emojiArray=[”您应该使用
ReactionCollector


var emojiArray=[”您应该使用
ReactionCollector


var emojiArray=[”首先,您在获取所提到用户的用户对象时有点搞砸了,所以您知道这是
agreement.intriends.users.First()

虽然希望通过反应请求用户输入,但我们通常希望使用以下任一选项:

  • ()
  • createReactionCollector
因为我个人更喜欢
waitingreactions()
,这里有一个关于如何使用它的快速说明:

awaitReactions是一个
消息
对象扩展,在我们选择的消息上创建一个反应收集器。此外,此功能还附带向其添加筛选器的选项。以下是我通常喜欢使用的筛选器:

从那时起,我们可以非常简单地在
awaitReactions()
函数中实现我们的过滤器,如下所示:

message.com(过滤器、{
max:1,//只接受一个反应
时间:30000,//30秒后将不工作
错误:['time']//如果使用.catch()将显示错误
})
.then(collected=>{//用户作出反应的反应对象
const reaction=收集的.first();
//这里是您的代码!您现在可以使用'reaction'变量来检查某些if语句,例如:

如果(reaction.emoji.name==='首先,您在获取提到的用户的用户对象时有点搞砸了,所以您只需知道它是
协商.提及.users.First()

虽然希望通过反应请求用户输入,但我们通常希望使用以下任一选项:

  • ()
  • createReactionCollector
因为我个人更喜欢
waitingreactions()
,这里有一个关于如何使用它的快速说明:

awaitReactions是一个
消息
对象扩展,在我们选择的消息上创建一个反应收集器。此外,此功能还附带向其添加筛选器的选项。以下是我通常喜欢使用的筛选器:

从那时起,我们可以非常简单地在
awaitReactions()
函数中实现我们的过滤器,如下所示:

message.com(过滤器、{
max:1,//只接受一个反应
时间:30000,//30秒后将不工作
错误:['time']//如果使用.catch()将显示错误
})
.then(collected=>{//用户作出反应的反应对象
const reaction=收集的.first();
//这里是您的代码!您现在可以使用'reaction'变量来检查某些if语句,例如:

如果(reaction.emoji.name==”,则此代码不显示所述用户单击反应后是否可以协商。此代码不显示所述用户单击反应后是否可以协商。