Better help part 1

This commit is contained in:
Karolis2011
2019-06-19 23:59:48 +03:00
parent 9ac6343406
commit b5702faa31
3 changed files with 113 additions and 20 deletions

View File

@@ -0,0 +1,32 @@
using Discord;
using Discord.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EventBot.Misc
{
public static class Extensions
{
public static ContextType GetContextType(this ICommandContext context)
{
ContextType type = 0;
if (context.Channel is IGuildChannel)
type |= ContextType.Guild;
if (context.Channel is IDMChannel)
type |= ContextType.DM;
if (context.Channel is IGroupChannel)
type |= ContextType.Group;
return type;
}
public static bool IsContextType(this ICommandContext context, ContextType type) => (context.GetContextType() & type) != 0;
public static string FormatCallHelpString(this CommandInfo command)
{
return $"{command.Aliases[0]} {string.Join(" ", command.Parameters.Select(p => p.IsOptional ? $"[{p.Name}]" : $"<{p.Name}>"))}";
}
}
}