Не понимаю как решить ошибку связанную с работой Discord-бота

обращаюсь с вопросом по поводу Discord-бота. Я хотел создать простенького бота для Дискорда, чтобы он работал и был в онлайне, а вместо этого получил очередную ошибку.

Вот мой код:

import discord
import os

client = discord.Client(intents=discord.Intents.default())

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return 
    
    if message.content.startwith('$hello'):
        await message.channel.send('Hello!')

client.run(os.getenv('TOKEN'))

Выдаёт вот такую вот ошибку:

Traceback (most recent call last):
  File "e:\Discordbot\main.py", line 18, in <module>
    client.run(os.getenv('TOKEN'))
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\discord\client.py", line 906, in run
    asyncio.run(runner())
    ~~~~~~~~~~~^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\asyncio\runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\discord\client.py", line 895, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\discord\client.py", line 823, in start
    await self.login(token)
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\discord\client.py", line 649, in login
    raise TypeError(f'expected token to be a str, received {token.__class__.__name__} instead')
TypeError: expected token to be a str, received NoneType instead

Ответы (0 шт):