diff --git a/redbot/cogs/audio/apis/interface.py b/redbot/cogs/audio/apis/interface.py index 8a4c3b5b1e1..b3c5e84b546 100644 --- a/redbot/cogs/audio/apis/interface.py +++ b/redbot/cogs/audio/apis/interface.py @@ -1011,7 +1011,12 @@ async def autoplay(self, player: lavalink.Player, playlist_api: PlaylistWrapper) await self.config.guild_from_id( guild_id=player.guild.id ).currently_auto_playing_in.set( - [notify_channel_id, player.channel.id, player.paused, player.volume] + [ + notify_channel_id, + player.channel.id, + player.paused, + player.volume.get_old_compat(), + ] ) else: await self.config.guild_from_id( diff --git a/redbot/cogs/audio/core/commands/equalizer.py b/redbot/cogs/audio/core/commands/equalizer.py index 6c63e195b23..b999eecdd42 100644 --- a/redbot/cogs/audio/core/commands/equalizer.py +++ b/redbot/cogs/audio/core/commands/equalizer.py @@ -126,9 +126,6 @@ async def command_equalizer_list(self, ctx: commands.Context): eq_presets["Metal"] = lavalink.Equalizer.metal().get() eq_presets["BassBoost"] = lavalink.Equalizer.boost().get() eq_presets["Boost"] = lavalink.Equalizer.boost().get() - - if not eq_presets.keys(): - return await self.send_embed_msg(ctx, title=_("No saved equalizer presets.")) await AudioPaginatingMenu( cog=ctx.cog, bot=self.bot, diff --git a/redbot/cogs/audio/core/commands/filters.py b/redbot/cogs/audio/core/commands/filters.py index 80134b13aa4..9907d55bba8 100644 --- a/redbot/cogs/audio/core/commands/filters.py +++ b/redbot/cogs/audio/core/commands/filters.py @@ -80,7 +80,7 @@ async def command_effects(self, ctx: commands.Context): await self.send_embed_msg( ctx, title=_("Here is the music effects status:"), - description=box(tabulate(data)), + description=box(tabulate(data, headers="keys")), ) @command_effects.command(name="karaoke", usage="off OR ") @@ -95,9 +95,7 @@ async def command_effects_karaoke( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -137,11 +135,8 @@ async def command_effects_timescale( if not self._player_check(ctx): ctx.command.reset_cooldown(ctx) return await self.send_embed_msg(ctx, title=_("Nothing playing.")) - player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -201,9 +196,7 @@ async def command_effects_tremolo( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -265,9 +258,7 @@ async def command_effects_vibrato( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -328,9 +319,7 @@ async def command_effects_rotation( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -370,9 +359,7 @@ async def command_effects_distortion( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -415,9 +402,7 @@ async def command_effects_reset(self, ctx: commands.Context): return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -462,9 +447,7 @@ async def command_effects_bassboost( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -510,9 +493,7 @@ async def command_effects_piano(self, ctx: commands.Context, *, state: OffConver return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -558,9 +539,7 @@ async def command_effects_metal(self, ctx: commands.Context, *, state: OffConver return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -606,9 +585,7 @@ async def command_effects_nightcore( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -676,9 +653,7 @@ async def command_effects_vaporwave( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -748,9 +723,7 @@ async def command_effects_synth(self, ctx: commands.Context, *, state: OffConver return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -849,9 +822,7 @@ async def command_effects_channelmix( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) @@ -894,9 +865,7 @@ async def command_effects_lowpass( return await self.send_embed_msg(ctx, title=_("Nothing playing.")) player = lavalink.get_player(ctx.guild.id) - dj_enabled = self._dj_status_cache.setdefault( - ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled() - ) + dj_enabled = self._dj_status_cache.get(ctx.guild.id) can_skip = await self._can_instaskip(ctx, ctx.author) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: ctx.command.reset_cooldown(ctx) diff --git a/redbot/cogs/audio/core/events/lavalink.py b/redbot/cogs/audio/core/events/lavalink.py index 07fc6ef1d36..af64e3a3cab 100644 --- a/redbot/cogs/audio/core/events/lavalink.py +++ b/redbot/cogs/audio/core/events/lavalink.py @@ -152,7 +152,12 @@ async def lavalink_event_handler( notify_channel = player.fetch("notify_channel") if notify_channel and autoplay: await self.config.guild_from_id(guild_id=guild_id).currently_auto_playing_in.set( - [notify_channel, player.channel.id, player.paused, player.volume] + [ + notify_channel, + player.channel.id, + player.paused, + player.volume.get_old_compat(), + ] ) else: await self.config.guild_from_id(guild_id=guild_id).currently_auto_playing_in.set( diff --git a/redbot/cogs/audio/core/tasks/startup.py b/redbot/cogs/audio/core/tasks/startup.py index e4fa6306781..de65b594e2a 100644 --- a/redbot/cogs/audio/core/tasks/startup.py +++ b/redbot/cogs/audio/core/tasks/startup.py @@ -214,7 +214,7 @@ async def restore_players(self) -> None: player._paused = paused if player.volume != volume: await player.set_volume(volume.get_old_compat()) - await self._eq_check(player=player, ctx=ctx(guild)) + await self._eq_check(player=player, ctx=ctx(guild)) if player.guild.id in current_track_meta: player.current = current_track_meta[player.guild.id] await player.resume( diff --git a/redbot/cogs/audio/core/utilities/equalizer.py b/redbot/cogs/audio/core/utilities/equalizer.py index 979e08839e3..933a1b2185f 100644 --- a/redbot/cogs/audio/core/utilities/equalizer.py +++ b/redbot/cogs/audio/core/utilities/equalizer.py @@ -4,8 +4,6 @@ import discord import lavalink -from lavalink import NodeNotFound, PlayerNotFound -from lavalink.filters import Equalizer from red_commons.logging import getLogger from redbot.core import commands diff --git a/redbot/cogs/audio/core/utilities/menu.py b/redbot/cogs/audio/core/utilities/menu.py index cd22712a582..f225f4da627 100644 --- a/redbot/cogs/audio/core/utilities/menu.py +++ b/redbot/cogs/audio/core/utilities/menu.py @@ -239,15 +239,21 @@ async def menu_disconnect( return False self.bot.dispatch("red_audio_audio_disconnect", ctx.guild) self.update_player_lock(ctx, False) - eq = player.fetch("eq") player.queue = [] player.store("playing_song", None) player.store("autoplay_notified", False) - if eq: - await self.config.custom("EQUALIZER", str(ctx.guild.id)).eq_bands.set(eq.bands) + if player.equalizer.changed: + async with self.config.custom("EQUALIZER", str(ctx.guild.id)).all() as eq_data: + eq_data["eq_bands"] = player.equalizer.get() + eq_data["name"] = player.equalizer.name await player.stop() await player.disconnect() - await self.config.guild_from_id(guild_id=ctx.guild.id).currently_auto_playing_in.set([]) self._ll_guild_updates.discard(ctx.guild.id) await self.api_interface.persistent_queue_api.drop(ctx.guild.id) + await self.clean_up_guild_config( + "last_known_vc_and_notify_channels", + "last_known_track", + "currently_auto_playing_in", + guild_ids=[ctx.guild.id], + ) return True diff --git a/redbot/cogs/audio/core/utilities/player.py b/redbot/cogs/audio/core/utilities/player.py index 1e16ddaa503..5bda1e3a14e 100644 --- a/redbot/cogs/audio/core/utilities/player.py +++ b/redbot/cogs/audio/core/utilities/player.py @@ -42,7 +42,7 @@ async def save_player_state(self) -> None: if guild_id: last_known_vc_and_notify_channels = ( "last_known_vc_and_notify_channels", - [notify_channel, vc_id, player.paused, player.volume], + [notify_channel, vc_id, player.paused, player.volume.get_old_compat()], ) if player.current: data = self.get_track_json(player, position="np") diff --git a/redbot/cogs/audio/manager.py b/redbot/cogs/audio/manager.py index a756a767541..9d59295856f 100644 --- a/redbot/cogs/audio/manager.py +++ b/redbot/cogs/audio/manager.py @@ -524,6 +524,7 @@ async def start_monitor(self, java_path: str): while True: await self.wait_until_ready(timeout=self.timeout) if not psutil.pid_exists(self._node_pid): + log.debug("Lavalink process died, restarting...") raise NoProcessFound try: lavalink.get_all_nodes()[0] @@ -549,6 +550,7 @@ async def start_monitor(self, java_path: str): ) await lavalink.wait_until_ready(timeout=60, wait_if_no_node=60) except asyncio.TimeoutError: + log.debug("Managed node monitor timed out waiting for RLL to connect") await self.cog.save_player_state() self.cog.lavalink_restart_connect(manual=True) return # lavalink_restart_connect will cause a new monitor task to be created. diff --git a/redbot/cogs/audio/menus/menus.py b/redbot/cogs/audio/menus/menus.py index 84e6f79b649..95f35a32685 100644 --- a/redbot/cogs/audio/menus/menus.py +++ b/redbot/cogs/audio/menus/menus.py @@ -980,14 +980,7 @@ async def prepare(self): self.queue_disconnect_all_label.disabled = True self.queue_disconnect_inactive_label.disabled = True - if max_pages > 2: - self.forward_button.disabled = False - self.backward_button.disabled = False - self.first_button.disabled = False - self.last_button.disabled = False - elif max_pages == 2: - self.forward_button.disabled = False - self.backward_button.disabled = False + if max_pages == 2: self.first_button.disabled = True self.last_button.disabled = True elif max_pages == 1: diff --git a/setup.cfg b/setup.cfg index 478df814826..cb9fc658823 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,7 +66,7 @@ install_requires = pytz==2021.1 PyYAML==5.4.1 Red-Commons==1.0.0 - Red-Lavalink @ git+https://github.com/Cog-Creators/Red-Lavalink@refs/pull/125/merge#egg=Red-Lavalink + Red-Lavalink @ git+https://github.com/Cog-Creators/Red-Lavalink@refs/pull/126/merge#egg=Red-Lavalink rich==10.9.0 schema==0.7.4 six==1.16.0