diff --git a/.gitignore b/.gitignore index 120dd17..3f64da8 100755 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ /venv/ /fun_and_admin_bot.egg-info/ /.YMcache/ -config.json \ No newline at end of file +config.json +/env/ +/.project diff --git a/check.py b/check.py new file mode 100755 index 0000000..503bf1b --- /dev/null +++ b/check.py @@ -0,0 +1,10 @@ +for i in range(133): + + if i in [11, 12, 13, 14]: + print(f'{i} дней') + elif i % 10 == 1: + print(f'{i} день') + elif i % 10 in [2, 3, 4]: + print(f'{i} дня') + else: + print(f'{i} дней') diff --git a/cogs/audio.py b/cogs/audio.py index 55775ab..1b72b54 100644 --- a/cogs/audio.py +++ b/cogs/audio.py @@ -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() diff --git a/lib/Player.py b/lib/Player.py index 1466e89..942d3d7 100644 --- a/lib/Player.py +++ b/lib/Player.py @@ -13,7 +13,7 @@ async def play_audio(audio, bot, vc): logger.error(f'Playing: {audio}') vp = await vc.connect() if not vp.is_playing(): - vp.play(FFmpegOpusAudio(f'{audio}', )) + vp.play(FFmpegOpusAudio(f'{audio}', executable='ffmpeg', options='-nostats -loglevel 0')) while vp.is_playing(): await sleep(0.5) await sleep(1)