Feature: Make the fields property in DiscordEmbedBuilder settable.
See original GitHub issueDetails
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:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This message was not sponsored by Outlook for Android
Yeah, just figured it would be nice since a few other libraries had it like that. In that case I’ll close this then.