Skip to content

Commit

Permalink
conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Drapersniper committed Apr 8, 2022
1 parent 6b245f1 commit 233f416
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 69 deletions.
7 changes: 6 additions & 1 deletion redbot/cogs/audio/apis/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 0 additions & 3 deletions redbot/cogs/audio/core/commands/equalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
63 changes: 16 additions & 47 deletions redbot/cogs/audio/core/commands/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <level> <mono> <band> <width>")
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion redbot/cogs/audio/core/events/lavalink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion redbot/cogs/audio/core/tasks/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions redbot/cogs/audio/core/utilities/equalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions redbot/cogs/audio/core/utilities/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion redbot/cogs/audio/core/utilities/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions redbot/cogs/audio/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.
Expand Down
9 changes: 1 addition & 8 deletions redbot/cogs/audio/menus/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 233f416

Please sign in to comment.