public async Task UsrCmd(CommandOrCrInfo command, PermissionAction action, [Remainder] IGuildUser user) { await _service.AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.User, PrimaryTargetId = user.Id, SecondaryTarget = SecondaryPermissionType.Command, SecondaryTargetName = command.Name.ToLowerInvariant(), State = action.Value, IsCustomCommand = command.IsCustom, }).ConfigureAwait(false); if (action.Value) { await ReplyConfirmLocalizedAsync("ux_enable", Format.Code(command.Name), GetText("of_command"), Format.Code(user.ToString())).ConfigureAwait(false); } else { await ReplyConfirmLocalizedAsync("ux_disable", Format.Code(command.Name), GetText("of_command"), Format.Code(user.ToString())).ConfigureAwait(false); } }
public async Task AllSrvrMdls(PermissionAction action) { var newPerm = new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Server, PrimaryTargetId = 0, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = action.Value, }; var allowUser = new Permissionv2 { PrimaryTarget = PrimaryPermissionType.User, PrimaryTargetId = Context.User.Id, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = true, }; await _service.AddPermissions(Context.Guild.Id, newPerm, allowUser); if (action.Value) { await ReplyConfirmLocalized("asm_enable").ConfigureAwait(false); } else { await ReplyConfirmLocalized("asm_disable").ConfigureAwait(false); } }
public async Task ChnlCmd(IUserMessage imsg, Command command, PermissionAction action, [Remainder] ITextChannel chnl) { var channel = (ITextChannel)imsg.Channel; try { using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.Channel, PrimaryTargetId = chnl.Id, 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); } } catch (Exception ex) { Console.WriteLine(ex); } await channel.SendMessageAsync($"{(action.Value ? "Allowed" : "Denied")} usage of `{command.Text}` command for `{chnl}` channel.").ConfigureAwait(false); }
public async Task AllRoleMdls(PermissionAction action, [Remainder] IRole role) { if (role == role.Guild.EveryoneRole) { return; } await _service.AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Role, PrimaryTargetId = role.Id, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = action.Value, }); if (action.Value) { await ReplyConfirmLocalized("arm_enable", Format.Code(role.Name)).ConfigureAwait(false); } else { await ReplyConfirmLocalized("arm_disable", Format.Code(role.Name)).ConfigureAwait(false); } }
public async Task SrvrCmd(CommandOrCrInfo command, PermissionAction action) { await _service.AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Server, PrimaryTargetId = 0, SecondaryTarget = SecondaryPermissionType.Command, SecondaryTargetName = command.Name.ToLowerInvariant(), State = action.Value, IsCustomCommand = command.IsCustom, }).ConfigureAwait(false); if (action.Value) { await ReplyConfirmLocalized("sx_enable", Format.Code(command.Name), GetText("of_command")).ConfigureAwait(false); } else { await ReplyConfirmLocalized("sx_disable", Format.Code(command.Name), GetText("of_command")).ConfigureAwait(false); } }
public async Task RoleCmd(CommandOrCrInfo command, PermissionAction action, [Leftover] IRole role) { if (role == role.Guild.EveryoneRole) { return; } await _service.AddPermissions(ctx.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Role, PrimaryTargetId = role.Id, SecondaryTarget = SecondaryPermissionType.Command, SecondaryTargetName = command.Name.ToLowerInvariant(), State = action.Value, IsCustomCommand = command.IsCustom, }).ConfigureAwait(false); if (action.Value) { await ReplyConfirmLocalizedAsync("rx_enable", Format.Code(command.Name), GetText("of_command"), Format.Code(role.Name)).ConfigureAwait(false); } else { await ReplyConfirmLocalizedAsync("rx_disable", Format.Code(command.Name), GetText("of_command"), Format.Code(role.Name)).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 ChnlCmd(CommandOrCrInfo command, PermissionAction action, [Leftover] ITextChannel chnl) { await _service.AddPermissions(ctx.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Channel, PrimaryTargetId = chnl.Id, SecondaryTarget = SecondaryPermissionType.Command, SecondaryTargetName = command.Name.ToLowerInvariant(), State = action.Value, IsCustomCommand = command.IsCustom, }).ConfigureAwait(false); if (action.Value) { await ReplyConfirmLocalizedAsync("cx_enable", Format.Code(command.Name), GetText("of_command"), Format.Code(chnl.Name)).ConfigureAwait(false); } else { await ReplyConfirmLocalizedAsync("cx_disable", Format.Code(command.Name), GetText("of_command"), Format.Code(chnl.Name)).ConfigureAwait(false); } }
public async Task RoleMdl(ModuleOrCrInfo module, PermissionAction action, [Remainder] IRole role) { if (role == role.Guild.EveryoneRole) { return; } await _service.AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Role, PrimaryTargetId = role.Id, SecondaryTarget = SecondaryPermissionType.Module, SecondaryTargetName = module.Name.ToLowerInvariant(), State = action.Value, }); if (action.Value) { await ReplyConfirmLocalized("rx_enable", Format.Code(module.Name), GetText("of_module"), Format.Code(role.Name)).ConfigureAwait(false); } else { await ReplyConfirmLocalized("rx_disable", Format.Code(module.Name), GetText("of_module"), Format.Code(role.Name)).ConfigureAwait(false); } }
public async Task UsrMdl(ModuleOrCrInfo module, PermissionAction action, [Remainder] IGuildUser user) { await _service.AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.User, PrimaryTargetId = user.Id, SecondaryTarget = SecondaryPermissionType.Module, SecondaryTargetName = module.Name.ToLowerInvariant(), State = action.Value, }); if (action.Value) { await ReplyConfirmLocalized("ux_enable", Format.Code(module.Name), GetText("of_module"), Format.Code(user.ToString())).ConfigureAwait(false); } else { await ReplyConfirmLocalized("ux_disable", Format.Code(module.Name), GetText("of_module"), Format.Code(user.ToString())).ConfigureAwait(false); } }
public async Task ChnlCmd(CommandOrCrInfo command, PermissionAction action, [Remainder] ITextChannel chnl) { await AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Channel, PrimaryTargetId = (long)chnl.Id, SecondaryTarget = SecondaryPermissionType.Command, SecondaryTargetName = command.Name.ToLowerInvariant(), State = action.Value, }); if (action.Value) { await ReplyConfirmLocalized("cx_enable", Format.Code(command.Name), GetText("of_command"), Format.Code(chnl.Name)).ConfigureAwait(false); } else { await ReplyConfirmLocalized("cx_disable", Format.Code(command.Name), GetText("of_command"), Format.Code(chnl.Name)).ConfigureAwait(false); } }
public async Task AllSrvrMdls(PermissionAction action) { using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.Server, PrimaryTargetId = 0, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = action.Value, }; uow.GuildConfigs.SetNewRootPermission(Context.Guild.Id, newPerm); var allowUser = new Permission { PrimaryTarget = PrimaryPermissionType.User, PrimaryTargetId = Context.User.Id, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = true, }; var config = uow.GuildConfigs.SetNewRootPermission(Context.Guild.Id, allowUser); Cache.AddOrUpdate(Context.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 Context.Channel.SendConfirmAsync($"{(action.Value ? "✅ Allowed" : "🆗 Denied")} usage of `ALL MODULES` on this server.").ConfigureAwait(false); }
public async Task ChnlCmd(CommandInfo command, PermissionAction action, [Remainder] ITextChannel chnl) { try { using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.Channel, PrimaryTargetId = chnl.Id, SecondaryTarget = SecondaryPermissionType.Command, SecondaryTargetName = command.Aliases.First().ToLowerInvariant(), State = action.Value, }; var config = uow.GuildConfigs.SetNewRootPermission(Context.Guild.Id, newPerm); Cache.AddOrUpdate(Context.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); } } catch (Exception ex) { _log.Error(ex); } await Context.Channel.SendConfirmAsync($"{(action.Value ? "✅ Allowed" : "🆗 Denied")} usage of `{command.Aliases.First()}` command for `{chnl}` channel.").ConfigureAwait(false); }
public async Task AllRoleMdls(PermissionAction action, [Remainder] IRole role) { if (role == role.Guild.EveryoneRole) { return; } using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.Role, PrimaryTargetId = role.Id, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = action.Value, }; var config = uow.GuildConfigs.SetNewRootPermission(Context.Guild.Id, newPerm); Cache.AddOrUpdate(Context.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 Context.Channel.SendConfirmAsync($"{(action.Value ? "✅ Allowed" : "🆗 Denied")} usage of `ALL MODULES` for `{role}` role.").ConfigureAwait(false); }
public async Task ChnlMdl(ModuleOrCrInfo module, PermissionAction action, [Remainder] ITextChannel chnl) { await _service.AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Channel, PrimaryTargetId = chnl.Id, SecondaryTarget = SecondaryPermissionType.Module, SecondaryTargetName = module.Name.ToLowerInvariant(), State = action.Value, }); if (action.Value) { await ReplyConfirmLocalized("cx_enable", Format.Code(module.Name), GetText("of_module"), Format.Code(chnl.Name)).ConfigureAwait(false); } else { await ReplyConfirmLocalized("cx_disable", Format.Code(module.Name), GetText("of_module"), Format.Code(chnl.Name)).ConfigureAwait(false); } }
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 AllUsrMdls(PermissionAction action, [Remainder] IUser user) { 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(Context.Guild.Id, newPerm); Cache.AddOrUpdate(Context.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); } if (action.Value) { await ReplyConfirmLocalized("aum_enable", Format.Code(user.ToString())).ConfigureAwait(false); } else { await ReplyConfirmLocalized("aum_disable", Format.Code(user.ToString())).ConfigureAwait(false); } }
public async Task SrvrMdl(ModuleInfo module, PermissionAction action) { using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.Server, PrimaryTargetId = 0, SecondaryTarget = SecondaryPermissionType.Module, SecondaryTargetName = module.Name.ToLowerInvariant(), State = action.Value, }; var config = uow.GuildConfigs.SetNewRootPermission(Context.Guild.Id, newPerm); Cache.AddOrUpdate(Context.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); } if (action.Value) { await ReplyConfirmLocalized("sx_enable", Format.Code(module.Name), GetText("of_module")).ConfigureAwait(false); } else { await ReplyConfirmLocalized("sx_disable", Format.Code(module.Name), GetText("of_module")).ConfigureAwait(false); } }
public async Task Verbose(PermissionAction action) { using (var uow = DbHandler.UnitOfWork()) { var config = uow.GuildConfigs.For(Context.Guild.Id, set => set); config.VerbosePermissions = action.Value; Cache.AddOrUpdate(Context.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 Context.Channel.SendConfirmAsync("ℹ️ I will " + (action.Value ? "now" : "no longer") + " show permission warnings.").ConfigureAwait(false); }
public async Task Verbose(PermissionAction action) { using (var uow = _db.GetDbContext()) { var config = uow.GuildConfigs.GcWithPermissionsv2For(ctx.Guild.Id); config.VerbosePermissions = action.Value; await uow.SaveChangesAsync(); _service.UpdateCache(config); } if (action.Value) { await ReplyConfirmLocalizedAsync("verbose_true").ConfigureAwait(false); } else { await ReplyConfirmLocalizedAsync("verbose_false").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); }
public async Task Verbose(PermissionAction action) { using (var uow = _db.UnitOfWork) { var config = uow.GuildConfigs.GcWithPermissionsv2For(Context.Guild.Id); config.VerbosePermissions = action.Value; await uow.CompleteAsync().ConfigureAwait(false); _service.UpdateCache(config); } if (action.Value) { await ReplyConfirmLocalized("verbose_true").ConfigureAwait(false); } else { await ReplyConfirmLocalized("verbose_false").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); }
public async Task RoleCmd(CommandInfo command, PermissionAction action, [Remainder] IRole role) { if (role == role.Guild.EveryoneRole) { return; } using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.Role, PrimaryTargetId = role.Id, SecondaryTarget = SecondaryPermissionType.Command, SecondaryTargetName = command.Aliases.First().ToLowerInvariant(), State = action.Value, }; var config = uow.GuildConfigs.SetNewRootPermission(Context.Guild.Id, newPerm); Cache.AddOrUpdate(Context.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); } if (action.Value) { await ReplyConfirmLocalized("rx_enable", Format.Code(command.Aliases.First()), GetText("of_command"), Format.Code(role.Name)).ConfigureAwait(false); } else { await ReplyConfirmLocalized("rx_disable", Format.Code(command.Aliases.First()), GetText("of_command"), Format.Code(role.Name)).ConfigureAwait(false); } }
public async Task AllChnlMdls(PermissionAction action, [Remainder] ITextChannel chnl) { await _service.AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Channel, PrimaryTargetId = chnl.Id, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = action.Value, }); if (action.Value) { await ReplyConfirmLocalized("acm_enable", Format.Code(chnl.Name)).ConfigureAwait(false); } else { await ReplyConfirmLocalized("acm_disable", Format.Code(chnl.Name)).ConfigureAwait(false); } }
public async Task AllUsrMdls(PermissionAction action, [Remainder] IUser user) { await _service.AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.User, PrimaryTargetId = user.Id, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = action.Value, }); if (action.Value) { await ReplyConfirmLocalized("aum_enable", Format.Code(user.ToString())).ConfigureAwait(false); } else { await ReplyConfirmLocalized("aum_disable", Format.Code(user.ToString())).ConfigureAwait(false); } }
public async Task UsrMdl(ModuleInfo module, PermissionAction action, [Remainder] IGuildUser user) { using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.User, PrimaryTargetId = user.Id, SecondaryTarget = SecondaryPermissionType.Module, SecondaryTargetName = module.Name.ToLowerInvariant(), State = action.Value, }; var config = uow.GuildConfigs.SetNewRootPermission(Context.Guild.Id, newPerm); Cache.AddOrUpdate(Context.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 Context.Channel.SendConfirmAsync($"{(action.Value ? "✅ Allowed" : "🆗 Denied")} usage of `{module.Name}` module for `{user}` user.").ConfigureAwait(false); }
public async Task Verbose(PermissionAction action) { using (var uow = DbHandler.UnitOfWork()) { var config = uow.GuildConfigs.For(Context.Guild.Id, set => set); config.VerbosePermissions = action.Value; Cache.AddOrUpdate(Context.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); } if (action.Value) { await ReplyConfirmLocalized("verbose_true").ConfigureAwait(false); } else { await ReplyConfirmLocalized("verbose_false").ConfigureAwait(false); } }
public async Task SrvrMdl(ModuleOrCrInfo module, PermissionAction action) { await _service.AddPermissions(Context.Guild.Id, new Permissionv2 { PrimaryTarget = PrimaryPermissionType.Server, PrimaryTargetId = 0, SecondaryTarget = SecondaryPermissionType.Module, SecondaryTargetName = module.Name.ToLowerInvariant(), State = action.Value, }); if (action.Value) { await ReplyConfirmLocalized("sx_enable", Format.Code(module.Name), GetText("of_module")).ConfigureAwait(false); } else { await ReplyConfirmLocalized("sx_disable", Format.Code(module.Name), GetText("of_module")).ConfigureAwait(false); } }
public async Task AllSrvrMdls(IUserMessage imsg, PermissionAction action) { var channel = (ITextChannel)imsg.Channel; using (var uow = DbHandler.UnitOfWork()) { var newPerm = new Permission { PrimaryTarget = PrimaryPermissionType.Server, PrimaryTargetId = 0, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = action.Value, }; uow.GuildConfigs.SetNewRootPermission(channel.Guild.Id, newPerm); var allowUser = new Permission { PrimaryTarget = PrimaryPermissionType.User, PrimaryTargetId = imsg.Author.Id, SecondaryTarget = SecondaryPermissionType.AllModules, SecondaryTargetName = "*", State = true, }; var config = uow.GuildConfigs.SetNewRootPermission(channel.Guild.Id, allowUser); 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` on this server.").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 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); }