I don't know how to fix it

Generally I don't know how I can define emved at the beginning. error: TypeError: Cannot read properties of undefined (reading 'spliceFields')
24 Replies
d.js toolkit
d.js toolkit3mo 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 OP
NyR
NyR3mo ago
Embed actually needs to be an instance of EmbedBuilder to use spliceFields() method You never actually do that in your code anywhere
sveet
sveet3mo ago
So how to do it another way?
NyR
NyR3mo ago
Wdym the other way? You already define embed with let embed; Make it an instance of EmbedBuilder before you call spliceFields() method by re-assigning embed = new EmbedBuilder();
sveet
sveet3mo ago
hm
CombinedPropertyError (1)
Received one or more errors

input[0]
| CombinedPropertyError (1)
| Received one or more errors
|
| input.value
| | ExpectedConstraintError > s.string.lengthGreaterThanOrEqual
| | Invalid string length
| |
| | Expected: expected.length >= 1
| |
| | Received:
| | | ''
CombinedPropertyError (1)
Received one or more errors

input[0]
| CombinedPropertyError (1)
| Received one or more errors
|
| input.value
| | ExpectedConstraintError > s.string.lengthGreaterThanOrEqual
| | Invalid string length
| |
| | Expected: expected.length >= 1
| |
| | Received:
| | | ''
NyR
NyR3mo ago
The field value is empty, log it and see what it returns Or make use of optional chaining and provide a default value if there is none
sveet
sveet3mo ago
returns nothing
NyR
NyR3mo ago
Then use optional chaining and provide default value if it's undefined
sveet
sveet3mo ago
how
d.js docs
d.js docs3mo ago
:mdn: Optional chaining (?.) The optional chaining (?.) operator accesses an object's property or calls a function. If the object accessed or function called using this operator is undefined or null, the expression short circuits and evaluates to undefined instead of throwing an error.
NyR
NyR3mo ago
Or you know make sure the value is actually not empty
sveet
sveet3mo ago
I don't know, nothing works and I just want to remove players from the embed
NyR
NyR3mo ago
Then do just that, it's basic js at this point
sveet
sveet3mo ago
Field value is empty
NyR
NyR3mo ago
And ? I told you to check whatever you are putting in the value if it is empty or not and then provide a default value if it is, it's basic js If you do not know how to do that, I recommend you learn some js ^
sveet
sveet3mo ago
I did it, I don't understand what you are writing now.
NyR
NyR3mo ago
So I don't understand what your issue is then
sveet
sveet3mo ago
I don't understand it myself I did it just like on the website and console.log returns very little I don't know what exactly you mean
sveet
sveet3mo ago
Pastebin
const { SlashCommandBuilder, EmbedBuilder } = require('@discordjs/b...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
sveet
sveet3mo ago
.addFields(
{ name: 'Członkowie', value: party.map((memberId) => `- <@${memberId}>`).join('\n') },
)
.addFields(
{ name: 'Członkowie', value: party.map((memberId) => `- <@${memberId}>`).join('\n') },
)
+
let embed;
embed.spliceFields(0, 1, {
name: 'Członkowie',
value: party.map((memberId) => `- <@${memberId}>`).join('\n')
});

await message.edit({
embeds: [embed]
});
let embed;
embed.spliceFields(0, 1, {
name: 'Członkowie',
value: party.map((memberId) => `- <@${memberId}>`).join('\n')
});

await message.edit({
embeds: [embed]
});
d.js docs
d.js docs3mo ago
:property: Message#embeds An array of embeds in the message - e.g. YouTube Player. (more...)
sveet
sveet3mo ago
I'm stupid I don't understand how to do it I can send you the whole code, but dm?
sveet
sveet3mo ago
Pastebin
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits, Cha...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
sveet
sveet3mo ago
it will no longer expire