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.

Program.cs 1.3 KiB

12345678910111213141516171819202122232425262728293031323334
  1. using Discord;
  2. using Discord.Webhook;
  3. using System.Threading.Tasks;
  4. namespace WebHookClient
  5. {
  6. // This is a minimal example of using Discord.Net's Webhook Client
  7. // Webhooks are send-only components of Discord that allow you to make a POST request
  8. // To a channel specific URL to send a message to that channel.
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. => new Program().MainAsync().GetAwaiter().GetResult();
  13. public async Task MainAsync()
  14. {
  15. // The webhook url follows the format https://discord.com/api/webhooks/{id}/{token}
  16. // Because anyone with the webhook URL can use your webhook
  17. // you should NOT hard code the URL or ID + token into your application.
  18. using (var client = new DiscordWebhookClient("https://discord.com/api/webhooks/123/abc123"))
  19. {
  20. var embed = new EmbedBuilder
  21. {
  22. Title = "Test Embed",
  23. Description = "Test Description"
  24. };
  25. // Webhooks are able to send multiple embeds per message
  26. // As such, your embeds must be passed as a collection.
  27. await client.SendMessageAsync(text: "Send a message to this webhook!", embeds: new[] { embed.Build() });
  28. }
  29. }
  30. }
  31. }