discord.pyのボイスチャンネルで音楽を再生したい
discordのbotをつっくています。
ボイスチャンネルを使いbotで音楽を流せるようにしたいです。
動作環境
windows10
python3.9
ffmpeg
discord.py
python
1@client.command() 2async def play(ctx): 3 if ctx.author.voice is None: 4 await ctx.send("いずれかのボイスチャンネルに接続してください") 5 return 6 else: 7 await ctx.author.voice.channel.connect() 8 voice_client = ctx.message.guild.voice_client 9 if not voice_client: 10 await ctx.send("ボイスチャンネルの接続に失敗しました") 11 return 12 if ctx.message.attachments: 13 await ctx.send("添付された曲を再生します") 14 await ctx.message.attachments[0].save("tmp.mp3") 15 music = "tmp.mp3" 16 ffmpeg_audio_source = discord.FFmpegPCMAudio("tmp.mp3") 17 voice_client.play(ffmpeg_audio_source) 18 return 19 else: 20 await ctx.send("ファイルを添付してください") 21
エラー
Ignoring exception in command play: Traceback (most recent call last): File "C:\Users****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "c:\Users***\Desktop\discord\discord.bot\voicebot.py", line 24, in play ffmpeg_audio_source = discord.FFmpegPCMAudio("tmp.mp3") File "C:\Users****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\player.py", line 225, in __init__ super().__init__(source, executable=executable, args=args, **subprocess_kwargs) File "C:\Users****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\player.py", line 138, in __init__ self._process = self._spawn_process(args, **kwargs) File "C:\Users****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\player.py", line 147, in _spawn_process raise ClientException(executable + ' was not found.') from None discord.errors.ClientException: ffmpeg was not found. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "C:\Users****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "C:\Users****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found.
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/09/11 10:27
2021/09/11 10:35
2021/09/11 10:37
2021/09/11 10:40
2021/09/11 10:55