Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. using System.Threading.Tasks;
  2. using Discord;
  3. using Discord.WebSocket;
  4. using System;
  5.  
  6. namespace Hello_World
  7. {
  8. class Program
  9. {
  10. static DiscordSocketClient NotifEventBot = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Verbose });
  11.  
  12. static async Task AsyncBot()
  13. {
  14. await NotifEventBot.LoginAsync(TokenType.Bot, "NDUzNTEyNjk3MzQ3MDQ3NDI1.DfsSrQ.5-mFg4BotcSLrYsSfu-1n0jo964");
  15. await NotifEventBot.StartAsync();
  16. await NotifEventBot.SetGameAsync("Need help? Write .commands");
  17. NotifEventBot.MessageReceived += MessageReceived;
  18.  
  19. NotifEventBot.Log += (logMsg) =>
  20. {
  21. Console.WriteLine(logMsg.Message);
  22. return null;
  23. };
  24. await Task.Delay(-1);
  25. }
  26.  
  27. static async Task MessageReceived(SocketMessage Context)
  28. {
  29. string Message = Context.Content.ToLower();
  30. var Server = (Context.Channel as SocketGuildChannel).Guild;
  31.  
  32. if(Message == ".commands" && Server.Id == 447023289634783232)
  33. {
  34. if (Context.Channel.Id == 458948229787287562)
  35. {
  36. await Context.Channel.SendMessageAsync("Commands:```js\n.role add NotifEvent //gives you the Notif-Event role\n.role delete NotifEvent //removes your Notif-Event role```");
  37. }
  38. else
  39. {
  40. var RepliedMessage = await Context.Channel.SendMessageAsync(Context.Author.Mention + ", commands are disable for this channel. Please use <#458948229787287562>.");
  41. await Task.Delay(7000);
  42. await RepliedMessage.DeleteAsync();
  43. await Context.DeleteAsync();
  44. }
  45. }
  46. else if(Message == ".role add notifevent" && Server.Id == 447023289634783232)
  47. {
  48. if (Context.Channel.Id == 458948229787287562)
  49. {
  50. try
  51. {
  52. await (Context.Author as IGuildUser).AddRoleAsync(Server.GetRole(448400139594366998));
  53. await Context.Channel.SendMessageAsync("You have been given the Notif-Event role!");
  54. }
  55. catch(Exception Error)
  56. {
  57. Console.WriteLine(Error.ToString());
  58. }
  59. }
  60. else
  61. {
  62. var RepliedMessage = await Context.Channel.SendMessageAsync(Context.Author.Mention + ", commands are disable for this channel. Please use <#458948229787287562>.");
  63. await Task.Delay(7000);
  64. await RepliedMessage.DeleteAsync();
  65. await Context.DeleteAsync();
  66. }
  67. }
  68. else if (Message == ".role delete notifevent" && Server.Id == 447023289634783232)
  69. {
  70. if (Context.Channel.Id == 458948229787287562)
  71. {
  72. try
  73. {
  74. await (Context.Author as IGuildUser).RemoveRoleAsync(Server.GetRole(448400139594366998));
  75. await Context.Channel.SendMessageAsync("I successfully removed your Notif-Event role!");
  76. }
  77. catch(Exception Error)
  78. {
  79. Console.WriteLine(Error.ToString());
  80. }
  81. }
  82. else
  83. {
  84. var RepliedMessage = await Context.Channel.SendMessageAsync(Context.Author.Mention + ", commands are disable for this channel. Please use <#458948229787287562>.");
  85. await Task.Delay(7000);
  86. await RepliedMessage.DeleteAsync();
  87. await Context.DeleteAsync();
  88. }
  89. }
  90.  
  91. else if(Message.StartsWith(".announce ") && Context.Channel.Id == 453189954365947904 && Message.Length != 10)
  92. {
  93. try
  94. {
  95. var UserRoles = (Context.Author as IGuildUser).RoleIds;
  96. foreach (var Role in UserRoles)
  97. {
  98. if (Role == 453189351980007424)
  99. {
  100. await (Server.GetChannel(447033846316269568) as ISocketMessageChannel).SendMessageAsync(Context.Content.Substring(10));
  101. await Context.Channel.SendMessageAsync("Successfully announced your message!");
  102. return;
  103. }
  104. }
  105. await Context.Channel.SendMessageAsync("You need to have the Host role before you can use this command.");
  106. }
  107. catch(Exception Error)
  108. {
  109. Console.WriteLine(Error.ToString());
  110. }
  111. }
  112. }
  113.  
  114.  
  115. static void Main(string[] args)
  116. {
  117. AsyncBot().Wait();
  118. }
  119. }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement