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 toolkit10mo 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
NyR10mo ago
Embed actually needs to be an instance of EmbedBuilder to use spliceFields() method You never actually do that in your code anywhere
sveet
sveetOP10mo ago
So how to do it another way?
NyR
NyR10mo 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
sveetOP10mo 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
NyR10mo 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
sveetOP10mo ago
returns nothing
NyR
NyR10mo ago
Then use optional chaining and provide default value if it's undefined
sveet
sveetOP10mo ago
how
d.js docs
d.js docs10mo 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
NyR10mo ago
Or you know make sure the value is actually not empty
sveet
sveetOP10mo ago
I don't know, nothing works and I just want to remove players from the embed
NyR
NyR10mo ago
Then do just that, it's basic js at this point
sveet
sveetOP10mo ago
Field value is empty
NyR
NyR10mo 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
sveetOP10mo ago
I did it, I don't understand what you are writing now.
NyR
NyR10mo ago
So I don't understand what your issue is then
sveet
sveetOP10mo 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
sveetOP10mo 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
sveetOP10mo 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 docs10mo ago
:property: Message#embeds An array of embeds in the message - e.g. YouTube Player. (more...)
sveet
sveetOP10mo ago
I'm stupid I don't understand how to do it I can send you the whole code, but dm?
sveet
sveetOP10mo 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
sveetOP10mo ago
it will no longer expire
Want results from more Discord servers?
Add your server