前提・実現したいこと
身内のサーバーで使う目的で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
1import discord 2import youtube_dl 3 4# ログイン処理 5client = discord.Client() 6@client.event 7async def on_ready(): 8 print('以下のログイン情報でBOTにログインしています。↓↓↓') 9 print(client.user.name) 10 print(client.user.id) 11 print('起動完了') 12 13# 音割れスーモ 14@client.event 15async def on_message(message): 16 if message.author.bot: 17 return 18 if message.author.voice_channel is None: 19 await self.bot.say('ボイスチャンネルに参加した上で、もう一度実行してください。') 20 return False 21 22 23 voice = await client.join_voice_channel(message.author.voice_channel) 24 if message.content == ("スーモ"): 25 player = await voice.create_ytdl_player('https://www.youtube.com/watch?v=ZiAOvG82xN4') 26 player.start() 27 28client.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
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/16 04:53
2018/07/16 11:37
2018/07/16 12:16