Adding Initial API support, updating readme
This commit is contained in:
parent
6732506dae
commit
92015d8880
27 changed files with 78 additions and 33 deletions
48
Geekbot.net/Commands/Help.cs
Normal file
48
Geekbot.net/Commands/Help.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Help : ModuleBase
|
||||
{
|
||||
private readonly CommandService commands;
|
||||
|
||||
public Help(CommandService commands)
|
||||
{
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
[Command("help", RunMode = RunMode.Async)]
|
||||
[Summary("List all Commands")]
|
||||
public async Task GetHelp()
|
||||
{
|
||||
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("```");
|
||||
var dm = await Context.User.GetOrCreateDMChannelAsync();
|
||||
await dm.SendMessageAsync(sb.ToString());
|
||||
}
|
||||
|
||||
// Table Padding, short function name because of many usages
|
||||
private string tp(string text, int shouldHave)
|
||||
{
|
||||
return text.PadRight(shouldHave);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue