public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services) { if (PermHandler.IsAdmin(context.User.Id)) { return(Task.Run(() => PreconditionResult.FromSuccess())); } return(Task.Run(() => PreconditionResult.FromError("Not an Admin."))); }
public async Task AdminRemove(SocketUser OldAdmin) { if (await PermHandler.RemoveAdmin(OldAdmin.Id)) { await Context.Channel.SendMessageAsync("Removed `" + OldAdmin.Mention + "` from the admin list!"); } else { await Context.Channel.SendMessageAsync("The specified user is not an admin!"); } }
public async Task AdminAdd(SocketUser NewAdmin) { if (await PermHandler.AddAdmin(NewAdmin.Username, NewAdmin.Id, Context.User.Username)) { await Context.Channel.SendMessageAsync("Added `" + NewAdmin.Mention + "` to my Admins!"); } else { await Context.Channel.SendMessageAsync("This user is already an admin!"); } }
public async Task BlackListRemove(ulong ChannelID = 0) { SocketTextChannel BLChannel = ChannelID != 0 ? Global.Kuro.Client.GetChannel(ChannelID) as SocketTextChannel : Context.Channel as SocketTextChannel; if (await PermHandler.RemoveBlackList(BLChannel)) { await Context.Channel.SendMessageAsync("Removed `" + ChannelID + "` from the BlackListed channels!"); } else { await Context.Channel.SendMessageAsync("This channel is not blacklisted!"); } }
public async Task BlackListAdd(ulong ChannelID = 0) { SocketTextChannel BLChannel = ChannelID != 0 ? Global.Kuro.Client.GetChannel(ChannelID) as SocketTextChannel : Context.Channel as SocketTextChannel; if (await PermHandler.AddBlackList(BLChannel, Context.User.Username)) { await Context.Channel.SendMessageAsync("Added `" + BLChannel.Id + "` to the BlackListed channels!"); } else { await Context.Channel.SendMessageAsync("This channel is already blacklisted!"); } }
private async Task HandleCommandAsync(SocketMessage messageParam) { SocketUserMessage message = messageParam as SocketUserMessage; if (message == null || (PermHandler.BlackListed(message.Channel as SocketTextChannel) && !PermHandler.IsAdmin(message.Author.Id))) { return; } int argPos = 0; if (!message.HasCharPrefix('-', ref argPos)) { return; } SocketCommandContext context = new SocketCommandContext(Client, message); IResult result = await Commands.ExecuteAsync(context, argPos, Services); if (!result.IsSuccess) { switch (result.Error) { case CommandError.UnknownCommand: await context.Channel.SendMessageAsync("Unknown command. Try `-help` for list of commands!"); break; case CommandError.BadArgCount: await context.Channel.SendMessageAsync("Wrong input! Please try something else."); break; case CommandError.UnmetPrecondition: await context.Channel.SendMessageAsync("You can not use this command!"); break; default: if (PermHandler.IsAdmin(context.Message.Author.Id)) { await context.Message.Author.SendMessageAsync(result.ErrorReason); await context.Channel.SendMessageAsync("Something went wrong! Please tell an admin! :("); } else { await context.Channel.SendMessageAsync("Something went wrong! Please tell an admin! :("); } break; } } }