mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-02-01 09:27:18 +00:00
cmdroute: Add ev.Data into {Command,Autocomplete}Data
This mostly helps avoid a type assertion that could potentially be incorrectly done.
This commit is contained in:
parent
5e0d1cfe4a
commit
4bc415f72b
|
@ -38,6 +38,7 @@ type Middleware = func(next InteractionHandler) InteractionHandler
|
||||||
type CommandData struct {
|
type CommandData struct {
|
||||||
discord.CommandInteractionOption
|
discord.CommandInteractionOption
|
||||||
Event *discord.InteractionEvent
|
Event *discord.InteractionEvent
|
||||||
|
Data *discord.CommandInteraction
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommandHandler is a slash command handler.
|
// CommandHandler is a slash command handler.
|
||||||
|
@ -71,6 +72,7 @@ func (f CommandHandlerFunc) HandleCommand(ctx context.Context, data CommandData)
|
||||||
type AutocompleteData struct {
|
type AutocompleteData struct {
|
||||||
discord.AutocompleteOption
|
discord.AutocompleteOption
|
||||||
Event *discord.InteractionEvent
|
Event *discord.InteractionEvent
|
||||||
|
Data *discord.AutocompleteInteraction
|
||||||
}
|
}
|
||||||
|
|
||||||
// Autocompleter is a type for an autocompleter.
|
// Autocompleter is a type for an autocompleter.
|
||||||
|
|
|
@ -194,6 +194,7 @@ func (r *Router) callCommandHandler(ev *discord.InteractionEvent, found handlerD
|
||||||
data := found.handler.HandleCommand(ctx, CommandData{
|
data := found.handler.HandleCommand(ctx, CommandData{
|
||||||
CommandInteractionOption: found.data,
|
CommandInteractionOption: found.data,
|
||||||
Event: ev,
|
Event: ev,
|
||||||
|
Data: ev.Data.(*discord.CommandInteraction),
|
||||||
})
|
})
|
||||||
if data == nil {
|
if data == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -299,6 +300,7 @@ func (r *Router) callAutocompletion(ev *discord.InteractionEvent, found autocomp
|
||||||
choices := found.handler.Autocomplete(ctx, AutocompleteData{
|
choices := found.handler.Autocomplete(ctx, AutocompleteData{
|
||||||
AutocompleteOption: found.data,
|
AutocompleteOption: found.data,
|
||||||
Event: ev,
|
Event: ev,
|
||||||
|
Data: ev.Data.(*discord.AutocompleteInteraction),
|
||||||
})
|
})
|
||||||
if choices == nil {
|
if choices == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue