#How to properly add an autocomplete function to a slash command inside a cog?

1 messages · Page 1 of 1 (latest)

tight zealot
#

So I've got this small /unban slash command inside a cog (image given below).

Currently there's no option to properly receive the user parameter. Is there a decent way to add an autocomplete to the command so that as I type, the banned users matching with the current text would appear as options?

Thanks in advance.

karmic charm
split steepleBOT
#
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.
blissful grail
#

I recommend using _unban.autocomplete("user")

#

also, if I remember correctly, options field is deprecated

tight zealot
mighty valve
#

nope you don’t

#

you can use the method args + doc string to add a description

tight zealot
#

like what arguments do I need to pass and stuff

mighty valve
#

check the above example, showing is easier

foggy hinge
#

Unless it's their ID

narrow epoch
#

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