首页 > 解决方案 > 如何删除 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 消息?请帮帮我

标签: javascriptdiscord.js

解决方案


该方法使用您的标准对象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
        })


推荐阅读