-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
Summary
Views will call asyncio.get_running_loop on initialization which fails without a running loop. SyncWebhook supports a view argument, but they can't be initialized.
Reproduction Steps
I want to use SyncWebhook in a synchronous context (a custom logging handler in a separate thread), but the __init__ will create a future, requiring an event loop to exist.
I understand that creating a future is important for the timeout, but I'm in a context where the view is completely static (components v2) and will never need to be listening in the first place. SyncWebhook supports a view parameter, but there's no way to make one without asyncio running.
If the design change of views can't be accepted, then the view argument of SyncWebhook.send should be removed to make it clear it isn't supported.
Minimal Reproducible Code
>>> import discord
>>> discord.ui.View()Expected Results
The view to be initialized
Actual Results
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
discord.ui.View()
~~~~~~~~~~~~~~~^^
File "/Users/laggron/Documents/Discord/Ballsdex/.venv/lib/python3.14/site-packages/discord/ui/view.py", line 704, in __init__
super().__init__(timeout=timeout)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/Users/laggron/Documents/Discord/Ballsdex/.venv/lib/python3.14/site-packages/discord/ui/view.py", line 222, in __init__
self.__stopped: asyncio.Future[bool] = asyncio.get_running_loop().create_future()
~~~~~~~~~~~~~~~~~~~~~~~~^^
RuntimeError: no running event loopIntents
Not relevant
System Information
- Python v3.14.0-final
- discord.py v2.7.0-alpha
- discord.py metadata: v2.7.0a5356+gc342db85
- aiohttp v3.13.2
- system info: Darwin 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:00 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6020
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Additional Context
No response