#How to properly add an autocomplete function to a slash command inside a cog?
1 messages · Page 1 of 1 (latest)
U can use commands.Param instead of options list
https://github.com/DisnakeDev/disnake/blob/master/examples/interactions/autocomplete.py
disnake.ext.commands.Param(default=Ellipsis, *, name=None, description=None, choices=None, converter=None, convert_defaults=False, autocomplete=None, channel_types=None, lt=None, ...)```
A special function that creates an instance of [`ParamInfo`](https://docs.disnake.dev/en/latest/ext/commands/api/app_commands.html#disnake.ext.commands.ParamInfo "disnake.ext.commands.ParamInfo") that contains some information about a slash command option. This instance should be assigned to a parameter of a function representing your slash command.
See [Parameters](https://docs.disnake.dev/en/latest/ext/commands/slash_commands.html#param-syntax) for more info.
I recommend using _unban.autocomplete("user")
also, if I remember correctly, options field is deprecated
okay so do I not need the options field anymore?
that's neat, but now how do I add the autocomplete function as mentioned above?
like what arguments do I need to pass and stuff
check the above example, showing is easier
What do you mean by properly receiving a user? If you mean receiving any mentionable user, then you can use user: disnake.User annotation in your function
However, this way it won't really allow entering a user that you don't share servers with
Unless it's their ID
oh
ur doing unban
i just did an unban cmd using slash and its quite annoying due to how unbanning works. you wouldn't be able to mention the user as they are banned
i used autocomplete and just returned the users name/id from guild.bans and then used the id returned from autocomplete to unban the user
yeah that's what I thought