Advertisement
Guest User

Fox Bot (Beta)

a guest
Feb 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 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 FoxBot
  11. {
  12. class MyBot
  13. {
  14. DiscordClient discord;
  15. CommandService commands;
  16.  
  17. Random rand;
  18.  
  19. string[] RFoxes;
  20. string[] R8ball;
  21.  
  22. public MyBot()
  23. {
  24. rand = new Random();
  25.  
  26. RFoxes = new string[]
  27. {
  28. "Foxes/Fox1.jpg",
  29. "Foxes/Fox2.jpg",
  30. "Foxes/Fox3.jpg",
  31. "Foxes/Fox4.jpg",
  32. "Foxes/Fox5.jpg",
  33. "Foxes/Fox6.jpg",
  34. "Foxes/Fox7.jpg",
  35. "Foxes/Fox8.jpg",
  36. "Foxes/Fox9.jpg",
  37. "Foxes/Fox10.jpg"
  38. };
  39.  
  40. R8ball = new string[]
  41. {
  42. "It is certain",
  43. "It is decidedly so",
  44. "Without a doubt",
  45. "Yes, definitely",
  46. "You may rely on it",
  47. "As I see it, yes",
  48. "Most likely",
  49. "Outlook good",
  50. "Yes",
  51. "Signs point to yes",
  52. "Reply hazy try again",
  53. "Ask again later",
  54. "Better not tell you now",
  55. "Cannot predict now",
  56. "Concentrate and ask again",
  57. "Don't count on it",
  58. "My reply is no",
  59. "My sources say no",
  60. "Outlook not so good",
  61. "Very doubtful"
  62. };
  63.  
  64. discord = new DiscordClient(x =>
  65. {
  66. x.LogLevel = LogSeverity.Info;
  67. x.LogHandler = Log;
  68. });
  69.  
  70. discord.UsingCommands(x =>
  71. {
  72. x.PrefixChar = '~';
  73. x.AllowMentionPrefix = true;
  74. });
  75.  
  76. commands = discord.GetService<CommandService>();
  77.  
  78. RegisterFoxCommand();
  79.  
  80. commands.CreateCommand("test")
  81. .Do(async (e) =>
  82. {
  83. await e.Channel.SendMessage("Hi!");
  84. });
  85. commands.CreateCommand("help")
  86. .Do(async (e) =>
  87. {
  88. await e.User.SendMessage("Nothing to see here (test)");
  89. await e.Channel.SendMessage("```I have sent you my commands!```");
  90. });
  91.  
  92. discord.ExecuteAndWait(async () =>
  93. {
  94. await discord.Connect("MjgyODkzODcwMjA5OTU3ODg5.C4wf0Q.RxXLwEgdr1TWjn-nS5RCbd4qAFg", TokenType.Bot);
  95. discord.SetGame("use ~help for help");
  96. });
  97. }
  98.  
  99. private void RegisterFoxCommand()
  100. {
  101. commands.CreateCommand("Fox")
  102. .Do(async (e) =>
  103. {
  104. int RandomFoxIndex = rand.Next(RFoxes.Length);
  105. string FoxToPost = RFoxes[RandomFoxIndex];
  106. await e.Channel.SendFile(FoxToPost);
  107. });
  108. }
  109.  
  110. private void Register8ballCommand()
  111. {
  112. commands.CreateCommand("8ball")
  113. .Do(async (e) =>
  114. {
  115. int Random8ball = rand.Next(R8ball.Length);
  116. string Answer = R8ball[Random8ball];
  117. await e.Channel.SendMessage(Answer);
  118. });
  119.  
  120. }
  121.  
  122. private void Log(object sender, LogMessageEventArgs e)
  123. {
  124. Console.WriteLine(e.Message);
  125. }
  126. }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement