D
D
DVSofter2020-12-04 23:06:08
Python
DVSofter, 2020-12-04 23:06:08

Error creating music bot?

@client.command()
async def play(ctx, url : str):
    song_there = os.path.isfile('song.mp3')

    try:
        if song_there:
            os.remove('song.mp3')
            print('[log] Старий файл удален')
    except PermissionError:
        print('[log] Не удалось удалить файл')

    await ctx.send('пожалуста ожидайте')

    voice = get(client.voice_clients, guild = ctx.guild)

    ydl_opts ={
        'format' : 'bestaudio/best',
        'postprocessors' : [{
            'key' : 'FFmpegExtractAudio',
            'preferredcodec' : 'mp3',
            'preferredquality' : '192'
        }],
    }

    with youtube_dl.YoutubeDL(ydl_opts) as ydl :
        print('[log] Загружаю Музику...')
        ydl.download([url])

    for file in os.listdir('./'):
        if file.endswith('.webm'):
            name = file
            print('[log] переименовиваю файл {file}')
            os.rename(file, 'song.mp3')

    voice.play(discord.FFmpegPCMAudio('song.mp3'), after = lambda e: print(f'[log] {name}, музика закончила свое проигрование'))
    voice.sourse = discord.PCMVolumeTransformer(voice.sourse)
    voice.sourse.volume = 0.07

    song_name = name.rsplist('-', 2)
    await ctx.send(f'Сейчас проигривает музика: {song_name[0]}')


Command raised an exception: DownloadError: ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuribtr, 2020-12-05
@Yuribtr

There are no telepaths here. Write the text of the error.
And it looks like you have a typo - the third line of code from the bottom is the variable voise

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question