Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. using Discord;
  2. using Discord.Commands;
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace momiji
  11. {
  12. class Mybot
  13. {
  14. DiscordClient discord;
  15. CommandService commands;
  16.  
  17. Random rand;
  18.  
  19. string[] freshestMeme;
  20.  
  21. string[] randomTexts;
  22.  
  23. public Mybot()
  24. {
  25. rand = new Random();
  26.  
  27. freshestMeme = new string[]
  28. {
  29. "memes/mem1.jpg", //0
  30. "memes/mem2.jpg", //1 and so forth.
  31. };
  32.  
  33. randomTexts = new string[]
  34. {
  35. "Hello",
  36. "Hi",
  37. };
  38.  
  39. discord = new DiscordClient(x =>
  40. {
  41. x.LogLevel = LogSeverity.Info;
  42. x.LogHandler = Log;
  43. });
  44.  
  45. discord.UsingCommands(x =>
  46. {
  47. x.PrefixChar = '!';
  48. x.AllowMentionPrefix = true;
  49. });
  50.  
  51. commands = discord.GetService<CommandService>();
  52.  
  53.  
  54.  
  55.  
  56. //Logging in
  57. discord.ExecuteAndWait(async () =>
  58. {
  59. await discord.Connect("Bot token"); //not a real token, btw.
  60. });
  61. }
  62.  
  63. private void RegisterMemeCommand()
  64. {
  65. commands.CreateCommand("meme") //Seems not to work. No idea.
  66. .Do(async (e) =>
  67. {
  68.  
  69. int randomMemeIndex = rand.Next(randomTexts.Length);
  70. string memeToPost = randomTexts[0];
  71. await e.Channel.SendMessage(memeToPost);
  72. });
  73. }
  74.  
  75. private void Log(object sender, LogMessageEventArgs e)
  76. {
  77. Console.WriteLine(e.Message);
  78. }
  79. }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement