From 1efcabada136e92eeb3d5411113be923256f80ba Mon Sep 17 00:00:00 2001 From: Draper <27962761+Drapersniper@users.noreply.github.com> Date: Mon, 17 May 2021 10:38:30 +0100 Subject: [PATCH] Cleanup `[p]volume` and fix infinite retrying in autoplay (#5045) * This PR depends on Part 2 due to new store value - cleanup of [p]volume - a fix for infinite retrying * update `[p]volume` help * Update controller.py * Update redbot/cogs/audio/core/commands/controller.py meh still hardcoded in RLL .. will be removed in 0.9 Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Update redbot/cogs/audio/core/commands/controller.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/audio/core/commands/controller.py | 28 ++++++------------- redbot/cogs/audio/core/events/cog.py | 1 + 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/redbot/cogs/audio/core/commands/controller.py b/redbot/cogs/audio/core/commands/controller.py index 84a60c0ad..c143b8018 100644 --- a/redbot/cogs/audio/core/commands/controller.py +++ b/redbot/cogs/audio/core/commands/controller.py @@ -710,7 +710,7 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass): can_skip = await self._can_instaskip(ctx, ctx.author) if not vol: vol = await self.config.guild(ctx.guild).volume() - embed = discord.Embed(title=_("Current Volume:"), description=str(vol) + "%") + embed = discord.Embed(title=_("Current Volume:"), description=f"{vol}%") if not self._player_check(ctx): embed.set_footer(text=_("Nothing playing.")) return await self.send_embed_msg(ctx, embed=embed) @@ -733,25 +733,15 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass): description=_("You need the DJ role to change the volume."), ) - if vol < 0: - vol = 0 - if vol > 150: - vol = 150 - await self.config.guild(ctx.guild).volume.set(vol) - if self._player_check(ctx): - player = lavalink.get_player(ctx.guild.id) - await player.set_volume(vol) - player.store("channel", ctx.channel.id) - player.store("guild", ctx.guild.id) - else: - await self.config.guild(ctx.guild).volume.set(vol) - if self._player_check(ctx): - player = lavalink.get_player(ctx.guild.id) - await player.set_volume(vol) - player.store("channel", ctx.channel.id) - player.store("guild", ctx.guild.id) + vol = max(0, min(vol, 150)) + await self.config.guild(ctx.guild).volume.set(vol) + if self._player_check(ctx): + player = lavalink.get_player(ctx.guild.id) + await player.set_volume(vol) + player.store("channel", ctx.channel.id) + player.store("guild", ctx.guild.id) - embed = discord.Embed(title=_("Volume:"), description=str(vol) + "%") + embed = discord.Embed(title=_("Volume:"), description=f"{vol}%") if not self._player_check(ctx): embed.set_footer(text=_("Nothing playing.")) await self.send_embed_msg(ctx, embed=embed) diff --git a/redbot/cogs/audio/core/events/cog.py b/redbot/cogs/audio/core/events/cog.py index 391a41aed..dc487343b 100644 --- a/redbot/cogs/audio/core/events/cog.py +++ b/redbot/cogs/audio/core/events/cog.py @@ -200,6 +200,7 @@ class AudioEvents(MixinMeta, metaclass=CompositeMetaClass): await asyncio.sleep(0.1) if tries > 1000: return + tries += 1 if notify_channel and not player.fetch("autoplay_notified", False): if (