Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Threading.Tasks;
- using Discord;
- using Discord.Commands;
- using Discord.WebSocket;
- using Lux.Discord.LuxBot.Utilities;
- namespace Lux.Discord.LuxBot.Library.Commands
- {
- public class NotifyCommand : CommandBase, ICommand
- {
- private readonly MessageUtilities _messageUtilities = new MessageUtilities();
- public string[] Triggers { get; set; } = { "@notify" };
- public async Task ProcessAsync(SocketCommandContext context)
- {
- var usercontext = context.User;
- var user = (usercontext as IGuildUser);
- var userRoleName = context.Guild.GetRole(user.RoleIds.ToArray()[1]).ToString();
- string reason = StripTriggers(context.Message.Content, Triggers);
- try
- {
- if (RoleChecker.IsAdmin(userRoleName) || RoleChecker.isHigherAdmin(userRoleName) && reason != null && reason != "" && reason != " ")
- {
- await context.Channel.SendMessageAsync(_messageUtilities.FormatEmojis(context.User.Mention + ", you cannot notify someone as an admin."));
- Console.WriteLine("User requested notify but failed");
- }
- else if (context.Channel.Id != RoleChecker.adminChannelId)
- {
- /* if (reason != "" || reason != null)
- {*/
- Console.WriteLine("User has requested help in #general!");
- await context.Channel.SendMessageAsync(context.User.Mention + ", admins have been notified! Please be patient! :smile:");
- var adminChannel = context.Guild.GetTextChannel(RoleChecker.adminChannelId) as SocketTextChannel;
- //var adminChannel1 = context.Channel.GetChannel(RoleChecker.adminChannelId) as SocketTextChannel;
- await adminChannel.SendMessageAsync("(@everyone) User **" + context.User.Username + "** has requested help in **#" + context.Channel.Name + "**!");
- await adminChannel.SendMessageAsync("(@everyone) Reason: " + reason);
- /*
- }
- else
- {
- await context.Channel.SendMessageAsync("You must provide a reason.");
- await context.Channel.SendMessageAsync("Usage: @notify [reason] without '[ ]'");
- await context.Channel.SendMessageAsync("Example: @notify cheater on server 2");
- }*/
- }
- }
- catch
- {
- await context.Channel.SendMessageAsync("Usage: @notify [reason]");
- await context.Channel.SendMessageAsync("Example: @notify cheater on server 2");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement