question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: Make the fields property in DiscordEmbedBuilder settable.

See original GitHub issue

Details

When trying to add fields to the DiscordEmbedBuilder, it seems that the only way to do so is through the .AddField() method, whereas all of the other properties are settable through object initializer syntax.

Current way of adding embed fields:

var builder = new DiscordEmbedBuilder
{
     Color = DiscordColor.Red,
     Description = "This is an embed"
};

builder.AddField("field1", "I am a field", true);
builder.AddField("field2", "I am also a field", false);

While this certainly works, in my opinion it would look much cleaner to add them through object initializer syntax:

var embed = new DiscordEmbedBuilder
{
     Color = DiscordColor.Red,
     Description = "This is an embed",
     Fields =
     {
          new DiscordEmbedField
          {
               Name = "field1",
               Value = "I am a field",
               Inline = true
          },

          new DiscordEmbedField
          {
               Name = "field2",
               Value = "I am also a field",
               Inline = false
          }
     }
};

This would of course involve making the EmbedField constructor public, as well as changing how the builder internally checks the fields to ensure there are no API errors.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Naamlooscommented, Nov 26, 2019

This message was not sponsored by Outlook for Android

0reactions
Neuheitcommented, Nov 28, 2019

Yeah, just figured it would be nice since a few other libraries had it like that. In that case I’ll close this then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Embeds | discord.js Guide
To add a blank field to the embed, you can use .addFields({ name: '\u200b', value: '\u200b' }) . The above example chains the...
Read more >
[NEW] Embed Builder GUIDE || Discord.JS v14
In addition to our How To Make A Discord Bot in Discord.JS v14 series, this video I will be teaching you how to...
Read more >
Discord.js V14 - Complete Embed Builder Guide
This is a complete embed builder guide for discord bot in discord.js v14! If you need any help, feel free to join the...
Read more >
How can i createoptional fields embed field on my discord ...
1 Answer. Use an if statement to check if the variable exists first. Then you will be able to avoid it saying "null"...
Read more >
Class EmbedBuilder
This builder class is used to build an Embed (rich embed) object that will be ready to be ... The author field builder...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found