This commit is contained in:
bot
2024-05-28 22:55:47 +03:00
parent 413736b44d
commit a136491362
4 changed files with 35 additions and 2 deletions

View File

@@ -55,10 +55,31 @@ class Audio(commands.Cog, name='Audio'):
):
if inter.author.voice is not None:
await inter.response.send_message(f'Played {audio}', ephemeral=True)
await play_audio(audio, self.bot, inter.author.voice.channel)
else:
await inter.response.send_message('You`re not in voice', ephemeral=True)
@commands.slash_command(name="play_random",
description="Make possible playing audio by command",
options=[
Option(name="num",
type=OptionType.integer,
)
])
async def playrandom(self, inter: disnake.ApplicationCommandInteraction,
num: int
):
if inter.author.voice is not None:
audio: list = []
for _a in ListGenerator('audio'):
audio.append(_a.name)
for i in range(num):
logger.info(f'Played {i+1} times')
await play_audio(f'audio/{random.choice(audio)}', self.bot, inter.author.voice.channel)
else:
await inter.response.send_message('You`re not in voice', ephemeral=True)
@playaudio.autocomplete('audio')
async def list_to_play(self, inter: disnake.ApplicationCommandInteraction, current: str):
current = current.lower()