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}>"))}"; } } }