Files
discord_bot/lib/Player.py
2022-08-23 02:23:27 +03:00

20 lines
517 B
Python

import logging
import random
from asyncio import sleep
from disnake import FFmpegPCMAudio
async def play_audio(full_audio, bot, vc):
if not bot.voice_clients:
audio = random.choice(full_audio)
logging.error(f'Playing: {audio}')
await sleep(1)
vp = await vc.connect()
if not vp.is_playing():
vp.play(FFmpegPCMAudio(f'audio/{audio}'), after=None)
while vp.is_playing():
await sleep(0.5)
await sleep(1)
await vp.disconnect()