Это мой код, и он возвращает кучу ошибок, когда я запускаю команду .memri. Я хотел, чтобы мой диссон-бот получил случайную картинку из subreddit "memritvmemes". Может кто-нибудь сказать мне, что я делаю не так?
Это мой код:
import praw
import random
import os
from discord.ext import commands
client = commands.Bot(command_prefix = '.')
reddit = praw.Reddit(client_id='the client id',
client_secret='the client secret',
user_agent='Memri TV Bot by /u/Hezbolloli')
@client.command()
async def memri(ctx):
memri_submissions = reddit.subreddit('memritvmemes').hot()
post_to_pick = random.randint(1, 10)
for i in range(0, post_to_pick):
submission = next(x for x in memri_submissions if not x.stickied)
await ctx.send(submission.url)
Это мой журнал ошибок в оболочке python:
Ignoring exception in command memri:
Traceback (most recent call last):
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Win 10\Desktop\app.py", line 69, in memri
submission = next(x for x in memri_submissions if not x.stickied)
File "C:\Users\Win 10\Desktop\app.py", line 69, in <genexpr>
submission = next(x for x in memri_submissions if not x.stickied)
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\praw\models\listing\generator.py", line 61, in __next__
self._next_batch()
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\praw\models\listing\generator.py", line 71, in _next_batch
self._listing = self._reddit.get(self.url, params=self.params)
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\praw\reddit.py", line 454, in get
data = self.request("GET", path, params=params)
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\praw\reddit.py", line 626, in request
return self._core.request(
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\prawcore\sessions.py", line 183, in request
return self._request_with_retries(
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\prawcore\sessions.py", line 115, in _request_with_retries
response, saved_exception = self._make_request(
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\prawcore\sessions.py", line 98, in _make_request
response = self._rate_limiter.call(
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\prawcore\rate_limit.py", line 35, in call
kwargs['headers'] = set_header_callback()
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\prawcore\sessions.py", line 145, in _set_header_callback
self._authorizer.refresh()
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\prawcore\auth.py", line 299, in refresh
self._request_token(grant_type='client_credentials')
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\prawcore\auth.py", line 138, in _request_token
response = self._authenticator._post(url, **data)
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\prawcore\auth.py", line 31, in _post
raise ResponseException(response)
prawcore.exceptions.ResponseException: received 401 HTTP response
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Win 10\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ResponseException: received 401 HTTP response