需要一个discord bot来要求用户在discord.js中进行多个输入

时间:2020-05-01 18:38:22

标签: node.js discord discord.js

我正在为不和谐的bot开发一条命令,该命令将逐步指导用户创建嵌入式消息。

此配置包含几个步骤,因此该机器人将要求用户输入一些输入,一个接一个地输入,例如标题,描述,字段等。

机器人:要求输入1。 用户:用输入1回答。

机器人:要求输入2。 用户:用输入2回答。

机器人:要求输入3。 用户:跳过。

机器人:要求输入4。 用户:用输入4回答。

我尝试使用messageCollector:

if (message.content.startsWith(`${prefix}embed`)) {
  // first part of the code here

  // then, wait for user's input
  const collectorTitle = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, { time: 10000 });
  collectorTitle.on('collect', message => {
    // save title or skip
  });

  // wait for second user's input
  const collectorDescription = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, { time: 10000 });
  collectorDescription.on('collect', message => {
    // save description or skip
  });

  // rest of the inputs
}

但这仅适用于第一个输入。我还没有找到停止第一个收集器并继续进行下一部分代码的方法。

我尝试使用if条件停止第一个messageCollector,试图将一个放置在收集器之前,将一个放置在收集器之后,但是代码始终卡在该messageCollector上,并且不会继续。

0 个答案:

没有答案