geekbot/Geekbot.net/Commands/Help.cs

62 lines
2.2 KiB
C#
Raw Normal View History

using System;
using System.Linq;
2017-09-15 22:56:03 +02:00
using System.Text;
using System.Threading.Tasks;
2017-04-17 16:58:48 +02:00
using Discord.Commands;
using Geekbot.net.Lib;
2017-04-17 16:58:48 +02:00
namespace Geekbot.net.Commands
2017-04-17 16:58:48 +02:00
{
public class Help : ModuleBase
{
private readonly CommandService _commands;
private readonly IErrorHandler _errorHandler;
2017-09-15 22:56:03 +02:00
public Help(CommandService commands, IErrorHandler errorHandler)
2017-09-15 22:56:03 +02:00
{
_commands = commands;
_errorHandler = errorHandler;
2017-09-15 22:56:03 +02:00
}
[Command("help", RunMode = RunMode.Async)]
2017-10-12 16:34:10 +02:00
[Remarks(CommandCategories.Helpers)]
2017-09-15 22:56:03 +02:00
[Summary("List all Commands")]
2017-04-17 16:58:48 +02:00
public async Task GetHelp()
{
try
2017-04-17 16:58:48 +02:00
{
var sb = new StringBuilder();
// sb.AppendLine("```");
// sb.AppendLine("**Geekbot Command list**");
// sb.AppendLine("");
// sb.AppendLine(tp("Name", 15) + tp("Parameters", 19) + "Description");
// foreach (var cmd in _commands.Commands)
// {
// var param = string.Join(", !", cmd.Aliases);
// if (!param.Contains("admin"))
// if (cmd.Parameters.Any())
// sb.AppendLine(tp(param, 15) +
// tp(string.Join(" ", cmd.Parameters.Select(e => e.Summary)), 19) +
// cmd.Summary);
// else
// sb.AppendLine(tp(param, 34) + cmd.Summary);
// }
// sb.AppendLine("```");
sb.AppendLine("For a list of all commands, please visit the following page");
sb.AppendLine("https://geekbot.pizzaandcoffee.rocks/commands");
var dm = await Context.User.GetOrCreateDMChannelAsync();
await dm.SendMessageAsync(sb.ToString());
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
2017-04-17 16:58:48 +02:00
}
2017-09-15 22:56:03 +02:00
}
// Table Padding, short function name because of many usages
private string tp(string text, int shouldHave)
{
return text.PadRight(shouldHave);
2017-04-17 16:58:48 +02:00
}
}
}