Advertisement
niels900000

notify command

Jul 4th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using Discord;
  5. using Discord.Commands;
  6. using Discord.WebSocket;
  7. using Lux.Discord.LuxBot.Utilities;
  8.  
  9. namespace Lux.Discord.LuxBot.Library.Commands
  10. {
  11. public class NotifyCommand : CommandBase, ICommand
  12. {
  13. private readonly MessageUtilities _messageUtilities = new MessageUtilities();
  14. public string[] Triggers { get; set; } = { "@notify" };
  15. public async Task ProcessAsync(SocketCommandContext context)
  16. {
  17. var usercontext = context.User;
  18.  
  19. var user = (usercontext as IGuildUser);
  20.  
  21. var userRoleName = context.Guild.GetRole(user.RoleIds.ToArray()[1]).ToString();
  22.  
  23. string reason = StripTriggers(context.Message.Content, Triggers);
  24. try
  25. {
  26. if (RoleChecker.IsAdmin(userRoleName) || RoleChecker.isHigherAdmin(userRoleName) && reason != null && reason != "" && reason != " ")
  27. {
  28. await context.Channel.SendMessageAsync(_messageUtilities.FormatEmojis(context.User.Mention + ", you cannot notify someone as an admin."));
  29. Console.WriteLine("User requested notify but failed");
  30.  
  31. }
  32. else if (context.Channel.Id != RoleChecker.adminChannelId)
  33. {
  34. /* if (reason != "" || reason != null)
  35. {*/
  36. Console.WriteLine("User has requested help in #general!");
  37. await context.Channel.SendMessageAsync(context.User.Mention + ", admins have been notified! Please be patient! :smile:");
  38. var adminChannel = context.Guild.GetTextChannel(RoleChecker.adminChannelId) as SocketTextChannel;
  39.  
  40. //var adminChannel1 = context.Channel.GetChannel(RoleChecker.adminChannelId) as SocketTextChannel;
  41.  
  42. await adminChannel.SendMessageAsync("(@everyone) User **" + context.User.Username + "** has requested help in **#" + context.Channel.Name + "**!");
  43. await adminChannel.SendMessageAsync("(@everyone) Reason: " + reason);
  44.  
  45.  
  46. /*
  47. }
  48. else
  49. {
  50. await context.Channel.SendMessageAsync("You must provide a reason.");
  51. await context.Channel.SendMessageAsync("Usage: @notify [reason] without '[ ]'");
  52. await context.Channel.SendMessageAsync("Example: @notify cheater on server 2");
  53. }*/
  54. }
  55. }
  56. catch
  57. {
  58. await context.Channel.SendMessageAsync("Usage: @notify [reason]");
  59. await context.Channel.SendMessageAsync("Example: @notify cheater on server 2");
  60. }
  61.  
  62.  
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement