예제 #1
0
        public async Task DisplayCommandsAsync()
        {
            StringBuilder builder = new StringBuilder()
                                    .AppendLine("Here is a list of useable commands!");

            var categorizedCommands = CustomCommands.GetCommands()
                                      .OrderBy(c => c.Name)
                                      .GroupBy(c => (c.Features.FirstOrDefault(f => f is CategoryFeature) as CategoryFeature)?.Category ?? null);

            foreach (var category in categorizedCommands)
            {
                string categoryDisplayName = new CultureInfo("en-US", false).TextInfo.ToTitleCase(category.Key ?? "uncategorized");

                builder.AppendLine();
                builder.AppendLine($"**{categoryDisplayName}**");
                foreach (var command in category)
                {
                    builder.AppendLine(command.Name);
                }
            }

            await GetDefaultBuilder()
            .WithDescription(builder.ToString())
            .Build()
            .SendToChannel(Context.Channel);
        }
예제 #2
0
        public async Task DisplayCommandsAsync()
        {
            StringBuilder builder = new StringBuilder()
                                    .AppendLine("Here is a list of useable commands!")
                                    .AppendLine()
                                    .AppendJoin('\n', CustomCommands.GetCommands().Select(c => c.Name));

            await GetDefaultBuilder()
            .WithDescription(builder.ToString())
            .Build()
            .SendToChannel(Context.Channel);
        }