Я хочу автоматизировать рассылку рекламы на дискорд сервер. Из за того, что дискорд сервер не мой, отсылать сообщение нужно с аккаунта человека. Для этого я раздобыл токен своего аккаунта и влепил его в bot.run(вместо токена бота), но теперь у меня вылазит ошибка Event loop is closed.
Вопрос: Что означает эта ошибка и как ее исправить ? И вообще возможно ли запустить код на токене юзера ?
import disnake
from disnake.ext import commands
import asyncio
bot = commands.Bot(command_prefix='.', help_command=None, intents=disnake.Intents.all())
@bot.event
async def on_ready():
print(f'Bot{bot.user} is ready to work')
async def send_message():
await bot.wait_until_ready()
channel = bot.get_channel(1168668195712925800)
while not bot.is_closed():
try:
await channel.send('Your text')
except Exception as e:
print(f"An error occurred: {e}")
await asyncio.sleep(60)
bot.loop.create_task(send_message())
bot.run('NjkwNDk2OTU4ODY3MTc3NTEz.G4PJV8.VsiHSKHy7KiWyhP-pw8QrU_8308G1pOcwecjc4')
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\http.py", line 462, in static_login
data: user.User = await self.request(Route("GET", "/users/@me"))
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\http.py", line 415, in request
raise HTTPException(response, data)
disnake.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\danii\Desktop\app\autopostbot.py", line 24, in <module>
bot.run('NjkwNDk2OTU4ODY3MTc3NTEz.G4PJV8.VsiHSKHy7KiWyhP-pw8QrU_8308G1pOcwecjc4')
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 1126, in run
return future.result()
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 1105, in runner
await self.start(*args, **kwargs)
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 1066, in start await self.login(token)
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 224, in login
await super().login(token)
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\common_bot_base.py", line 131, in login
await super().login(token=token) # type: ignore
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 865, in login
data = await self.http.static_login(token.strip())
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\http.py", line 466, in static_login
raise LoginFailure("Improper token has been passed.") from exc
disnake.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000020E7D471F70>
Traceback (most recent call last):
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\Users\danii\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed