discord.js - 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!');
});
});
}
});
解决方案
推荐阅读
- google-maps - 使用地点自动完成功能了解来自 Google Places API for Web 的请求
- curl - 使用cmd调用curl?
- replace - 如何使用正则表达式在jinja2中使用ansible嵌套变量并替换
- powershell - 循环浏览 CSV 文件中的目录
- java - 为什么即使遵循正确的模式也会为 SimpleDateFormat 显示 ParseException?
- python - python-pdfkit (wkhtmltopdf) 目录溢出
- vb.net - 编码和解码 VBA 程序
- node.js - Active Directory 和 Express/Node
- python - 使用 Pyhive 插入 Hive 调用错误
- ruby - Ruby 中 `\w` 与 `[[:alpha:]]` 之间 Unicode 行为的差异