You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

EmbedBuilder.Overwrites.md 1.3 kB

7 years ago
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---
  2. uid: Discord.EmbedBuilder
  3. seealso:
  4. - linkId: Discord.EmbedFooterBuilder
  5. - linkId: Discord.EmbedAuthorBuilder
  6. - linkId: Discord.EmbedFieldBuilder
  7. remarks: *content
  8. ---
  9. This builder class is used to build an @Discord.Embed (rich embed)
  10. object that will be ready to be sent via @Discord.IMessageChannel.SendMessageAsync*
  11. after @Discord.EmbedBuilder.Build* is called.
  12. ---
  13. uid: Discord.EmbedBuilder
  14. example: [*content]
  15. ---
  16. The example below builds an embed and sends it to the chat using the
  17. command system.
  18. ```cs
  19. [Command("embed")]
  20. public async Task SendRichEmbedAsync()
  21. {
  22. var embed = new EmbedBuilder
  23. {
  24. // Embed property can be set within object initializer
  25. Title = "Hello world!"
  26. }
  27. // Or with methods
  28. .AddField("Field title",
  29. "Field value. I also support [hyperlink markdown](https://example.com)!")
  30. .WithAuthor(Context.Client.CurrentUser)
  31. .WithFooter(footer => footer.Text = "I am a footer.")
  32. .WithColor(Color.Blue)
  33. .WithTitle("I overwrote \"Hello world!\"")
  34. .WithDescription("I am a description.")
  35. .WithUrl("https://example.com")
  36. .WithCurrentTimestamp()
  37. .Build();
  38. await ReplyAsync(embed: embed);
  39. }
  40. ```
  41. #### Result
  42. ![Embed Example](images/embed-example.png)