我有一个不和谐的机器人,根据命令,它会向一个频道发送多条消息。一些消息是图像,它们总是最后发送。
msg.channel.send({files: ["image.png"]});
for (var i in rules) {
msg.channel.send({embed: rules[i]});
}
msg.channel.send({files: ["image2.png"]});
msg.channel.send({embed: embed1});
msg.channel.send({files: ["image3.png"]});
msg.channel.send({embed: embed2});
我希望按照代码的顺序发送消息。
TextChannel.send()
返回一个承诺,所以你可以使用 async/await
// make sure your function is async
await msg.channel.send({files: ["image.png"]});
await msg.channel.send({files: ["image2.png"]});
await msg.channel.send({embed: embed1});
await msg.channel.send({files: ["image3.png"]});
await msg.channel.send({embed: embed2});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句