Q&A
実現したいこと
DiscordBotのボイスチャンネルへの接続以降の処理が実行されるようにしたい。
前提
Python 3.8.12
Discord.py 2.2.0
DiscordでBotを作成しています。
「$join」でボイスチャンネル自体に接続はできているのですが、そこで処理が止まっているようで、print(2)が出力されません。
そして、voice_clientもNoneのままであるため、「$leave」で切断することができません。
例外は出ません。
ログ
1 INFO discord.voice_client Connecting to voice... INFO discord.voice_client Starting voice handshake... (connection attempt 1) INFO discord.voice_client Voice handshake complete. Endpoint found japan7069.discord.media WARNING discord.gateway Shard ID None has stopped responding to the gateway. Closing and restarting.
該当のソースコード
import discord import os intents = discord.Intents.all() client = discord.Client(intents=intents) @client.event async def on_message(message): if message.author == client.user: return if message.content.startswith('$join'): if message.author.voice is None: return print(1) # ボイスチャンネルに接続する await message.author.voice.channel.connect() print(2) if message.content.startswith('$leave'): if message.guild.voice_client is None: return # 切断する await message.guild.voice_client.disconnect() client.run(os.getenv("TOKEN"))
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。