前提・実現したいこと
身内のサーバーで使う目的でDiscordのBOT製作を開始し、ひとまずVoice Channelに参加した状態でBOTを動かせるようにはなったのですが、一度動かすとBOTプログラムを再起動しないとコマンドを受け付けてくれないといった状態になってしまい、それを解決したいと思い質問させていただきました。
発生している問題・エラーメッセージ
エラーメッセージ
Ignoring exception in on_message Traceback (most recent call last): File "C:\Program Files\Python36\lib\site-packages\discord\client.py", line 307, in _run_event yield from getattr(self, event)(*args, **kwargs) File "suumobot.py", line 27, in on_message voice = await client.join_voice_channel(message.author.voice_channel) File "C:\Program Files\Python36\lib\site-packages\discord\client.py", line 3177, in join_voice_channel raise ClientException('Already connected to a voice channel in this server') discord.errors.ClientException: Already connected to a voice channel in this server
該当のソースコード
python
import discord import youtube_dl # ログイン処理 client = discord.Client() @client.event async def on_ready(): print('以下のログイン情報でBOTにログインしています。↓↓↓') print(client.user.name) print(client.user.id) print('起動完了') # 音割れスーモ @client.event async def on_message(message): if message.author.bot: return if message.author.voice_channel is None: await self.bot.say('ボイスチャンネルに参加した上で、もう一度実行してください。') return False voice = await client.join_voice_channel(message.author.voice_channel) if message.content == ("スーモ"): player = await voice.create_ytdl_player('https://www.youtube.com/watch?v=ZiAOvG82xN4') player.start() client.run("token") # 「token」の部分は都合により変更しています。
試したこと
特になし
補足情報(FW/ツールのバージョンなど)
Windows10 Home x64 build 17134.165
Python 3.6.5
aiohttp 1.0.5
async-timeout 3.0.0
cffi 1.11.5
chardet 3.0.4
discord 0.0.2
discord.py 0.16.12
multidict 4.3.1
PyNaCl 1.2.1
six 1.11.0
websockets 3.4
youtube-dl 2018.7.10
まだ回答がついていません
会員登録して回答してみよう