Discord-Net-Labs / Discord.Net-Labs

An experimental fork of Discord.Net that implements the newest discord features for testing and development to eventually get merged into Discord.Net
https://labs.discordnet.dev
MIT License
156 stars 42 forks source link

Adding New Extensions #274

Closed ghost closed 2 years ago

ghost commented 2 years ago

EmbedFieldBuilderExtensions

Hello 👋, i added a new Extension for EmbedFieldBuilder, its can make the codes more beautiful & clean .

with Extension

       new EmbedBuilder()
        {
            Title = "",
            Description = "",
            Fields = new List<EmbedFieldBuilder>()
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
        }.Build();

Without Extension

 new EmbedBuilder()
        {
            Title = "",
            Description = "",
            Fields = new List<EmbedFieldBuilder>()
            {
                 new EmbedFieldBuilder()
                 {
                    IsInline=true,
                    Name="Name",
                    Value ="valuse"
                 },
                 new EmbedFieldBuilder()
                {
                    IsInline=true,
                    Name="Name",
                    Value ="valuse"
                },
                  new EmbedFieldBuilder()
                {
                    IsInline=true,
                    Name="Name",
                    Value ="valuse"
                },
                   new EmbedFieldBuilder()
                {
                    IsInline=true,
                    Name="Name",
                    Value ="valuse"
                },
                    new EmbedFieldBuilder()
                {
                    IsInline=true,
                    Name="Name",
                    Value ="valuse"
                },
            }
        }.Build();

Format Extensions (User, Channel, Role Tags + Emote)

quinchs commented 2 years ago

Theres already a EmbedBuilder.WithFields and EmbedBuilder.AddField method.

ghost commented 2 years ago

Theres already a EmbedBuilder.WithFields and EmbedBuilder.AddField method.

So is possible to making fields like that (in EmbedBuilder blocks) or something for adding Filed to Filed List.

 new EmbedBuilder()
        {
            Title = "",
            Description = "",
            Fields = new List<EmbedFieldBuilder>()
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
            .WithField("Name", "Value", false)
        }.Build();
quinchs commented 2 years ago

It would be

new EmbedBuilder()
    .WithTitle("Hello World!")
    .AddField("Field Title", "Field content")
ghost commented 2 years ago

It would be

new EmbedBuilder()
    .WithTitle("Hello World!")
    .AddField("Field Title", "Field content")

yes, i see, but its can be good still for adding fields in the body, also i added some Formats, check them too. anyways if was good, merge it, if not reject.

quinchs commented 2 years ago

All the additions that your making already exist in an easier form. I just dont see a need for them, sorry.