Bot get crash if import external list with/without async

24 Replies
d.js toolkit
d.js toolkit11mo 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!
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Klubuntu
Klubuntu11mo ago
Please Wait I will update it, but I also have to look for everything
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Klubuntu
Klubuntu11mo ago
Alright @Jô 🌈 🦄 Can you help me ?
grass
grass11mo ago
run your code with the --enable-source-maps flag to see where the error comes from somewhere you’re sending a message with an empty object in embeds
Klubuntu
Klubuntu11mo ago
OK
(node:18760) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
[BOT] Added to play https://open.spotify.com/track/1DMEzmAoQIikcL52psptQL
[BOT] Playing https://open.spotify.com/track/1DMEzmAoQIikcL52psptQL
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50035]: Invalid Form Body
embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required
at handleErrors (node_modules\@discordjs\rest\dist\index.js:640:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (node_modules\@discordjs\rest\dist\index.js:1021:23)
at async SequentialHandler.queueRequest (node_modules\@discordjs\rest\dist\index.js:862:14)
at async REST.request (node_modules\@discordjs\rest\dist\index.js:1387:22)
at async TextChannel.send (node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:162:15) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [ {} ],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
embeds: { '0': { _errors: [ [Object] ] } }
}
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1132630798852423720/messages'
}

Node.js v18.12.1
(node:18760) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
[BOT] Added to play https://open.spotify.com/track/1DMEzmAoQIikcL52psptQL
[BOT] Playing https://open.spotify.com/track/1DMEzmAoQIikcL52psptQL
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50035]: Invalid Form Body
embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required
at handleErrors (node_modules\@discordjs\rest\dist\index.js:640:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (node_modules\@discordjs\rest\dist\index.js:1021:23)
at async SequentialHandler.queueRequest (node_modules\@discordjs\rest\dist\index.js:862:14)
at async REST.request (node_modules\@discordjs\rest\dist\index.js:1387:22)
at async TextChannel.send (node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:162:15) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [ {} ],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
embeds: { '0': { _errors: [ [Object] ] } }
}
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1132630798852423720/messages'
}

Node.js v18.12.1
grass
grass11mo ago
alright that did not help much
Klubuntu
Klubuntu11mo ago
what else do you need ?
grass
grass11mo ago
uhhh when does this error, error
Klubuntu
Klubuntu11mo ago
Embed builder return:
EmbedBuilder {
data: {
color: 2546080,
title: ':musical_note: Playing TEST DRIVE',
url: 'https://open.spotify.com/track/1DMEzmAoQIikcL52psptQL',
author: undefined,
description: 'by Manager :cd: https://manager-discord.netlify.app',
thumbnail: {
url: 'https://i.scdn.co/image/ab67616d0000b27360ba1d6104d0475c7555a6b2'
},
fields: [ [Object], [Object], [Object] ],
image: undefined,
timestamp: undefined,
footer: {
text: '(C) 2023 - Manager v3.0 BETA 2 by Klubuntu',
icon_url: undefined
}
}
}
EmbedBuilder {
data: {
color: 2546080,
title: ':musical_note: Playing TEST DRIVE',
url: 'https://open.spotify.com/track/1DMEzmAoQIikcL52psptQL',
author: undefined,
description: 'by Manager :cd: https://manager-discord.netlify.app',
thumbnail: {
url: 'https://i.scdn.co/image/ab67616d0000b27360ba1d6104d0475c7555a6b2'
},
fields: [ [Object], [Object], [Object] ],
image: undefined,
timestamp: undefined,
footer: {
text: '(C) 2023 - Manager v3.0 BETA 2 by Klubuntu',
icon_url: undefined
}
}
}
It should work and data from fields
[
{ name: 'Playing from', value: ':headphones: Spotify', inline: true },
{ name: 'Duration', value: '02:59', inline: true },
{ name: 'Publish Date', value: 'Unavailable', inline: true }
]
[
{ name: 'Playing from', value: ':headphones: Spotify', inline: true },
{ name: 'Duration', value: '02:59', inline: true },
{ name: 'Publish Date', value: 'Unavailable', inline: true }
]
duck
duck11mo ago
the issue isn't with the embed you built, it's where you send it
Klubuntu
Klubuntu11mo ago
Hmm I updated my code to send trigger if play
player.events.on('playerTrigger', (queue, track) => {
queue.metadata.channel.send("test");
queue.metadata.channel.send({embeds: [useEmbed(track, "play")]});
});
player.events.on('playerTrigger', (queue, track) => {
queue.metadata.channel.send("test");
queue.metadata.channel.send({embeds: [useEmbed(track, "play")]});
});
and first message send without problems useEmbed relates to: https://pastebin.com/Gw3ZgFnR
grass
grass11mo ago
where do you define useEmbed
Klubuntu
Klubuntu11mo ago
in above link
grass
grass11mo ago
you define getEmbed in that
grass
grass11mo ago
useEmbed returns a promise
Klubuntu
Klubuntu11mo ago
yes, Is my solution is to add await ?
grass
grass11mo ago
yes/no either dont make useEmbed an async function or await it you dont even use await in the useEmbed function
Klubuntu
Klubuntu11mo ago
Thanks, problem solved ✅
Klubuntu
Klubuntu11mo ago
Klubuntu
Klubuntu11mo ago
without Crash
Klubuntu
Klubuntu11mo ago