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.

getting_started.cs 1.0 KiB

1234567891011121314151617181920212223242526272829
  1. class Program
  2. {
  3. private static DiscordBotClient _client;
  4. static void Main(string[] args)
  5. {
  6. var client = new DiscordClient();
  7. //Log some info to console
  8. client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");
  9. //Echo any message received, provided it didn't come from us
  10. client.MessageCreated += async (s, e) =>
  11. {
  12. if (!e.Message.IsAuthor)
  13. await client.SendMessage(e.Message.ChannelId, e.Message.Text);
  14. };
  15. //Convert our sync method to an async one and blocks this function until the client disconnects
  16. client.Run(async () =>
  17. {
  18. //Connect to the Discord server usinotng our email and password
  19. await client.Connect("discordtest@email.com", "Password123");
  20. //If we are not a member of any server, use our invite code
  21. if (!client.Servers.Any())
  22. await client.AcceptInvite("aaabbbcccdddeee");
  23. });
  24. }
  25. }

Introduction

No Description

No topics