Shard ID None voice heartbeat blocked for more than 10 seconds

45 Views Asked by At

I'm new to writing bots and I'm trying to create a music bot using the library discord.py and yt-dlp. But I get this error and I don't know what to do anymore. If anyone can help me, I will be grateful! This is my code:

import libraries

from discord.ext import commands
import yt_dlp as youtube_dl

intents = discord.Intents.default()
intents.typing = False
intents.presences = False
intents.message_content = True

TOKEN='my token'
bot = commands.Bot(command_prefix='!',intents=discord.Intents.all())

@bot.event
async def on_ready():
print(f'Бот {bot.user.name} готов к работе!')

#bot commands
@bot.command()
async def join(ctx):
channel = ctx.author.voice.channel
await channel.connect()

@bot.command()
async def leave(ctx):
await ctx.voice_client.disconnect()

@bot.command()
async def play(ctx, url):
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': \[{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}\],
}

    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        info = ydl.extract_info(url, download=True)
        url2 = info['formats'][0]['url']
        voice_client = ctx.voice_client
    
        FFMPEG_OPTIONS = {
            'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
            'options': '-vn'
        }
    
        voice_client.stop()
        voice_client.play(discord.FFmpegPCMAudio(url2, **FFMPEG_OPTIONS))

@bot.command()
async def pause(ctx):
ctx.voice_client.pause()

@bot.command()
async def resume(ctx):
ctx.voice_client.resume()

bot.run(TOKEN)```
0

There are 0 best solutions below