Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using Discord;
  2. using Discord.WebSocket;
  3.  
  4. class Program
  5. {
  6. // Convert our sync-main to an async main method
  7. static void Main(string[] args) => new Program().Run().GetAwaiter().GetResult();
  8.  
  9. // Create a DiscordClient with WebSocket support
  10. private DiscordSocketClient client;
  11.  
  12. public async Task Run()
  13. {
  14. client = new DiscordSocketClient();
  15.  
  16. // Place the token of your bot account here
  17. string token = "Yes,i did replace the token";
  18.  
  19. // Hook into the MessageReceived event on DiscordSocketClient
  20. client.MessageReceived += async (message) =>
  21. { // Check to see if the Message Content is "!ping"
  22. if (message.Content == "!ping")
  23. // Send 'pong' back to the channel the message was sent in
  24. await message.Channel.SendMessageAsync("pong");
  25. };
  26.  
  27. // Configure the client to use a Bot token, and use our token
  28. await client.LoginAsync(TokenType.Bot, token);
  29. // Connect the client to Discord's gateway
  30. await client.ConnectAsync();
  31.  
  32. // Block this task until the program is exited.
  33. await Task.Delay(-1);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement