import discord from discord.ext import commands import asyncio import os import subprocess import ffmpeg from voice_generator import creat_WAV client = commands.Bot(command_prefix='.') voice_client = None @client.event async def on_ready(): print('Logged in as') print(client.user.name) print(client.user.id) print('------') @client.command() async def join(ctx): print('#join') print('#voicechannelを取得') vc = ctx.author.voice.channel print('#voicechannelに接続') await vc.connect() @client.command() async def bye(ctx): print('#bye') print('#切断') await ctx.voice_client.disconnect() @client.command() async def register(ctx, arg1, arg2): with open('C:/open_jtalk/bin/dic.txt', mode='a') as f: f.write('\n'+ arg1 + ',' + arg2) print('dic.txtに書き込み:''\n'+ arg1 + ',' + arg2) await ctx.send('`' + arg1+'` を `'+arg2+'` として登録しました') @client.event async def on_voice_state_update(member, before, after): server_id_test = "サーバーID" text_id_test = "チャンネルID" if member.guild.id == server_id_test: # サーバーid text_ch = client.get_channel(text_id_test) # 通知させたいTEXTチャンネルid if before.channel is None: msg = f'【VC参加ログ】{member.name} が {after.channel.name} に参加しました。' await text_ch.send(msg) @client.event async def on_message(message): print('---on_message_start---') msgclient = message.guild.voice_client print(msgclient) if message.content.startswith('.'): pass else: if message.guild.voice_client: print('#message.content:'+ message.content) creat_WAV(message.content) source = discord.FFmpegPCMAudio("output.wav") message.guild.voice_client.play(source) else: pass await client.process_commands(message) print('---on_message_end---') client.run("botのトークン") ``` ```### 前提・実現したいこと https://qiita.com/Nemy/items/d895114d3ba9a9d7cb62 上記のサイトを参考にディスコードでテキスト読み上げbotを作成しています。 ### 発生している問題・エラーメッセージ .joinと打ったらボイスチャンネルに入出するはずなのですが反応しません。 エラー None #join #voicechannelを取得 #voicechannelに接続 ---on_message_end--- Ignoring exception in command join: Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, i n wrapped ret = await coro(*args, **kwargs) File "C:\open_jtalk\bin\read_bot.py", line 27, in join await vc.connect() File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 1277, in connect voice = cls(client, self) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\voice_client.py", line 199, in __ init__ raise RuntimeError("PyNaCl library needed in order to use voice") RuntimeError: PyNaCl library needed in order to use voice The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, i n invoke await ctx.command.invoke(ctx) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, i n wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in orde r to use voice ### 試したこと 権限の確認、botの再起動、再招待 ### 補足情報(FW/ツールのバージョンなど) 環境はWindows10、python3.7.9 上記のサイト通りに作成したのですがうまくいかなく困っています。どうぞよろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー