Skip to content

Commit 6a13165

Browse files
committed
fix empty field error for command groups with missing permission for subcommands
1 parent 9fe74cf commit 6a13165

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/Bot/Helpers/TextCommandHelper.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static async ValueTask<EmbedBuilder> CreateCommandEmbedAsync(Command comm
5959

6060
if (command.Attributes.Any(x => x is DummyCommandAttribute))
6161
{
62-
await addSubcommandsFieldAsync();
62+
addSubcommandsField();
6363
return checks.Count > 0
6464
? embed.AddField("Checks",
6565
(await Task.WhenAll(checks.Select(check => FormatCheckAsync(check, ctx)))).JoinToString("\n"))
@@ -89,12 +89,11 @@ public static async ValueTask<EmbedBuilder> CreateCommandEmbedAsync(Command comm
8989
$"{Format.Code("4d3h2m1s")}: {Format.Italics("4 days, 3 hours, 2 minutes and one second.")}");
9090

9191
if (command.Attributes.Any(x => x is ShowSubcommandsInHelpOverrideAttribute))
92-
await addSubcommandsFieldAsync();
92+
addSubcommandsField();
9393

9494
if (command.Attributes.TryGetFirst(x => x is ShowUnixArgumentsInHelpAttribute, out var unixAttr)
9595
&& unixAttr is ShowUnixArgumentsInHelpAttribute attr)
9696
embed.AddField("Unix Arguments", getArgs(attr.VolteUnixCommand));
97-
9897

9998
return checks.Count > 0
10099
? embed.AddField("Checks",
@@ -104,17 +103,17 @@ public static async ValueTask<EmbedBuilder> CreateCommandEmbedAsync(Command comm
104103
)
105104
).JoinToString("\n"))
106105
: embed;
107-
108-
109-
110-
async Task addSubcommandsFieldAsync()
106+
107+
void addSubcommandsField()
111108
{
112-
embed.AddField("Subcommands", (await command.Module.Commands.WhereAccessibleAsync(ctx)
113-
.Where(static x => !x.Attributes.Any(a => a is DummyCommandAttribute)).ToListAsync())
114-
.Select(static x => FormatCommandShort(x, false))
115-
.JoinToString(", "));
109+
embed.AddField("Subcommands",
110+
command.Module.Commands
111+
.Where(static x => !x.Attributes.Any(a => a is DummyCommandAttribute))
112+
.Select(static x => FormatCommandShort(x, false))
113+
.FormatCollection(x => x, ", ")
114+
);
116115
}
117-
116+
118117
static string formatUnixArgs(KeyValuePair<string[], string> kvp) =>
119118
$"{Format.Bold(kvp.Key.Select(static name => $"-{name}").JoinToString(" or "))}: {kvp.Value}";
120119

0 commit comments

Comments
 (0)