Help part 2
This commit is contained in:
@@ -26,7 +26,22 @@ namespace EventBot.Misc
|
|||||||
|
|
||||||
public static string FormatCallHelpString(this CommandInfo command)
|
public static string FormatCallHelpString(this CommandInfo command)
|
||||||
{
|
{
|
||||||
return $"{command.Aliases[0]} {string.Join(" ", command.Parameters.Select(p => p.IsOptional ? $"[{p.Name}]" : $"<{p.Name}>"))}";
|
return $"{command.Aliases[0]} {string.Join(" ", command.Parameters.Select(p => p.FormatParameter()))}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string FormatParameter(this ParameterInfo p) => p.IsOptional ? $"[{p.Name}]" : $"<{p.Name}>";
|
||||||
|
public static string FormatParameterType(this ParameterInfo p)
|
||||||
|
{
|
||||||
|
var @switch = new Dictionary<Type, Func<ParameterInfo, string>>()
|
||||||
|
{
|
||||||
|
{ typeof(int), (_) => "Number" },
|
||||||
|
|
||||||
|
};
|
||||||
|
if (@switch.ContainsKey(p.Type))
|
||||||
|
return @switch[p.Type](p);
|
||||||
|
else
|
||||||
|
return p.Type.Name;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -73,7 +73,8 @@ namespace EventBot.Modules
|
|||||||
var pagedCommands = _commands.Commands
|
var pagedCommands = _commands.Commands
|
||||||
.OrderBy(c => c.Aliases[0])
|
.OrderBy(c => c.Aliases[0])
|
||||||
.Where(c => c.Attributes
|
.Where(c => c.Attributes
|
||||||
.Select(a => {
|
.Select(a =>
|
||||||
|
{
|
||||||
switch (a)
|
switch (a)
|
||||||
{
|
{
|
||||||
case NoHelpAttribute _:
|
case NoHelpAttribute _:
|
||||||
@@ -94,7 +95,8 @@ namespace EventBot.Modules
|
|||||||
{
|
{
|
||||||
Title = "Command list",
|
Title = "Command list",
|
||||||
Color = Color.DarkBlue,
|
Color = Color.DarkBlue,
|
||||||
Pages = pagedCommands.Select(p => string.Join("\r\n", p.Select(c => {
|
Pages = pagedCommands.Select(p => string.Join("\r\n", p.Select(c =>
|
||||||
|
{
|
||||||
if (c.MA)
|
if (c.MA)
|
||||||
return $"`{c.CI.FormatCallHelpString()}` - **{c.CI.Name}**";
|
return $"`{c.CI.FormatCallHelpString()}` - **{c.CI.Name}**";
|
||||||
else
|
else
|
||||||
@@ -108,6 +110,45 @@ namespace EventBot.Modules
|
|||||||
};
|
};
|
||||||
await PagedReplyAsync(pager);
|
await PagedReplyAsync(pager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command]
|
||||||
|
[Name("Help")]
|
||||||
|
[Summary("Shows detailed info about command.")]
|
||||||
|
public async Task DefaultHelpAsync([Summary("Command ")][Remainder] string commandAlias)
|
||||||
|
{
|
||||||
|
var command = _commands.Commands.Where(c => c.Aliases.Contains(commandAlias)).FirstOrDefault();
|
||||||
|
if (command == null)
|
||||||
|
throw new Exception("This command was not found.");
|
||||||
|
var embed = new EmbedBuilder()
|
||||||
|
.WithTitle(command.Name)
|
||||||
|
.WithDescription(command.Summary)
|
||||||
|
.WithColor(Color.DarkTeal);
|
||||||
|
embed.AddField("Module", command.Module.Name, true);
|
||||||
|
if (command.Aliases.Count > 1)
|
||||||
|
embed.AddField("Aliases", string.Join(", ", command.Aliases));
|
||||||
|
if(command.Parameters.Count > 0)
|
||||||
|
embed.AddField("Parameters",
|
||||||
|
string.Join("\r\n", command.Parameters.Select(p => $"`{p.FormatParameter()}` *(Type: {p.FormatParameterType()})* - **{p.Summary}** {(p.IsRemainder ? "_No quotes are needed, when providing this parameter._" : "")}" ))
|
||||||
|
);
|
||||||
|
|
||||||
|
await ReplyAsync($"I got this information about command `{commandAlias}`:", embed: embed.Build());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("types")]
|
||||||
|
[Name("Type help")]
|
||||||
|
[Priority(1)]
|
||||||
|
[Summary("Shows information about avaivable types for command paramters.")]
|
||||||
|
[NoHelp]
|
||||||
|
public async Task TypeHelp()
|
||||||
|
{
|
||||||
|
await ReplyAsync($"There are following avaivable types for command input: \r\n" +
|
||||||
|
$"***String*** - The most basic text input, must be qouted if there is space inside. Ex: `\"This is a string\"`; `ThisCanBeUsedAlsoAsString`\r\n" +
|
||||||
|
$"***Number*** - Just a simple number. Ex: `1`; `-2`; `1523`\r\n" +
|
||||||
|
$"***User*** - Mention or ID of user. Ex: `360710685186850826`; `Skull132#1984`; {Context.Client.CurrentUser.Mention}\r\n" +
|
||||||
|
$"***Event*** - ID of event. Just positive numbers 🙂.\r\n" +
|
||||||
|
$"***EventRole*** - ID of event's role. Also positive numbers 😊.\r\n" +
|
||||||
|
$"***EventParticipactionType*** - What type you want. Ex: `Quick`; `Detailed`");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@ using Discord.Addons.Interactive;
|
|||||||
namespace EventBot.Modules
|
namespace EventBot.Modules
|
||||||
{
|
{
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[Name("Event")]
|
||||||
public class EventModule : ModuleBase<SocketCommandContext>
|
public class EventModule : ModuleBase<SocketCommandContext>
|
||||||
{
|
{
|
||||||
private readonly EventManagementService _events;
|
private readonly EventManagementService _events;
|
||||||
@@ -55,6 +56,7 @@ namespace EventBot.Modules
|
|||||||
[RequireUserPermission(GuildPermission.Administrator, Group = "Permission")]
|
[RequireUserPermission(GuildPermission.Administrator, Group = "Permission")]
|
||||||
[RequireOwner(Group = "Permission")]
|
[RequireOwner(Group = "Permission")]
|
||||||
[Group("event")]
|
[Group("event")]
|
||||||
|
[Name("Event management")]
|
||||||
public class EventManagementModule : InteractiveBase<SocketCommandContext>
|
public class EventManagementModule : InteractiveBase<SocketCommandContext>
|
||||||
{
|
{
|
||||||
private readonly EventManagementService _events;
|
private readonly EventManagementService _events;
|
||||||
|
Reference in New Issue
Block a user