首页 > 解决方案 > Discord 机器人不接受输入

问题描述

在发布时使用 Node.js (v16.11.1) 和最新的 discord.js。试图得到简单的答复。当 bot 运行时,'/ping' 工作,它问我'你为什么要 ping 我?',但无论我给它什么输入,15 秒后都会超时,打印'你没有输入任何输入!'。

我究竟做错了什么?请帮忙。

    if (!interaction.isCommand()) return;

    const { commandName } = interaction;

    if (commandName === 'ping') {
        await interaction.reply('Why did you ping me?').then(() => {
       // const filter = m => m.content.startsWith('!test');
       const filter = m => interaction.user.id === m.author.id;
        
        interaction.channel.awaitMessages({ filter, time: 15000, max: 1, errors: ['time'] })
        .then(messages => {
            interaction.followUp(`You've entered: ${messages.first().content}`);
        })
        .catch(() => {
            interaction.followUp('You did not enter any input!');
        });
        
        
        });
    } 
});

标签: discord.jsbots

解决方案


推荐阅读