public async Task AllUsrMdls(IUserMessage imsg, PermissionAction action, [Remainder] IUser user) { var channel = (ITextChannel)imsg.Channel; using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.User, PrimaryTargetId = user.Id, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = action.Value, }; var config = uow.GuildConfigs.SetNewRootPermission(channel.Guild.Id, newPerm); Cache.AddOrUpdate(channel.Guild.Id, new PermissionCache() { PermRole = config.PermissionRole, RootPermission = config.RootPermission, Verbose = config.VerbosePermissions }, (id, old) => { old.RootPermission = config.RootPermission; return(old); }); await uow.CompleteAsync().ConfigureAwait(false); } await channel.SendMessageAsync($"{(action.Value ? "✅ Allowed" : "🆗 Denied")} usage of `ALL MODULES` for `{user}` user.").ConfigureAwait(false); }
public async Task ChnlMdl(IUserMessage imsg, Module module, PermissionAction action, [Remainder] ITextChannel chnl) { var channel = (ITextChannel)imsg.Channel; using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.Channel, PrimaryTargetId = chnl.Id, SecondaryTarget = SecondaryPermissionType.Module, SecondaryTargetName = module.Name.ToLowerInvariant(), State = action.Value, }; var config = uow.GuildConfigs.SetNewRootPermission(channel.Guild.Id, newPerm); Cache.AddOrUpdate(channel.Guild.Id, new PermissionCache() { PermRole = config.PermissionRole, RootPermission = config.RootPermission, Verbose = config.VerbosePermissions }, (id, old) => { old.RootPermission = config.RootPermission; return(old); }); await uow.CompleteAsync().ConfigureAwait(false); } await channel.SendMessageAsync($"{(action.Value ? "✅ Allowed" : "🆗 Denied")} usage of `{module.Name}` module for `{chnl}` channel.").ConfigureAwait(false); }
public async Task SrvrCmd(IUserMessage imsg, Command command, PermissionAction action) { var channel = (ITextChannel)imsg.Channel; using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.Server, PrimaryTargetId = 0, SecondaryTarget = SecondaryPermissionType.Command, SecondaryTargetName = command.Text.ToLowerInvariant(), State = action.Value, }; var config = uow.GuildConfigs.SetNewRootPermission(channel.Guild.Id, newPerm); Cache.AddOrUpdate(channel.Guild.Id, new PermissionCache() { PermRole = config.PermissionRole, RootPermission = config.RootPermission, Verbose = config.VerbosePermissions }, (id, old) => { old.RootPermission = config.RootPermission; return(old); }); await uow.CompleteAsync().ConfigureAwait(false); } await channel.SendMessageAsync($"{(action.Value ? "✅ Allowed" : "🆗 Denied")} usage of `{command.Text}` command on this server.").ConfigureAwait(false); }
public async Task Verbose(IUserMessage msg, PermissionAction action) { var channel = (ITextChannel)msg.Channel; using (var uow = DbHandler.UnitOfWork()) { var config = uow.GuildConfigs.For(channel.Guild.Id); config.VerbosePermissions = action.Value; Cache.AddOrUpdate(channel.Guild.Id, new PermissionCache() { PermRole = config.PermissionRole, RootPermission = Permission.GetDefaultRoot(), Verbose = config.VerbosePermissions }, (id, old) => { old.Verbose = config.VerbosePermissions; return(old); }); await uow.CompleteAsync().ConfigureAwait(false); } await channel.SendMessageAsync("ℹ️ I will " + (action.Value ? "now" : "no longer") + " show permission warnings.").ConfigureAwait(false); }