【问题标题】:discord.js send and wait before editing a messagediscord.js 在编辑消息之前发送并等待
【发布时间】:2018-09-25 04:31:27
【问题描述】:

我希望我的机器人发送 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

谢谢你帮助我。

【问题讨论】:

  • 对我来说似乎很好。代码应该按预期工作。
  • 我刚刚测试了您的代码并且工作正常。你有什么 NodeJS 版本?什么 discord.js 版本?使用node -v获取Node版本,npm list discord.js获取discordjs版本
  • 最后,我已经管理好自己并修补了它,如果最后有效的话!
  • 你应该回答你自己的问题,你为使它工作所做的工作,所以如果其他人遇到与你相同的问题,你知道你做了什么来解决它。 @Dillgo

标签: javascript wait discord.js


【解决方案1】:

好的,最后的代码是:

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

【讨论】:

    猜你喜欢
    • 2020-07-02
    • 2011-02-10
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    • 2021-11-09
    • 1970-01-01
    • 2015-03-03
    • 1970-01-01
    相关资源
    最近更新 更多