Я пишу бота для дискорд на python 3, через апи discord.py. Сейчас я пытаюсь его подключить к голосовому каналу.
import discord
from discord.ext import commands
TOKEN = 'Скрыт'
ver = '0.4.1 VChCT build (Voice Channel Connect Test'
intents = discord.Intents.default ()
intents.members = True
bot = commands.Bot (command_prefix = settings ['prefix'], intents = intents)
async def vch (message, bot):
channel = message.author.voice.channel
if channel:
await message.channel.send(channel.id)
await bot.connect ()
else:
await ctx.send('you arent in a vc')
@bot.event
async def on_message (message):
if message.author.bot:
return
if message.content.lower () == '!connect':
await vch (message, bot)
return
Ошибка:
<br>
Traceback (most recent call last):<br>
File "D:\Misha\Языки\API\discord\NuclearBot-collected\Nuclearbot-main-3\Nuclearbot-main\main.py", line 119, in <br>
bot.run (TOKEN)<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 708, in run<br>
return future.result()<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 687, in runner<br>
await self.start(*args, **kwargs)<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 651, in start<br>
await self.connect(reconnect=reconnect)<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 551, in connect<br>
await self.ws.poll_event()<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\gateway.py", line 560, in poll_event<br>
msg = await self.socket.receive(timeout=self._max_heartbeat_timeout)<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client_ws.py", line 212, in receive<br>
raise RuntimeError(<br>
RuntimeError: Concurrent call to receive() is not allowed<br>
>>> Exception in thread Thread-1:<br>
Traceback (most recent call last):<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\threading.py", line 950, in _bootstrap_inner<br>
self.run()<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\gateway.py", line 150, in run<br>
f = asyncio.run_coroutine_threadsafe(coro, loop=self.ws.loop)<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 926, in run_coroutine_threadsafe<br>
loop.call_soon_threadsafe(callback)<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 791, in call_soon_threadsafe<br>
self._check_closed()<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed<br>
raise RuntimeError('Event loop is closed')<br>
RuntimeError: Event loop is closed<br>
<br>
Warning (from warnings module):<br>
File "C:\Users\errma\AppData\Local\Programs\Python\Python39\lib\threading.py", line 952<br>
self._invoke_excepthook(self)<br>
RuntimeWarning: coroutine 'DiscordWebSocket.send_heartbeat' was never awaited<br>