Advertisement
Kayuwaii

Bot Class

Dec 10th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. //My Bot Class File
  2. using Discord;
  3. using Discord.Commands;
  4.  
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10.  
  11. namespace ConsoleApplication6
  12. {
  13.     class MyBot
  14.     {
  15.         DiscordClient bot;
  16.  
  17.         public MyBot()
  18.         {
  19.  
  20.             bot = new DiscordClient(x =>
  21.             {
  22.                 x.LogLevel = LogSeverity.Info;
  23.                 x.LogHandler = Log;
  24.             });
  25.  
  26.             bot.UsingCommands(x =>
  27.             {
  28.                 x.PrefixChar = '!';
  29.                 x.AllowMentionPrefix = true;
  30.             });
  31.  
  32.             var commands = bot.GetService<CommandService>();
  33.  
  34.             commands.CreateCommand("hello")
  35.                 .Do(async (e) =>
  36.                 {
  37.                     await e.Channel.SendMessage("Sup");
  38.             });
  39.  
  40.             bot.ExecuteAndWait(async () =>
  41.             {
  42.                 await bot.Connect("MyTokenXD", TokenType.Bot);
  43.             });
  44.         }
  45.  
  46. // Log servers in console.
  47.         private void Log(object sender, LogMessageEventArgs e)
  48.         {
  49.             Console.WriteLine(e.Message);
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement