- 39
- 7
Че делать если такая вот ошибка вылазит?
Код Бота
Код Бота
Код:
import discord
import json
from discord.ext import commands
from youtube_dl import YoutubeDL
file = open('config.json', 'r')
config = json.load(file)
YDL_OPTIONS = {'format': 'worstaudio/best', 'noplaylist': 'False', 'simulate': 'True', 'key': 'FFmpegExtractAudio'}
FFMPEG_OPTIONS = {'before_options': '-reconect 1 -reconect_streamed 1 -reconect_delay_max 5', 'options': '-vn'}
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=config['prefix'], intents=intents)
client = discord.Client(intents=intents)
@bot.command()
async def play(ctx, url):
vc = await ctx.message.author.voice.channel.connect()
with YoutubeDL(YDL_OPTIONS) as ydl:
if 'https://' in url:
info = ydl.extract_info(url, download=False)
else:
info = ydl.extract_info(f"ytsearch:{url}", download=False)['entries'][0]
link = info['formats'][0]['url']
vc.play(discord.FFmpegPCMAudio(executable="ffmpeg\\ffmpeg.exe", source=link, **FFMPEG_OPTIONS))
# @bot.command(name='ping')
# async def ping(ctx):
# await ctx.send(f'{ctx.author.mention} pong')
bot.run(config['token'])
Вложения
Последнее редактирование: