I made a fun command and I got no errors so far.
Here's the code:
const { MessageEmbed } = require('discord.js')
module.exports = {
name: "spin",
description: "spin",
permissions: ["SEND_MESSAGES"],
run: async (client, message, args) => {
if(message.author.bot) return;
let number = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36"];
let secondEmbed = new MessageEmbed()
.setTitle("The wheel is spinning...")
.setColor('#fc8eac')
.setTimestamp()
.addField("Spinner", `<@!${message.author.id}>`, true)
.addField("Result", ` <a:dotload:928216650614968321>`, true)
.setThumbnail('https://cdn.discordapp.com/emojis/928270805492699177.webp?size=160&quality=lossless')
.setFooter(`${message.author.tag}`, message.author.displayAvatarURL());
const m = await message.channel.send({embeds: [secondEmbed] })
let firstEmbed = new MessageEmbed()
.setTitle("The wheel has stopped spinning!")
.setColor('#fc8eac')
.setTimestamp()
.addField("Spinner", `<@!${message.author.id}>`, true)
.addField("Result", `${number[Math.floor(Math.random() * number.length)]}`, true)
.setThumbnail('https://cdn.discordapp.com/emojis/928270805492699177.webp?size=160&quality=lossless')
.setFooter(`${message.author.tag}`, message.author.displayAvatarURL());
await m.edit(({embeds: [firstEmbed] }), {timeout: 5000})
}
}
I'm having trouble on this line 'coz the embed gets edited in less than the given time length {timeout: 5000}
await m.edit(({embeds: [firstEmbed] }), {timeout: 5000})
I need help on how to fix this.
I'm not sure if there is a timeout option for the Message#edit method. At least I can't find it in the documentation.
However, you could use the good old setTimeout method to achieve the same:
setTimeout(() => {
m.edit({ embeds: [firstEmbed] })
}, 5000)