Search code examples
javascriptimagediscordembed

Discord .setImage file isn't inside the embed but sent before it


const { Channel } = require("discord.js")

module.exports = {
    name: 'wa',
    description: "summons embed",
    execute(message, args, Discord) { 
        const attachment = new Discord
                      .MessageAttachment('./pictures/Nero (BC).png', 'Nero (BC).png');
        let NewEmbed = new Discord.MessageEmbed()
        .setColor('#FFC62B')
        .setTitle('Nero \(BC\)')
        .attachFiles(attachment)
        .setImage('attachment://Nero (BC).png')
        .setDescription('Black Clover <:female:812724616934064140> \n 324 <:kakera:812729845121155082> \n React with any emoji to claim! \n (Read **$togglereact)**')
        message.channel.send(NewEmbed);
        
    }
}

so when I try to use $wa the embed appears and all stuff is correct except the file, which is sent before the embed.

what happens


Solution

  • For anyone trying to do this, I recommend using an image hosting site and .setImage instead of this mess with

    const attachment = new Discord
                          .MessageAttachment('./pictures/image name.png', 'image name.png');
    

    and

    .attachFiles(attachment)
            .setImage('attachment://image name.png')
    

    instead of all of that just use .setImage('link to hosting site.png')

    for me personally imgur doesn't work but I don't know if I'm allowed to say website names here so sorry guys.

    but you'll be fine if you find an image hosting site that links to the png and not to a website with the image embeded.

    hope this helped!