#Add button to DiscordEmbedBuilder

1 messages · Page 1 of 1 (latest)

spark plank
#

**How i can add a Button to DiscordEmbedBuilder. **
If the Button clicked the Message should be send to another cannel in the same Discord channel. Default is false. I need a Button and a onClick event for the move action.

Can someone help me?

**Code is here: **

DiscordEmbedBuilder discordMessage = new DiscordEmbedBuilder { Color = DiscordColor.Red, Title = title, ImageUrl = product.Image, Url = product.Link, Timestamp= DateTime.UtcNow } .AddFieldExtended("Produkt", product.Title) .AddFieldExtended("Shop", product.Typ?.ToString()) .AddFieldExtended("Link", product.Link) .AddFieldExtended("EK", product.Preis + " €") .AddFieldExtended("VK", product.VK + " €") .AddFieldExtended("Maximale Bestellmenge", maxBestellmenge) .AddFieldExtended("Information zur Lieferrung", status.LieferNotiz) .AddFieldExtended("Hinweis", extraText); await discordChannel.SendMessageAsync(discordMessage);

sweet summit
#

There is no toggle button. only normal buttons and link button

spark plank
sweet summit
#

Use AddComponents and provide a DiscordButtonComponent

spark plank
sweet summit
#

it is on the messagebuilder

spark plank
#

what i can use instead in the messagebuilder for this props

sweet summit
#

create a new DiscordMessageBuilder and use AddEmbed and add you exsisting embed to it

#

and change the sendmessage to the messagebuilder

sweet summit
#

a am a little bit curious

spark plank
# sweet summit What does you AddFieldExtended Method do?

nothing special

public static DiscordEmbedBuilder AddFieldExtended(this DiscordEmbedBuilder builder, string name, string value, bool inline = false) { if (string.IsNullOrWhiteSpace(value)) { return builder; } return builder.AddField(name, value); }

sweet summit
#

ahh only a little check, nice

spark plank
#

how i can change the text of the button and disable the button then?

#

await e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate ,new DiscordInteractionResponseBuilder().WithContent("Erfolgreich verschoben!"));

sweet summit
#

after you send the message?

spark plank
#

i will click on the button then write the message in a new channel

#

and update the button to moved

#

discordClient.ComponentInteractionCreated += async (s, e) => { if(e.Id == "move-to-admin-deals-button") { //Update Button Text and Disable await e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate ,new DiscordInteractionResponseBuilder().WithContent("Erfolgreich verschoben!")); } };

sweet summit
#

You could use Message.ModifyAsync(x => x.ClearComponents()); or use ModifyAsync to only disable the button but its a bit more tricky