feat: replace buttons in /configure-channels with select menu

This commit is contained in:
sam 2024-11-05 16:20:24 +01:00
parent e7eaa9f13a
commit f0fcfd7bd3
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
4 changed files with 186 additions and 267 deletions

View file

@ -222,6 +222,93 @@ public class ChannelCommands(
return Result.Success;
}
public static IStringSelectComponent LogTypeSelect =>
new StringSelectComponent(
CustomID: CustomIDHelpers.CreateSelectMenuID("select-log-type"),
MinValues: 1,
MaxValues: 1,
Options:
[
new SelectOption(
Label: "Server changes",
Value: nameof(LogChannelType.GuildUpdate)
),
new SelectOption(
Label: "Emoji changes",
Value: nameof(LogChannelType.GuildEmojisUpdate)
),
new SelectOption(Label: "New roles", Value: nameof(LogChannelType.GuildRoleCreate)),
new SelectOption(
Label: "Edited roles",
Value: nameof(LogChannelType.GuildRoleUpdate)
),
new SelectOption(
Label: "Deleted roles",
Value: nameof(LogChannelType.GuildRoleDelete)
),
new SelectOption(
Label: "New channels",
Value: nameof(LogChannelType.ChannelCreate)
),
new SelectOption(
Label: "Edited channels",
Value: nameof(LogChannelType.ChannelUpdate)
),
new SelectOption(
Label: "Deleted channels",
Value: nameof(LogChannelType.ChannelDelete)
),
new SelectOption(
Label: "Members joining",
Value: nameof(LogChannelType.GuildMemberAdd)
),
new SelectOption(
Label: "Members leaving",
Value: nameof(LogChannelType.GuildMemberRemove)
),
new SelectOption(
Label: "Member role changes",
Value: nameof(LogChannelType.GuildMemberUpdate)
),
new SelectOption(
Label: "Key role changes",
Value: nameof(LogChannelType.GuildKeyRoleUpdate)
),
new SelectOption(
Label: "Member name changes",
Value: nameof(LogChannelType.GuildMemberNickUpdate)
),
new SelectOption(
Label: "Member avatar changes",
Value: nameof(LogChannelType.GuildMemberAvatarUpdate)
),
new SelectOption(
Label: "Timeouts",
Value: nameof(LogChannelType.GuildMemberTimeout)
),
new SelectOption(Label: "Kicks", Value: nameof(LogChannelType.GuildMemberKick)),
new SelectOption(Label: "Bans", Value: nameof(LogChannelType.GuildBanAdd)),
new SelectOption(Label: "Unbans", Value: nameof(LogChannelType.GuildBanRemove)),
new SelectOption(Label: "New invites", Value: nameof(LogChannelType.InviteCreate)),
new SelectOption(
Label: "Deleted invites",
Value: nameof(LogChannelType.InviteDelete)
),
new SelectOption(
Label: "Edited messages",
Value: nameof(LogChannelType.MessageUpdate)
),
new SelectOption(
Label: "Deleted messages",
Value: nameof(LogChannelType.MessageDelete)
),
new SelectOption(
Label: "Bulk deleted messages",
Value: nameof(LogChannelType.MessageDeleteBulk)
),
]
);
public static (List<IEmbed>, List<IMessageComponent>) BuildRootMenu(
List<IChannel> guildChannels,
IGuild guild,
@ -357,208 +444,9 @@ public class ChannelCommands(
List<IMessageComponent> components =
[
new ActionRowComponent([LogTypeSelect]),
new ActionRowComponent(
[
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Server changes",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildUpdate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Emoji changes",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildEmojisUpdate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "New roles",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildRoleCreate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Edited roles",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildRoleUpdate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Deleted roles",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildRoleDelete)
)
),
]
),
new ActionRowComponent(
[
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "New channels",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.ChannelCreate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Edited channels",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.ChannelUpdate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Deleted channels",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.ChannelDelete)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Members joining",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildMemberAdd)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Members leaving",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildMemberRemove)
)
),
]
),
new ActionRowComponent(
[
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Member role changes",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildMemberUpdate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Key role changes",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildKeyRoleUpdate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Member name changes",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildMemberNickUpdate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Member avatar changes",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildMemberAvatarUpdate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Timeouts",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildMemberTimeout)
)
),
]
),
new ActionRowComponent(
[
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Kicks",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildMemberKick)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Bans",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildBanAdd)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Unbans",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.GuildBanRemove)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "New invites",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.InviteCreate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Deleted invites",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.InviteDelete)
)
),
]
),
new ActionRowComponent(
[
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Edited messages",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.MessageUpdate)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Deleted messages",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.MessageDelete)
)
),
new ButtonComponent(
ButtonComponentStyle.Primary,
Label: "Bulk deleted messages",
CustomID: CustomIDHelpers.CreateButtonIDWithState(
"config-channels",
nameof(LogChannelType.MessageDeleteBulk)
)
),
new ButtonComponent(
ButtonComponentStyle.Secondary,
Label: "Close",