Vexed01 / Vex-Cogs

My cogs for Red.
https://cogdocs.vexcodes.com
GNU General Public License v3.0
27 stars 20 forks source link

[GoogleTrends] Cog not working #119

Open mrPauwHaan opened 1 year ago

mrPauwHaan commented 1 year ago

What cog is this bug report for?

GoogleTrends

What versions are you running?

No response

Describe the bug

When I use a command I am getting the error as shown below

If there's an error, paste it here

Traceback (most recent call last):
  File "/data/venv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/cogs/CogManager/cogs/googletrends/googletrends.py", line 113, in trends
    request = await self.get_trends_request(list(query), timeframe, geo)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/cogs/CogManager/cogs/googletrends/plot.py", line 42, in get_trends_request
    return await self.bot.loop.run_in_executor(self.executor, func)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/cogs/CogManager/cogs/googletrends/plot.py", line 47, in _get_trends_request
    trend.build_payload(
  File "/data/cogs/Downloader/lib/pytrends/request.py", line 189, in build_payload
    self._tokens()
  File "/data/cogs/Downloader/lib/pytrends/request.py", line 195, in _tokens
    widget_dicts = self._get_data(
                   ^^^^^^^^^^^^^^^
  File "/data/cogs/Downloader/lib/pytrends/request.py", line 124, in _get_data
    retry = Retry(total=self.retries, read=self.retries,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist'

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

Traceback (most recent call last):
  File "/data/venv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "/data/venv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 File "/data/venv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist'
Vexed01 commented 1 year ago

This appears to be an issue with version 2 and above of urllib3, I'm waiting for the maintainer of pytrends to update to support the new urllib.

As Red is a large project, it wouldn't be a good idea to make the whole bot and every other installed cog use an outdated version of urllib3 just so this cog can work - in fact it might break other cogs or core Red. It's just a waiting game at the moment, through if it takes a while I might look into making my own fork of the pytrends library and fixing it there.

I've added a more friendly error in 79e609c

Progress can be seen in https://github.com/GeneralMills/pytrends/issues/591