简体   繁体   English

awaitMessages 在 Discord.js v13 中不起作用

[英]awaitMessages doesn't works in Discord.js v13

I recently updated my bot to v13, but all commands that use awaitMessages doesn't work anymore.我最近将我的机器人更新到 v13,但是所有使用 awaitMessages 的命令都不再起作用了。 Here my code:这是我的代码:

    if (hasPermission == true) {
      let firstEmbed = new Discord.MessageEmbed()
        .setTitle("Passaggio 1 (Grado di completamento: 0%)")
        .setColor("#b50000")
        .setDescription(
          "*Primo passaggio*, manda la **descrizione** del server con cui stai facendo partnership."
        )
        .setFooter("Tempo: 5 minuti");
        message.channel.send({embeds: [firstEmbed]}).then(() => {
        message.channel.awaitMessages((m) => m.author.id == message.author.id, {
            max: 1,
            time: 300000,
            errors: ['time']
          })
          .then((description) => {
            console.log("test 3")
            if (description.first().content.length > 1999) {
              return message.channel.send(
                "Errore! La descrizione è troppo lunga!"
              );
            }
            let descriptionToClean = description.first().content;
            let cleanDesc = cleanDescription(descriptionToClean);
            let secondEmbed = new Discord.MessageEmbed()
              .setTitle("Passaggio 2 (Grado di completamento: 33%)")
              .setColor("#d4750f")
              .setDescription(
                "*Secondo passaggio*, manda qui sotto l'ID del **gestore dell'altro server**, con cui stai facendo partner.\nTieni presente che il gestore deve essere in tutti i server della catena di cui fai parte.\nSe non vuoi mandare l'ID o non funziona il bot, scrivi `skip`."
              )
              .setFooter("Tempo: 5 minuti");
              message.channel.send({embeds: [secondEmbed]}).then(() => {
              message.channel
                .awaitMessages((m) => m.author.id == message.author.id, {
                  max: 1,
                  time: 300000,
                })
                .then((partnerManager) => {
                  let gestore;
                  let skip = false;
                  if(partnerManager.first().content.toLowerCase() == "skip") skip = true;
                  if(partnerManager.first().content) gestore = partnerManager.first().content;
                  let isIn = CheckIfManagerIsInServer(
                    client,
                    message.guild.id,
                    gestore
                  );

(note that this isn't the complete code, and I'm sure that not run only after the first awaitMessages) I think that the problem is this: awaitMessages doesn't collect any data. (请注意,这不是完整的代码,我确信它不会仅在第一个 awaitMessages 之后运行)我认为问题在于:awaitMessages 不收集任何数据。 等待消息示例

After message.channel.awaitMessages(), the code doesn't run.在 message.channel.awaitMessages() 之后,代码没有运行。 Someone can tell me why?有人可以告诉我为什么吗? Thanks in advance and sorry for bad english!在此先感谢,抱歉英语不好!

awaitMessages doesn't take multiple parameters. awaitMessages不接受多个参数。

Exerpt from the API docs摘自 API 文档

.awaitMessages([options]) .awaitMessages([选项])

// Await !vote messages
const filter = m => m.content.startsWith('!vote');
// Errors: ['time'] treats ending because of the time limit as an error
channel.awaitMessages({ filter, max: 4, time: 60_000, errors: ['time'] })
  .then(collected => console.log(collected.size))
  .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));

What you have as your first parameter should be the filter property of the AwaitMessagesOptions object您的第一个参数应该是AwaitMessagesOptions object 的filter属性

message.channel.awaitMessages({
  filter: (m) => m.author.id === message.author.id,
  max: 1,
  time: 300000,
  errors: ['time']
})
.then(...);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM