Akese315
Akese315

Reputation: 63

AddFields in EmbedBuilder doesn't support empty string

I have an issue with addFields value. I really can't understand why this doesn't work. The error is on the product.brand value.

This is my code:

async sendProduct(product)
{   
  console.log(typeof(product.brand));
  console.log(product.brand);
  const productMessage = await new EmbedBuilder()
    .setColor(0x0099FF)
    .setURL(product.url)
    .setTitle('Acheter cet article')
    .setImage(product.image)
    .addFields(
      { name: 'Marque:', value: product.brand } 
    )
  await this.PRODUCT_CHANNEL.send({ embeds: [productMessage] });
}

Error:

C:\axel\programmation\project\node_modules\@sapphire\shapeshift\dist\index.js:463 return errors.length === 0 ? Result.ok(transformed) : Result.err(new CombinedPropertyError(errors));
^ CombinedPropertyError: Received one or more errors at ArrayValidator.handle 
(C:\axel\programmation\\node_modules\@sapphire\shapeshift\dist\index.js:463:70) at ArrayValidator.parse 
(C:\axel\programmation\project\node_modules\@sapphire\shapeshift\dist\index.js:142:88) at EmbedBuilder.addFields
(C:\axel\programmation\project\node_modules\@discordjs\builders\dist\messages\embed\Embed.cjs:17:42) at Robot.sendProduct 
(C:\axel\programmation\project\index.js:83:10) at 
C:\axel\programmation\project\index.js:131:22 at
Array.forEach (<anonymous>) at C:\axel\programmation\project\index.js:130:18 at 
processTicksAndRejections (node:internal/process/task_queues:96:5) { 
errors: [ [ 0,
CombinedPropertyError: Received one or more errors at ObjectValidator.handleIgnoreStrategy 
(C:\axel\programmation\project\node_modules\@sapphire\shapeshift\dist\index.js:1240:70)

Please help me to solve this annoying issue.

Thanks.

Upvotes: 2

Views: 1666

Answers (1)

Akese315
Akese315

Reputation: 63

So I would never thought it was that but the error was caused by an empty string. In fact my function is called hundred of times and i didn't notice there was an empty brand.

So be aware of your empty string.

Upvotes: 2

Related Questions