Exemplo n.º 1
0
        public static async Task <IEnumerable <CommandInfo> > CheckConditions(
            this IEnumerable <CommandInfo> commands,
            ICommandContext ctx,
            IServiceProvider svcs,
            PermissionsService permsvc)
        {
            var ret = new List <CommandInfo>();

            foreach (var cmd in commands)
            {
                var preconditionResult = await cmd.CheckPreconditionsAsync(ctx, svcs).ConfigureAwait(false);

                if (preconditionResult.IsSuccess)
                {
                    if (cmd.Module.Name == PermissionsModule.PermModuleName)
                    {
                        //using (var config = permsvc.ReadOnlyConfig)
                        using (var config = permsvc.LoadConfig())
                        {
                            bool shouldHide = await config.GetHidePermCommands(ctx.Guild).ConfigureAwait(false);

                            if (cmd.Name != nameof(PermissionsModule.HelpCmd) && shouldHide)
                            {
                                continue;
                            }
                        }
                    }
                    ret.Add(cmd);
                }
            }
            return(ret);
        }
 /// <summary> </summary>
 public PermissionsModule(
     PermissionsService permService,
     IServiceProvider services)
 {
     _permService = permService ?? throw new ArgumentNullException(nameof(permService));
     _services    = services;
     //_cmdService = permService.CService;
 }
Exemplo n.º 3
0
        public static async Task <IEnumerable <CommandInfo> > CheckConditions(
            this IEnumerable <CommandInfo> commands,
            ICommandContext ctx,
            IServiceProvider svcs,
            PermissionsService permsvc)
        {
            var ret = new List <CommandInfo>();

            foreach (var cmd in commands)
            {
                if ((await cmd.CheckPreconditionsAsync(ctx, svcs).ConfigureAwait(false)).IsSuccess)
                {
                    if (cmd.Module.Name == PermissionsModule.PermModuleName &&
                        cmd.Name != nameof(PermissionsModule.HelpCmd) &&
                        !(await permsvc.GetHidePermCommands(ctx.Guild).ConfigureAwait(false)))
                    {
                        ret.Add(cmd);
                    }
                }
            }
            return(ret);
        }