Better help part 1
This commit is contained in:
32
EventBot/Misc/Extensions.cs
Normal file
32
EventBot/Misc/Extensions.cs
Normal 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}>"))}";
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user