public async Task HelpCmd() { var cmds = (await _permService.CService.Commands .Where(c => !c.Attributes.Any(p => p is HiddenAttribute)) .CheckConditions(Context, _services, _permService).ConfigureAwait(false)); if (await UseFancy().ConfigureAwait(false)) { if (await _permService.GetHidePermCommands(Context.Guild).ConfigureAwait(false)) { cmds = cmds.Where(c => c.Module.Name != PermModuleName); } var app = await Context.Client.GetApplicationInfoAsync().ConfigureAwait(false); _permService.AddNewFancy(await new FancyHelpMessage(Context.Channel, Context.User, cmds.ToList(), app).SendMessage().ConfigureAwait(false)); } else { var grouped = cmds.GroupBy(c => c.Module.Name) .Select(g => $"{g.Key}:\n\t`{String.Join("`, `", g.Select(c => c.Aliases.FirstOrDefault()).Distinct())}`") .ToList(); var sb = new StringBuilder("You can use the following commands:\n") .AppendLine($"{String.Join("\n", grouped)}\n") .Append("You can use `help <command>` for more information on that command."); await ReplyAsync(sb.ToString()).ConfigureAwait(false); } }
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); }