30 lines
826 B
Python
30 lines
826 B
Python
import logging
|
|
from asyncio import sleep
|
|
from typing import Union, Optional
|
|
|
|
import disnake
|
|
from disnake import FFmpegPCMAudio
|
|
from disnake.ext import commands
|
|
|
|
|
|
async def play_audio(audio, bot, vc):
|
|
if not bot.voice_clients:
|
|
logging.info(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()
|
|
|
|
|
|
async def get_audio_list(inter: Union[disnake.ApplicationCommandInteraction, commands.Context],
|
|
search: Optional[str],
|
|
return_embed: bool = False,
|
|
) -> None:
|
|
|
|
await list_files()
|