C#C
C#2y ago
Kyede

Parse embed from Json into EmbedBuilderUtils

Hello! :D

For my own convenience and to not clog up my entire class file with endless amounts of lines. I created a json file that holds numerous of preset embeds that I wanna use. However, I'm stuck on an issue and I certainly cannot seem to figure out the issue whatsoever.

{
  "embeds": {
    "first_embed": {
      "title": "First Embed",
      "description": "This is the description for the first embed.",
      "color": 16711680,
      "author": {
        "name": "Author Name",
      },
      "footer": {
        "text": "Footer Text"
      }
    },
    "second_embed": {
      "title": "Second Embed",
      "description": "This is the description for the second embed.",
      "color": 16711680
    }
  }
}


i simply want to parse the embed into a utility that is named EmbedBuilderUtils which is provided by Discord.NET. It basically goes like this

_ = EmbedBuilderUtils.TryParse(Configuration.GetSection("embeds").GetValue<string>("first_embed"), out var builder);

await ReplyAsync(null, false, embed: builder.Build());


This should technically speaking work? unless there is another way to parse first_embed's object entirely. I'm quite lost on this. Any help is appreciated!
Was this page helpful?