diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-02-24 12:57:00 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-02-24 12:57:00 +0100 |
| commit | dd5a4c1766ed9cadcd5de982f91f407adbd07f40 (patch) | |
| tree | 33ce211e6f1852c4e3b8ff9fb1c6eaa4c83333e0 | |
| parent | 772b22ada53dca7391b781dd7b5d14d2130cf277 (diff) | |
feat(dynamicid): use new HandleRaw
| -rw-r--r-- | dynamicid/handling.go | 10 | ||||
| -rw-r--r-- | main.go | 31 |
2 files changed, 21 insertions, 20 deletions
diff --git a/dynamicid/handling.go b/dynamicid/handling.go index 08d1620..44223f1 100644 --- a/dynamicid/handling.go +++ b/dynamicid/handling.go @@ -6,16 +6,16 @@ import ( "github.com/nyttikord/gokord/bot" "github.com/nyttikord/gokord/discord/types" - "github.com/nyttikord/gokord/event" "github.com/nyttikord/gokord/interaction" + "github.com/nyttikord/gokord/interaction/interactionhandler" ) func HandleDynamicMessageComponent[T any]( - events bot.EventManager, + m *interactionhandler.Manager, handler func(context.Context, bot.Session, *interaction.MessageComponent, T), base string, ) { - events.AddHandler(func(ctx context.Context, dg bot.Session, i *event.InteractionCreate) { + m.HandleRaw(func(ctx context.Context, dg bot.Session, i *interaction.Interaction) { if i.Type != types.InteractionMessageComponent { return } @@ -36,12 +36,12 @@ func HandleDynamicMessageComponent[T any]( } func HandleDynamicModalComponent[T any]( - events bot.EventManager, + m *interactionhandler.Manager, handler func(context.Context, bot.Session, *interaction.ModalSubmit, T), base string, ) { - events.AddHandler(func(ctx context.Context, dg bot.Session, i *event.InteractionCreate) { + m.HandleRaw(func(ctx context.Context, dg bot.Session, i *interaction.Interaction) { if i.Type != types.InteractionModalSubmit { return } @@ -137,16 +137,17 @@ func main() { }) events.AddHandler(rolereact.HandleReactionAdd) events.AddHandler(rolereact.HandleReactionRemove) - dynamicid.HandleDynamicMessageComponent(events, rolereact.HandleModifyComponent, rolereact.OpenMessage) - dynamicid.HandleDynamicMessageComponent(events, rolereact.HandleApplyMessage, rolereact.ApplyMessage) - dynamicid.HandleDynamicMessageComponent(events, rolereact.HandleResetMessage, rolereact.ResetMessage) - dynamicid.HandleDynamicMessageComponent(events, rolereact.HandleStartSetNote, rolereact.SetNote) - dynamicid.HandleDynamicModalComponent(events, rolereact.HandleSetNote, rolereact.SetNote) - dynamicid.HandleDynamicMessageComponent(events, rolereact.HandleNewRole, rolereact.NewRole) - dynamicid.HandleDynamicMessageComponent(events, rolereact.HandleOpenRole, rolereact.OpenRole) - dynamicid.HandleDynamicMessageComponent(events, rolereact.HandleSetRole, rolereact.SetRoleRoleID) - dynamicid.HandleDynamicMessageComponent(events, rolereact.HandleSetReaction, rolereact.SetRoleReaction) - dynamicid.HandleDynamicMessageComponent(events, rolereact.HandleDelRole, rolereact.DelRole) + + dynamicid.HandleDynamicMessageComponent(intrs, rolereact.HandleModifyComponent, rolereact.OpenMessage) + dynamicid.HandleDynamicMessageComponent(intrs, rolereact.HandleApplyMessage, rolereact.ApplyMessage) + dynamicid.HandleDynamicMessageComponent(intrs, rolereact.HandleResetMessage, rolereact.ResetMessage) + dynamicid.HandleDynamicMessageComponent(intrs, rolereact.HandleStartSetNote, rolereact.SetNote) + dynamicid.HandleDynamicModalComponent(intrs, rolereact.HandleSetNote, rolereact.SetNote) + dynamicid.HandleDynamicMessageComponent(intrs, rolereact.HandleNewRole, rolereact.NewRole) + dynamicid.HandleDynamicMessageComponent(intrs, rolereact.HandleOpenRole, rolereact.OpenRole) + dynamicid.HandleDynamicMessageComponent(intrs, rolereact.HandleSetRole, rolereact.SetRoleRoleID) + dynamicid.HandleDynamicMessageComponent(intrs, rolereact.HandleSetReaction, rolereact.SetRoleReaction) + dynamicid.HandleDynamicMessageComponent(intrs, rolereact.HandleDelRole, rolereact.DelRole) // commands intrs.HandleCommand("rank", commands.Rank) @@ -167,13 +168,13 @@ func main() { }) intrs.HandleMessageComponent(config.XpRoleNew, config.HandleXpRoleNew) intrs.HandleModalSubmit(config.XpRoleAdd, config.HandleXpRoleAdd) - dynamicid.HandleDynamicMessageComponent(events, func(ctx context.Context, dg bot.Session, i *interaction.MessageComponent, params *config.XpRoleId) { + dynamicid.HandleDynamicMessageComponent(intrs, func(ctx context.Context, dg bot.Session, i *interaction.MessageComponent, params *config.XpRoleId) { config.HandleXpRoleEdit(ctx, dg, i.Interaction, params) }, config.XpRoleEdit) - dynamicid.HandleDynamicMessageComponent(events, config.HandleXpRoleEditRole, config.XpRoleEditRole) - dynamicid.HandleDynamicMessageComponent(events, config.HandleXpRoleEditLevelStart, config.XpRoleEditLevelStart) - dynamicid.HandleDynamicModalComponent(events, config.HandleXpRoleEditLevel, config.XpRoleEditLevel) - dynamicid.HandleDynamicMessageComponent(events, config.HandleXpRoleDel, config.XpRoleDel) + dynamicid.HandleDynamicMessageComponent(intrs, config.HandleXpRoleEditRole, config.XpRoleEditRole) + dynamicid.HandleDynamicMessageComponent(intrs, config.HandleXpRoleEditLevelStart, config.XpRoleEditLevelStart) + dynamicid.HandleDynamicModalComponent(intrs, config.HandleXpRoleEditLevel, config.XpRoleEditLevel) + dynamicid.HandleDynamicMessageComponent(intrs, config.HandleXpRoleDel, config.XpRoleDel) // channel related intrs.HandleMessageComponent(config.ModifyFallbackChannel, func(ctx context.Context, dg bot.Session, i *interaction.MessageComponent) { if config.HandleModifyFallbackChannel(ctx, dg, i) { |
