代码之家  ›  专栏  ›  技术社区  ›  Dillgo

不一致js发送并等待,然后再编辑消息

  •  1
  • Dillgo  · 技术社区  · 6 年前

    我要我的机器人发送 my emotes ,等待1秒钟,然后将消息编辑为 my others emotes

    这是我的代码:

    message.channel.send('my emotes')
      .then((msg) => {
        setTimeout(function() {
        msg.edit('my other emotes');
      }, 1000)});  
    

    他发给我这个错误: Cannot read property 'edit' of undefined

    谢谢你帮助我。

    1 回复  |  直到 6 年前
        1
  •  2
  •   SaschaM78 Maxx    5 年前

    好的,那么最终有效的代码是:

    message.channel.send('my emote')
    .then((msg)=> {
      setTimeout(function(){
        msg.edit('my others emotes');
      }, 1000)
    });