Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow passing autocompleters that take a cog as first argument to commands.Param #1269

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/1269.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow passing autocompleters that take a :class:`commands.Cog` as first argument to :class:`commands.Param`.
6 changes: 5 additions & 1 deletion disnake/ext/commands/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,11 @@ def __init__(
self.param_name: str = self.name
self.converter = converter
self.convert_default = convert_default

if autocomplete:
classify_autocompleter(autocomplete)
self.autocomplete = autocomplete

self.choices = choices or []
self.type = type or str
self.channel_types = channel_types or []
Expand Down Expand Up @@ -1121,7 +1125,7 @@ def Param(
choices: Optional[Choices] = None,
converter: Optional[Callable[[ApplicationCommandInteraction[BotT], Any], Any]] = None,
convert_defaults: bool = False,
autocomplete: Optional[Callable[[ApplicationCommandInteraction[BotT], str], Any]] = None,
autocomplete: Optional[AnyAutocompleter] = None,
channel_types: Optional[List[ChannelType]] = None,
lt: Optional[float] = None,
le: Optional[float] = None,
Expand Down
Loading