@F1azy

Почему выдаёт ошибку с мемами?

Я новичок в Python, и хочу написать команду что бы автоматически присылались мемы из реддита в определённый канал, но код выдаёт ошибку и я не понимаю почему.
bot = discord.Client()
reddit = asyncpraw.Reddit(client_id=settings['token'],
                     client_secret=settings['secret'],
                     user_agent='random_raddit_bot/0.0.1')
                     
mems = []
TIMEOUT = 5
ID_CHANNEL = 939121803324981276
SUBREDDIT_NAME = 'memes'
POST_LIMIT = 1

@bot.event
async def on_ready():
    channel = bot.get_channel(ID_CHANNEL)
    while True:
        await asyncio.sleep(TIMEOUT)
        memes_submissions = await reddit.subreddit(SUBREDDIT_NAME)
        memes_submissions = memes_submissions.new(limit=POST_LIMIT)
        item = await memes_submissions.__anext__() 
        if item.title not in mems:
            mems.append(item.title)
            await channel.send(item.url)


Ошибка:
spoiler
Ignoring exception in on_ready
Traceback (most recent call last):
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\pasha\Desktop\bot\bot.py", line 593, in on_ready
    item = await memes_submissions.__anext__()
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpraw\models\listing\generator.py", line 63, in __anext__
    await self._next_batch()
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpraw\models\listing\generator.py", line 73, in _next_batch
    self._listing = await self._reddit.get(self.url, params=self.params)
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpraw\reddit.py", line 661, in get
    return await self._objectify_request(method="GET", params=params, path=path)
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpraw\reddit.py", line 765, in _objectify_request
    await self.request(
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpraw\reddit.py", line 967, in request
    return await self._core.request(
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncprawcore\sessions.py", line 370, in request
    return await self._request_with_retries(
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncprawcore\sessions.py", line 270, in _request_with_retries
    response, saved_exception = await self._make_request(
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncprawcore\sessions.py", line 187, in _make_request
    response = await self._rate_limiter.call(
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncprawcore\rate_limit.py", line 34, in call
    kwargs["headers"] = await set_header_callback()
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncprawcore\sessions.py", line 322, in _set_header_callback
    await self._authorizer.refresh()
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncprawcore\auth.py", line 371, in refresh
    await self._request_token(grant_type="client_credentials", **additional_kwargs)
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncprawcore\auth.py", line 153, in _request_token
    response = await self._authenticator._post(url, **data)
  File "C:\Users\pasha\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncprawcore\auth.py", line 41, in _post
    raise ResponseException(response)
asyncprawcore.exceptions.ResponseException: received 401 HTTP response
  • Вопрос задан
  • 113 просмотров
Решения вопроса 1
mckruasan
@mckruasan
Junior Python, Html, CSS
не получается соединиться с реддитом, а вот почему… это я не подскажу
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы