Closed sandbands closed 2 years ago
With 2.0, the recommended way to start a bot is by using asyncio.run
, as such:
async def main():
async with client:
await client.start(...)
asyncio.run(main())
GitHub issues should be used for bug reports, for further questions, please join the discord.py support server: https://discord.gg/dpy
trying that just gives me this
Traceback (most recent call last):
File "C:\Users\ramal\projects\server-nuker\main.py", line 119, in <module>
asyncio.run(main())
File "C:\Users\ramal\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\ramal\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
File "C:\Users\ramal\projects\server-nuker\main.py", line 113, in main
async with client:
AttributeError: __aenter__
For versions below 2.0
, use client.run
instead.
Summary
Can't run the client because client.login and client.start werent awaited but i cant await them
Reproduction Steps
i get
RuntimeWarning: coroutine 'client.login was never awaited RuntimeWarning: coroutine 'client.start' was never awaited
i tried
but it told me i cant have await calls outside of functions so i tried
but main() has to be awaited. and since I cant await outside of an async function i cant call main to await those two.
Minimal Reproducible Code
No response
Expected Results
client is supposed to run
Actual Results
Got errors
Intents
default
System Information
Checklist
Additional Context
No response