Top-gg-Community / python-sdk

A simple API wrapper for top.gg written in Python
https://docs.top.gg/docs/Libraries/python
MIT License
91 stars 54 forks source link

Error in cogs #52

Closed takipsizad closed 3 years ago

takipsizad commented 3 years ago

This issue tracker is ONLY used for reporting bugs with topggpy. Feel free to share your suggestions in the #api channel in our Discord server!

For help with general Python issues, use StackOverflow, our #development channel, or the Python Discord server.

Expected Behavior

Should work fine

Current Behavior

Error

` File "C:\Users\pc\python\lib\site-packages\discord\ext\commands\bot.py", line 644, in _load_from_module_spec setup(self) File "c:\Users\pc\projeler\bot\cogs\redditcommands.py", line 63, in setup bot.add_cog(Redditcommands(bot)) File "c:\Users\pc\projeler\bot\cogs\redditcommands.py", line 12, in init self.dbl = topgg.DBLClient(bot=self.bot, token=dbltoken) File "C:\Users\pc\python\lib\site-packages\topgg\client.py", line 112, in init self.http = HTTPClient(token, loop=self.loop, session=kwargs.get("session")) File "C:\Users\pc\python\lib\site-packages\topgg\http.py", line 83, in init self.rate_limiter = AsyncRateLimiter( File "C:\Users\pc\python\lib\site-packages\topgg\ratelimiter.py", line 53, in init self.lock = asyncio.Lock() File "C:\Users\pc\python\lib\asyncio\locks.py", line 81, in init__ self._loop = events.get_event_loop() File "C:\Users\pc\python\lib\asyncio\events.py", line 642, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.' RuntimeError: There is no current event loop in thread 'MainThread'.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "c:\Users\pc\projeler\bot\bot.py", line 61, in bot.load_extension(f"cogs.{name}") File "C:\Users\pc\python\lib\site-packages\discord\ext\commands\bot.py", line 704, in load_extension self._load_from_module_spec(spec, name) File "C:\Users\pc\python\lib\site-packages\discord\ext\commands\bot.py", line 649, in _load_from_module_spec raise errors.ExtensionFailed(key, e) from e discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.redditcommands' raised an error: RuntimeError: There is no current event loop in thread 'MainThread'.`

Development Environment

3.9 ,1.0.1

Steps to Reproduce

1.Using top gg client in cog

Context

Votelocking command

norinorin commented 3 years ago

Odd, I don't think this should happen. Did you by any chance call asyncio.run or something that closes the event loop?

Edit: I'm pretty sure that this isn't on the lib side nor related to cogs. You most likely closed the event loop and didn't set a new one; therefore, get_event_loop raised the error.

Esmeray6 commented 3 years ago

Is there any update on this?