Проблема с воспроизведением звука в голосовом канале
У меня есть код, который может работать без ошибок и бот может подключиться к голосовому каналу, но при присоединении он ничего не делает. И он тоже ничего не отправляет. Мой файл ffmpeg.exe находится в том же каталоге, что и main.py. Я пытался сделать это другими способами, но столкнулся с той же проблемой.
main.py:
import discord
from discord.ext import tasks, commands
import yt_dlp
bot = discord.Bot()
@bot.slash_command(name="play", help="Play music")
async def play(ctx, url):
if ctx.voice_client is None:
if ctx.author.voice:
channel = ctx.author.voice.channel
vc = await channel.connect()
await play_music(vc, url)
else:
await ctx.respond("You are not connected to a voice channel.")
else:
await ctx.respond("I'm already connected to a voice channel.")
async def play_music(voice_client, url):
ffmpeg_path = "ffmpeg.exe"
voice_client.volume = 0.5
voice_client.play(discord.FFmpegPCMAudio(url, executable=ffmpeg_path), after=lambda e: print('Player error: %s' % e) if e else None)
bot.run(TOKEN)