MessageAttachement isn't working

Hi, I'm trying to add a local file to my embed but it is giving me an Invalid Form Body error: Scheme "attachement" is not supported. Scheme must be one of ('http', 'https').. My code looks like the following:
const { MessageEmbed, MessageAttachment } = require("discord.js");
const countries = require("svg-country-flags/countries.json");

module.exports = {
data: new SlashCommandBuilder()
.setName("guess")
.setDescription("Guess a random flag"),


async execute(interaction) {

let randomProperty = function (obj) {
let keys = Object.keys(obj);
let num = keys.length * Math.random() << 0;

return `${keys[num]}, ${obj[keys[num]]}`;
};


let randCountry = randomProperty(countries);
randCountry = randCountry.split(", ");

const file = new MessageAttachment(`./node_modules/svg-country-flags/png1000px/${randCountry[0]}.png`);

const guessEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle("Guess that Flag!")
.setDescription(`<t:${countdown}:R>`)
.setImage({
url: `attachement://${randCountry[0]}.png`,
size: 256
})

interaction.reply({ embeds: [guessEmbed], files: [file] })

};

};
const { MessageEmbed, MessageAttachment } = require("discord.js");
const countries = require("svg-country-flags/countries.json");

module.exports = {
data: new SlashCommandBuilder()
.setName("guess")
.setDescription("Guess a random flag"),


async execute(interaction) {

let randomProperty = function (obj) {
let keys = Object.keys(obj);
let num = keys.length * Math.random() << 0;

return `${keys[num]}, ${obj[keys[num]]}`;
};


let randCountry = randomProperty(countries);
randCountry = randCountry.split(", ");

const file = new MessageAttachment(`./node_modules/svg-country-flags/png1000px/${randCountry[0]}.png`);

const guessEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle("Guess that Flag!")
.setDescription(`<t:${countdown}:R>`)
.setImage({
url: `attachement://${randCountry[0]}.png`,
size: 256
})

interaction.reply({ embeds: [guessEmbed], files: [file] })

};

};
4 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Nils
NilsOP3y ago
So I'm trying it like this now
.setImage( `attachement://${countryCode}.png`, { size: 256 })
.setImage( `attachement://${countryCode}.png`, { size: 256 })
but now it's giving me the error: Scheme "attachement" is not supported. Scheme must be one of ('http', 'https').
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Nils
NilsOP3y ago
Oh man, dumb mistake. Thanks mate sometimes it takes a second pair of eyes to see the mistake.
Want results from more Discord servers?
Add your server