Error when creating embed

I'm getting the following error when trying to create an embed. My main goal is to let the user enter the name, select an image and unix time to create an embed.
[29.07.2023 16:56.55.954] [ERROR] Error creating embed: Received one or more errors
[29.07.2023 16:56.55.955] [ERROR] Error details: CombinedError (3)
Received one or more errors

1 ExpectedValidationError > s.literal(V)
| Expected values to be equals
|
| Expected:
| | null
|
| Received:
| | '#e76604'

2 ValidationError > s.number
| Expected a number primitive
|
| Received:
| | '#e76604'

3 ValidationError > s.tuple(T)
| Expected an array
|
| Received:
| | '#e76604'

at UnionValidator.handle (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/node_modules/@sapphire/shapeshift/dist/index.mjs:1096:23)
at UnionValidator.parse (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/node_modules/@sapphire/shapeshift/dist/index.mjs:204:88)
at EmbedBuilder.setColor (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/node_modules/@discordjs/builders/dist/index.mjs:225:20)
at createFiresaleEmbed (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/src/commands/firesale.js:20:14)
at Client.<anonymous> (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/src/commands/firesale.js:96:27)
at Client.emit (node:events:526:35)
at InteractionCreateAction.handle (C:\Users\Leon\OneDrive\Desktop\DKK v14\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\Leon\OneDrive\Desktop\DKK v14\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\Leon\OneDrive\Desktop\DKK v14\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (C:\Users\Leon\OneDrive\Desktop\DKK v14\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:12)
[29.07.2023 16:56.55.954] [ERROR] Error creating embed: Received one or more errors
[29.07.2023 16:56.55.955] [ERROR] Error details: CombinedError (3)
Received one or more errors

1 ExpectedValidationError > s.literal(V)
| Expected values to be equals
|
| Expected:
| | null
|
| Received:
| | '#e76604'

2 ValidationError > s.number
| Expected a number primitive
|
| Received:
| | '#e76604'

3 ValidationError > s.tuple(T)
| Expected an array
|
| Received:
| | '#e76604'

at UnionValidator.handle (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/node_modules/@sapphire/shapeshift/dist/index.mjs:1096:23)
at UnionValidator.parse (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/node_modules/@sapphire/shapeshift/dist/index.mjs:204:88)
at EmbedBuilder.setColor (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/node_modules/@discordjs/builders/dist/index.mjs:225:20)
at createFiresaleEmbed (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/src/commands/firesale.js:20:14)
at Client.<anonymous> (file:///C:/Users/Leon/OneDrive/Desktop/DKK%20v14/src/commands/firesale.js:96:27)
at Client.emit (node:events:526:35)
at InteractionCreateAction.handle (C:\Users\Leon\OneDrive\Desktop\DKK v14\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\Leon\OneDrive\Desktop\DKK v14\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\Leon\OneDrive\Desktop\DKK v14\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (C:\Users\Leon\OneDrive\Desktop\DKK v14\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:12)
My code looks as follows:
let name = options.getString('name')
let image1 = options.getAttachment('bild1')
let image2 = options.getAttachment('bild2')
let image3 = options.getAttachment('bild3')
let unix = options.getInteger('unix')

const embed = createFiresaleEmbed(event.title, name, unix, image1.url, event.color);

interaction.reply({
content: 'Test',
embeds: [embed],
ephemeral: true
});
let name = options.getString('name')
let image1 = options.getAttachment('bild1')
let image2 = options.getAttachment('bild2')
let image3 = options.getAttachment('bild3')
let unix = options.getInteger('unix')

const embed = createFiresaleEmbed(event.title, name, unix, image1.url, event.color);

interaction.reply({
content: 'Test',
embeds: [embed],
ephemeral: true
});
function createFiresaleEmbed(title, name, unix, image, color) {
try {
return new EmbedBuilder()
.setTitle(title)
.setColor(color)
.setDescription(Dieses Mal einen **${name}**!\n\nDer Fire Sale startet <t:${unix}:R>\n\n) //Took out Gravis to not f up discord formatting
.setImage(image)
.setFooter({ text: config.global.footer });
} catch (error) {
console.error(Error creating embed: ${error.message}); //Took out Gravis to not f up discord formatting
console.error("Error details:", error);
return null;
}
}
function createFiresaleEmbed(title, name, unix, image, color) {
try {
return new EmbedBuilder()
.setTitle(title)
.setColor(color)
.setDescription(Dieses Mal einen **${name}**!\n\nDer Fire Sale startet <t:${unix}:R>\n\n) //Took out Gravis to not f up discord formatting
.setImage(image)
.setFooter({ text: config.global.footer });
} catch (error) {
console.error(Error creating embed: ${error.message}); //Took out Gravis to not f up discord formatting
console.error("Error details:", error);
return null;
}
}
I logged all the variables title, name, unix, image and color: the values seem to be ok
console.log(title);
console.log(name);
console.log(unix);
console.log(image);
console.log(color);
console.log(title);
console.log(name);
console.log(unix);
console.log(image);
console.log(color);
[29.07.2023 16:59.54.946] [LOG] 🔥 Neuer Fire Sale! [29.07.2023 16:59.54.947] [LOG] testa [29.07.2023 16:59.54.947] [LOG] 1690649796 [29.07.2023 16:59.54.948] [LOG] https://cdn.discordapp.com/ephemeral-attachments/1066036486497112075/1134862857813622804/7ify6m.jpg [29.07.2023 16:59.54.948] [LOG] #e76604
5 Replies
d.js toolkit
d.js toolkit•11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
DANIEL
DANIEL•11mo ago
Seem like color is the problem
Schlaumeyer
Schlaumeyer•11mo ago
That's what the error says... yeah. But in other files the color is not the problem so I think it has to be something different
duck
duck•11mo ago
Your error suggests you've imported EmbedBuilder from @discordjs/builders rather than discord.js You'll need to import from discord.js for colors to be resolved
Schlaumeyer
Schlaumeyer•11mo ago
I knew it would be some stupid issue... thx