fix: make slash command args optional without breaking them
This commit is contained in:
parent
72c09b3e08
commit
c86f94e497
1 changed files with 16 additions and 5 deletions
|
|
@ -53,6 +53,8 @@ public class InviteCommands(
|
|||
.Select(i => new PartialNamedInvite(
|
||||
i.Code,
|
||||
dbInvites.FirstOrDefault(dbI => dbI.Code == i.Code)?.Name,
|
||||
i.Uses,
|
||||
i.Channel,
|
||||
i.Inviter,
|
||||
i.CreatedAt
|
||||
))
|
||||
|
|
@ -64,20 +66,29 @@ public class InviteCommands(
|
|||
Value: $"""
|
||||
**Name:** {i.Name ?? "*(unnamed)*"}
|
||||
**Created at:** <t:{i.CreatedAt.ToUnixTimeSeconds()}>
|
||||
**Uses:** {i.Uses}
|
||||
**Channel:** {(i.Channel != null ? $"<#{i.Channel.ID.Value}>" : "*(unknown)*")}
|
||||
**Created by:** {i.CreatedBy.OrDefault()?.Tag() ?? "*(unknown)*"}
|
||||
""",
|
||||
IsInline: true
|
||||
));
|
||||
IsInline: false
|
||||
))
|
||||
.ToList();
|
||||
|
||||
return await feedbackService.SendContextualPaginatedMessageAsync(
|
||||
userId,
|
||||
DiscordUtils.PaginateFields(fields, title: $"Invites for {guild.Name}")
|
||||
DiscordUtils.PaginateFields(
|
||||
fields,
|
||||
title: $"Invites for {guild.Name} ({fields.Count})",
|
||||
fieldsPerPage: 5
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private record struct PartialNamedInvite(
|
||||
string Code,
|
||||
string? Name,
|
||||
int Uses,
|
||||
IPartialChannel? Channel,
|
||||
Optional<IUser> CreatedBy,
|
||||
DateTimeOffset CreatedAt
|
||||
);
|
||||
|
|
@ -88,7 +99,7 @@ public class InviteCommands(
|
|||
[Description("The channel to create the invite in")]
|
||||
[ChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)]
|
||||
IChannel channel,
|
||||
[Description("What to name the new invite")] [Optional] string? name
|
||||
[Description("What to name the new invite")] string? name = null
|
||||
)
|
||||
{
|
||||
var (userId, guildId) = contextInjection.GetUserAndGuild();
|
||||
|
|
@ -141,7 +152,7 @@ public class InviteCommands(
|
|||
[Description("The invite to rename")]
|
||||
[AutocompleteProvider("autocomplete:invite-provider")]
|
||||
string invite,
|
||||
[Description("The invite's new name")] [Optional] string? name
|
||||
[Description("The invite's new name")] string? name = null
|
||||
)
|
||||
{
|
||||
var (_, guildId) = contextInjection.GetUserAndGuild();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue