So this is my code for sending an embed, that says Loading shop with the dots changing. However, I am getting a pretty strange error message, which first tells me the error is at msg.delete() with "UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'delete' of undefined" and then a second one at the second msg.edit() saying "Cannot read property 'edit' of undefined". I searched up the docs and many forums, but the .then() syntax should be right. Any idea?
var embed = new Discord.MessageEmbed().setColor("GOLD").setTitle("Loading shop");
msg.channel.send(embed)
.then(msg => {setTimeout(()=>{msg.edit(embed.setTitle("Loading shop."))}, 500)})
.then(msg => {setTimeout(()=>{msg.edit(embed.setTitle("Loading shop.."))}, 500)})
.then(msg => {setTimeout(()=>{msg.edit(embed.setTitle("Loading shop..."))}, 500)})
.then(msg => {setTimeout(()=>{msg.edit(embed.setTitle("Loading shop"))}, 500)})
.then(msg => {setTimeout(()=>{msg.edit(embed.setTitle("Loading shop."))}, 500)})
.then(msg => {setTimeout(()=>{msg.edit(embed.setTitle("Loading shop.."))}, 500)})
.then(msg => {setTimeout(()=>{msg.edit(embed.setTitle("Loading shop..."))}, 500)})
.then(msg => {msg.delete()});
question from:
https://stackoverflow.com/questions/65923286/discord-js-msg-channel-send-then-promise-not-working 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…