-
-
Notifications
You must be signed in to change notification settings - Fork 463
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
bot.before_invoke function runs twice with slash sub commands causing a whole bunch of issues #2134
Comments
Did you also set a |
I will have to check |
Not sure if this helps but I managed to capture stack traces both times the function was called File "Revnobot/main.py", line 154, in <module>
client.run(config.token)
File "Revnobot/venv/lib/python3.11/site-packages/discord/client.py", line 753, in run
loop.run_forever()
File "/usr/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
self._run_once()
File "/usr/lib/python3.11/asyncio/base_events.py", line 1922, in _run_once
handle._run()
File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "Revnobot/venv/lib/python3.11/site-packages/discord/client.py", line 399, in _run_event
await coro(*args, **kwargs)
File "Revnobot/venv/lib/python3.11/site-packages/discord/bot.py", line 1185, in on_interaction
await self.process_application_commands(interaction)
File "Revnobot/venv/lib/python3.11/site-packages/discord/bot.py", line 867, in process_application_commands
await self.invoke_application_command(ctx)
File "/Revnobot/venv/lib/python3.11/site-packages/discord/ext/bridge/bot.py", line 176, in invoke_application_command
await ctx.command.invoke(ctx)
File "Revnobot/venv/lib/python3.11/site-packages/discord/commands/core.py", line 378, in invoke
await self.prepare(ctx)
File "Revnobot/venv/lib/python3.11/site-packages/discord/commands/core.py", line 310, in prepare
await self.call_before_hooks(ctx)
File "Revnobot/venv/lib/python3.11/site-packages/discord/commands/core.py", line 535, in call_before_hooks
await hook(ctx)
File "Revnobot/main.py", line 116, in pre_invocation
ctx, "Execution Stack", f'\```python\n{("".join(traceback.format_stack())).replace("\```", "")}\```')) Execution 2: File "Revnobot/main.py", line 154, in <module>
client.run(config.token)
File "Revnobot/venv/lib/python3.11/site-packages/discord/client.py", line 753, in run
loop.run_forever()
File "/usr/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
self._run_once()
File "/usr/lib/python3.11/asyncio/base_events.py", line 1922, in _run_once
handle._run()
File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "Revnobot/venv/lib/python3.11/site-packages/discord/client.py", line 399, in _run_event
await coro(*args, **kwargs)
File "Revnobot/venv/lib/python3.11/site-packages/discord/bot.py", line 1185, in on_interaction
await self.process_application_commands(interaction)
File "Revnobot/venv/lib/python3.11/site-packages/discord/bot.py", line 867, in process_application_commands
await self.invoke_application_command(ctx)
File "Revnobot/venv/lib/python3.11/site-packages/discord/ext/bridge/bot.py", line 176, in invoke_application_command
await ctx.command.invoke(ctx)
File "Revnobot/venv/lib/python3.11/site-packages/discord/commands/core.py", line 381, in invoke
await injected(ctx)
File "Revnobot/venv/lib/python3.11/site-packages/discord/commands/core.py", line 131, in wrapped
ret = await coro(arg)
File "Revnobot/venv/lib/python3.11/site-packages/discord/commands/core.py", line 1363, in _invoke
await command.invoke(ctx)
File "Revnobot/venv/lib/python3.11/site-packages/discord/commands/core.py", line 378, in invoke
await self.prepare(ctx)
File "Revnobot/venv/lib/python3.11/site-packages/discord/commands/core.py", line 310, in prepare
await self.call_before_hooks(ctx)
File "Revnobot/venv/lib/python3.11/site-packages/discord/commands/core.py", line 535, in call_before_hooks
await hook(ctx)
File "Revnobot/main.py", line 116, in pre_invocation
ctx, "Execution Stack", f'\```python\n{("".join(traceback.format_stack())).replace("\```", "")}\```')) |
I think #2091 might play a part in this. From my understanding, Slash command group is also considered a command. So Can you check if this issue occurred before that pr? |
Considering how the library deals with Slash groups, this seems logical. A Slash group is just another "command". And #2091 adds features that make it even more like a command. I also intend to add a So it only makes sense to run functions set using I will wait for core devs to decide whether this is a feature or a bug. PS - using |
Since the slash group itself is not being invoked, before_invoke should not be called for it |
Wdym By checks? |
The |
you mean do the defer() in a check? |
Summary
the bot.before_invoke function gets called twice during the invocation of a slash sub command
Reproduction Steps
This seems to only occur on master and not stable 2.4.1
@bot.before_invoke
decoratorInteractionResponded
will be raisedMinimal Reproducible Code
Expected Results
i executed
should only print once meaningActual Results
i executed
prints twiceor the following traceback if you use ctx.defer()
Intents
all
System Information
Checklist
Additional Context
No response
The text was updated successfully, but these errors were encountered: