Уведомления

Группа в Telegram: @pythonsu

#1 Авг. 11, 2021 16:04:43

i4etverg_ex
Зарегистрирован: 2021-06-23
Сообщения: 18
Репутация: +  0  -
Профиль   Отправить e-mail  

Music Bot Discord

Всем привет.
Данный бот по команде ?play (ссылка) запускает музыку, но следующую ссылку не запускает и
приходится дисконектить его и только тогда он начинает запускать снова музыку.
Ошибку прикрепил ниже

Прошу наведите в чем ошибка и как её решить?

 import discord
from discord.ext import commands
import music
cogs = [music]
client = commands.Bot(command_prefix='?', intents = discord.Intents.all())
@client.command()
async def join1(ctx):
    await ctx.message.author.voice.channel.connect(reconnect=True)
for i in range(len(cogs)):
    cogs[i].setup(client)
client.run("token")

 import discord
from discord.ext import commands
from discord.voice_client import VoiceClient
import youtube_dl
class music(commands.Cog):
    def __init__(self, client):
        self.ydl_opts = {'format': 'bestaudio'}
        self.FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
                               'options': '-vn'}
        self.client = client
    @commands.command()
    async def join(self, ctx):
        if ctx.author.voice is None:
            await ctx.send('Ты не в голосовом канале!')
        else:
            await ctx.message.author.voice.channel.connect(reconnect=True)
    @commands.command()
    async def disconnect(self, ctx):
        if (ctx.guild.voice_client):  # If the bot is in a voice channel
            await ctx.guild.voice_client.disconnect()  # Leave the channel
            await ctx.channel.send('Вышел')
        else:  # But if it isn't
            await ctx.send("Я не нахожусь в голосовом канале! 😡")
    @commands.command()
    async def pause(self, ctx):
        await ctx.guild.voice_client.pause()
        await ctx.send('Пауза')
    @commands.command()
    async def resume(self, ctx):
        await ctx.guild.voice_client.resume()
        await ctx.send('Снять с паузы')
    @commands.command()
    async def play(self, ctx, url):
        channel = ctx.message.author.voice.channel
        voice = await channel.connect()
        with youtube_dl.YoutubeDL(self.ydl_opts) as ydl:
            source = ydl.extract_info(url, download=False)['formats'][0]['url']
        voice.play(discord.FFmpegPCMAudio(source, **self.FFMPEG_OPTIONS,
                                          executable="D:\\fail\\ff0808\\bin\\ffmpeg.exe"))
        voice.is_playing
def setup(client):
    client.add_cog(music(client))

Отредактировано i4etverg_ex (Авг. 11, 2021 16:04:54)

Прикреплённый файлы:
attachment error.png (72,8 KБ)

Офлайн

#2 Авг. 31, 2021 10:47:12

Bernard21
Зарегистрирован: 2021-08-31
Сообщения: 1
Репутация: +  0  -
Профиль   Отправить e-mail  

Music Bot Discord

Это то же самое, что я ищу о python на онлайн-radio en direct и на других форумах ИТ.

Отредактировано Bernard21 (Сен. 1, 2021 04:51:42)

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version