javascript - 如何删除 message.channel.send?
问题描述
message.channel.send(`You understand by submitting this strike form you are prepared to be spoken to at any given time per log accepters? Type ***yes*** if you understand.`).then(async (m) => {
message.channel.awaitMessages(response => response.content === 'yes', {
max: 1,
time: 10000,
errors: ['time'],
}).then(async (collected) => {
因此,当我发送带有“您通过提交了解”的消息时,我如何在 15 秒后删除该消息,然后当用户在聊天中键入 yes 时,如何删除 awaitMessages 消息?请帮帮我
解决方案
该方法使用您的标准对象TextChannel#send
返回一个承诺,您可以像这样调用它的函数:<Message>
Message.delete()
message.channel.send(`You understand by submitting this strike form you are prepared to be spoken to at any given time per log accepters?\n\n Type ***yes*** if you understand.`).then(async (m) => {
// for the collector it would automatically terminate after 1 response so you may simply continue as it was before
message.channel.awaitMessages(response => response.content === 'yes', {
max: 1,
time: 10000,
errors: ['time'],
}).then(async (collected) => {
setTimeout( () => m.delete(); collected.first().delete() , 15000) // 15 seconds
})
推荐阅读
- spring-mvc - 如何在jsp页面上显示日期
- mongodb - Mongodump 在安全模式下对 mongodb 失败
- c# - 通过模型构建器转换为 GUID 添加和删除前缀
- excel - 将字母和计数器值添加到 Excel 中列中的每个单元格
- file - 未处理的异常:内容大小低于指定的 contentLength。已写入 511 个字节,但预期为 704
- c - 在 Linux 上的 C++ 程序中分析常驻内存使用情况和许多页面错误
- r - 如何计算总金额取决于 r 中的日期?
- xcode - 如何在应用启动时打开多个窗口?
- android - 未调用 PendingIntent.getBoradcast 广播接收器
- python - 为什么我的 jupyter 内核在导入 numpy 时在虚拟环境中运行时会死机?