daily pastebin goal
50%
SHARE
TWEET

213213

a guest Nov 18th, 2018 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Discord;
  2. using Discord.Commands;
  3. using Discord.WebSocket;
  4. using System;
  5. using System.Threading.Tasks;
  6.  
  7. namespace MyBot
  8. {
  9.     public class Program
  10.     {
  11.         public static void Main(string[] args)
  12.            => new Program().MainAsync().GetAwaiter().GetResult();
  13.  
  14.          
  15.        
  16.        
  17.         private DiscordSocketClient _client;
  18.         private CommandService _commands;
  19.         private CommandHandler _handler;
  20.      
  21.  
  22.         public async Task MainAsync()
  23.         {
  24.          
  25.            
  26.             _client = new DiscordSocketClient();
  27.  
  28.             _client.Log += Log;
  29.             _client.MessageReceived += MessageReceived;
  30.             string token = "";
  31.             await _client.LoginAsync(TokenType.Bot, token);
  32.             await _client.StartAsync();
  33.             _handler = new CommandHandler();
  34.             await Task.Delay(-1);
  35.         }
  36.  
  37.         private async Task MessageReceived(SocketMessage message)
  38.         {
  39.             if (message.Content == "!ping") {
  40.                 await message.Channel.SendMessageAsync("Pong!");
  41.             }
  42.         }
  43.  
  44.         private Task Log(LogMessage msg)
  45.         {
  46.             Console.WriteLine(msg.ToString());
  47.             return Task.CompletedTask;
  48.         }
  49.     }
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top