Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 7a4f524

Browse files
committed
Fix Context annotations failing under __future__
1 parent a207fc6 commit 7a4f524

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

discord/ext/slash/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ async def _kwargs_from_options(self, options, resolved):
393393
self.command = self.command.slash[opt['name']]
394394
await self._kwargs_from_options(opt.get('options', []), resolved)
395395
elif isinstance(self.command, Command):
396-
kwargs[self.command._ctx_arg] = self
396+
kwargs[self.command._ctx_arg[0]] = self
397397
self.options = kwargs
398398

399399
async def _try_get(
@@ -965,7 +965,7 @@ def __init__(self, coro: Coroutine, **kwargs):
965965
'required argument with no valid annotation')
966966
try:
967967
if issubclass(typ, Context):
968-
self._ctx_arg = param.name
968+
self._ctx_arg = (param.name, typ)
969969
elif issubclass(typ, ChoiceEnum):
970970
typ = Option(description=typ)
971971
except TypeError: # not even a class
@@ -1358,7 +1358,7 @@ async def on_interaction_create(self, event: dict):
13581358
if cmd is None:
13591359
raise commands.CommandNotFound(
13601360
f'No command {event["data"]["name"]!r} found by any critera')
1361-
ctx = await cmd.coro.__annotations__[cmd._ctx_arg](self, cmd, event)
1361+
ctx: Context = await cmd._ctx_arg[1](self, cmd, event)
13621362
self.dispatch('before_slash_command_invoke', ctx)
13631363
try:
13641364
await ctx.command.invoke(ctx)

0 commit comments

Comments
 (0)