How to import embeds from 1 file into 2 without creating embed in 2 file?

Let's say I have a config.json file in which I wrote 5 different embed messages. And there is info.js, which should output one of these messages depending on the role of the participant. How to do this, because I have an error with the fact that DiscordAPI requires minimal data in embed messages.
30 Replies
d.js toolkit
d.js toolkit3d 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! - Marked as resolved by staff
RLodka
RLodkaOP3d ago
DiscordAPIError[50035]: Invalid Form Body
data.embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required
DiscordAPIError[50035]: Invalid Form Body
data.embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required
What's the difference between importing json and js files?
NyR
NyR3d ago
Nothing, qjuh told you already. Whatever you are passing as an embed seems to be undefined, show your code specifically or json file structure and how you are importing/using it in the file
d.js docs
d.js docs3d ago
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
RLodka
RLodkaOP3d ago
I'm importing embed messages from embed.js file. I had one version that the problem lay in .json.
No description
No description
RLodka
RLodkaOP3d ago
I didn't quite understand how to do this. Can I get an example or a detailed explanation?
monbrey
monbrey3d ago
This is really a pretty basic JS thing, not discord.js Don't overwrite module.exports Do you know how to write an object?
RLodka
RLodkaOP3d ago
No
d.js docs
d.js docs3d ago
:mdn: JavaScript object basics Congratulations, you've reached the end of our first JS objects article — you should now have a good idea of how to work with objects in JavaScript — including creating your own simple objects. You should also appreciate that objects are very useful as structures for storing related data and functionality — if you tried to keep track of all the properties and methods in our person object as separate variables and functions, it would be inefficient and frustrating, and we'd run the risk of clashing with other variables and functions that have the same names. Objects let us keep the information safely locked away in their own package, out of harm's way.
RLodka
RLodkaOP3d ago
I read the manual. I basically remembered how to do this because I had done it in other programming languages. But my problem is that I don’t know how not to overwrite the module, make a command and export the output of the embed message I need into it.
monbrey
monbrey3d ago
Just define module.exports once, with an object containing everything you want to export Do not overwrite it. It's a variable like any other, you can't make it = things multiple times and expect it to merge itself
RLodka
RLodkaOP3d ago
Where do I need to define it if I cannot create the command itself without it?
No description
NyR
NyR3d ago
In your embed.js, your command file is fine. See how you doing there? Exporting data and execute in one object? Do it like that in your embed file too It boils down to basics module.exports= { A, B, ...}
RLodka
RLodkaOP3d ago
Like this?
No description
NyR
NyR3d ago
That's still your command file (and you also now removed the import for some reason)
RLodka
RLodkaOP3d ago
No description
RLodka
RLodkaOP3d ago
?
NyR
NyR3d ago
I'm not sure what you are not understanding? The above image is great. Back to where we started ig. Did you fix your embed.js file though?
RLodka
RLodkaOP3d ago
No description
NyR
NyR3d ago
Now you got rid of your other variable entirely. But that'd work. Did you try it? Also I recommend you freshen up your knowledge of js if you are struggling that much in basics #resources
RLodka
RLodkaOP3d ago
The essence of the matter does not change. The exact same error is given. Sorry that I know so little in this area.
NyR
NyR3d ago
Show the full error please Also how does your info.js looks now?
RLodka
RLodkaOP3d ago
DiscordAPIError[50035]: Invalid Form Body
data.embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required
at handleErrors (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async ChatInputCommandInteraction.reply (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:115:5)
at async Object.execute (C:\Users\singe\Desktop\dsbot\commands\utility\info.js:9:9)
at async Object.execute (C:\Users\singe\Desktop\dsbot\events\interactionCreate.js:16:4) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { data: [Object] }
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1317978749706178580/aW50ZXJhY3Rpb246MTMxNzk3ODc0OTcwNjE3ODU4MDpuV2k1TEFlVEJKdHpSbUQ0bzVseHhobUc3cmhGdDNjMmRlV2xvSFpOMnoyTHRSUnlwcGFKQ0FkZkc2TnZXcmVycjV1WFhITUFHNEg5SU14WmI1NFZWaktSRFpRdmVHVzliblZtVzFFTTdIN2kyS1pOQ3VIc0hRRk5tRUxwTXVnQg/callback'
}
DiscordAPIError[50035]: Invalid Form Body
data.embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required
at handleErrors (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async ChatInputCommandInteraction.reply (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:115:5)
at async Object.execute (C:\Users\singe\Desktop\dsbot\commands\utility\info.js:9:9)
at async Object.execute (C:\Users\singe\Desktop\dsbot\events\interactionCreate.js:16:4) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { data: [Object] }
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1317978749706178580/aW50ZXJhY3Rpb246MTMxNzk3ODc0OTcwNjE3ODU4MDpuV2k1TEFlVEJKdHpSbUQ0bzVseHhobUc3cmhGdDNjMmRlV2xvSFpOMnoyTHRSUnlwcGFKQ0FkZkc2TnZXcmVycjV1WFhITUFHNEg5SU14WmI1NFZWaktSRFpRdmVHVzliblZtVzFFTTdIN2kyS1pOQ3VIc0hRRk5tRUxwTXVnQg/callback'
}
RLodka
RLodkaOP3d ago
No description
NyR
NyR3d ago
log SOV_democracy in your info.js file please Better yet, just log console.log(require('./embed'))
RLodka
RLodkaOP3d ago
{
FRA_monarhist: EmbedBuilder {
data: {
color: 39423,
title: 'Королевство Франция',
description: 'Описание',
thumbnail: [Object],
fields: [Array],
timestamp: '2024-12-15T22:32:11.275Z'
}
}
}
DiscordAPIError[50035]: Invalid Form Body
data.embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required
at handleErrors (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async ChatInputCommandInteraction.reply (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:115:5)
at async Object.execute (C:\Users\singe\Desktop\dsbot\commands\utility\info.js:10:9)
at async Object.execute (C:\Users\singe\Desktop\dsbot\events\interactionCreate.js:16:4) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { data: [Object] }
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1317982907016417340/aW50ZXJhY3Rpb246MTMxNzk4MjkwNzAxNjQxNzM0MDowQmZUTVhxR0hzS01IVVpnUzhRRXNESzlhZ0NpV0YwSmdyb2JrTnk0TXlyYmZiNEJra0VXekZIRkZOMmxvQ3pDUnR5M3RIOVp2WGVXUXVGbnJrUzlsUUljQ2FqSmdrbmhxUDRSSjZtMW83RHZCQzZaSHR6ZndMMHJGcGw4S1dQMg/callbac'
}
{
FRA_monarhist: EmbedBuilder {
data: {
color: 39423,
title: 'Королевство Франция',
description: 'Описание',
thumbnail: [Object],
fields: [Array],
timestamp: '2024-12-15T22:32:11.275Z'
}
}
}
DiscordAPIError[50035]: Invalid Form Body
data.embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required
at handleErrors (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async ChatInputCommandInteraction.reply (C:\Users\singe\Desktop\dsbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:115:5)
at async Object.execute (C:\Users\singe\Desktop\dsbot\commands\utility\info.js:10:9)
at async Object.execute (C:\Users\singe\Desktop\dsbot\events\interactionCreate.js:16:4) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { data: [Object] }
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1317982907016417340/aW50ZXJhY3Rpb246MTMxNzk4MjkwNzAxNjQxNzM0MDowQmZUTVhxR0hzS01IVVpnUzhRRXNESzlhZ0NpV0YwSmdyb2JrTnk0TXlyYmZiNEJra0VXekZIRkZOMmxvQ3pDUnR5M3RIOVp2WGVXUXVGbnJrUzlsUUljQ2FqSmdrbmhxUDRSSjZtMW83RHZCQzZaSHR6ZndMMHJGcGw4S1dQMg/callbac'
}
NyR
NyR3d ago
The log shows completely different name than what you export from your embed.js file (FRA_monarhist). Are you sure your files are safe or did you make changes and forgot to uodate your imports?
RLodka
RLodkaOP3d ago
Please excuse me, I forgot to remove the export modules from other embed messages. I finally succeeded. Thank you for your help and your time. I would now like to clarify, is it possible to export the rest of the messages that I have in the same way?
No description
NyR
NyR3d ago
That's what we have been telling you from start, yes. Export it as one object. Do not overwrite module.exports by doing it multiple times ...
RLodka
RLodkaOP3d ago
Once again thank you very much for your help!
Want results from more Discord servers?
Add your server