Closed ire4ever1190 closed 2 years ago
Implements autocomplete for interactions
basic example
proc interactionCreate(s: Shard, i: Interaction) {.event(discord).} = if i.kind == itAutoComplete: let things = [ " and self", " and friends", " and co" ] if i.data.isSome: for key, option in i.data.get().options: if option.focused.get(false): var choices: seq[ApplicationCommandOptionChoice] = @[] for thing in things: choices &= ApplicationCommandOptionChoice( name: option.str & thing, value: (some (option.str & thing), none int) ) await discord.api.createInteractionResponse(i.id, i.token, InteractionResponse( kind: irtAutoCompleteResult, choices: choices )) else: # Handle interactions normally
I went with variant objects over generics in the end so that existing code didn't break
Implements autocomplete for interactions
basic example
I went with variant objects over generics in the end so that existing code didn't break