mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-08 18:32:32 -05:00
Bump RLL and improve logging (#5044)
* version bump * - bump RLL - logging changes - player.channel.guild->player.guild - small cleanup around logging changes * missed one * here this one too * Apply suggestions from code review Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * add one missing player log * missed one * Format with Black Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
@@ -24,7 +24,7 @@ class PlayerTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
pause_times: Dict = {}
|
||||
while True:
|
||||
async for p in AsyncIter(lavalink.all_players()):
|
||||
server = p.channel.guild
|
||||
server = p.guild
|
||||
if await self.bot.cog_disabled_in_guild(self, server):
|
||||
continue
|
||||
|
||||
@@ -37,11 +37,7 @@ class PlayerTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
try:
|
||||
await p.pause(False)
|
||||
except Exception as err:
|
||||
debug_exc_log(
|
||||
log,
|
||||
err,
|
||||
f"Exception raised in Audio's unpausing player for {server.id}.",
|
||||
)
|
||||
debug_exc_log(log, err, "Exception raised in Audio's unpausing %r.", p)
|
||||
pause_times.pop(server.id, None)
|
||||
servers = stop_times.copy()
|
||||
servers.update(pause_times)
|
||||
@@ -61,7 +57,7 @@ class PlayerTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
).currently_auto_playing_in.set([])
|
||||
except Exception as err:
|
||||
debug_exc_log(
|
||||
log, err, f"Exception raised in Audio's emptydc_timer for {sid}."
|
||||
log, err, "Exception raised in Audio's emptydc_timer for %s.", sid
|
||||
)
|
||||
|
||||
elif sid in stop_times and await self.config.guild(server_obj).emptydc_enabled():
|
||||
@@ -81,7 +77,7 @@ class PlayerTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
if "No such player for that guild" in str(err):
|
||||
stop_times.pop(sid, None)
|
||||
debug_exc_log(
|
||||
log, err, f"Exception raised in Audio's emptydc_timer for {sid}."
|
||||
log, err, "Exception raised in Audio's emptydc_timer for %s.", sid
|
||||
)
|
||||
elif (
|
||||
sid in pause_times and await self.config.guild(server_obj).emptypause_enabled()
|
||||
@@ -94,6 +90,6 @@ class PlayerTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
if "No such player for that guild" in str(err):
|
||||
pause_times.pop(sid, None)
|
||||
debug_exc_log(
|
||||
log, err, f"Exception raised in Audio's pausing for {sid}."
|
||||
log, err, "Exception raised in Audio's pausing for %s.", sid
|
||||
)
|
||||
await asyncio.sleep(5)
|
||||
|
||||
@@ -31,6 +31,7 @@ class StartUpTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
# There has to be a task since this requires the bot to be ready
|
||||
# If it waits for ready in startup, we cause a deadlock during initial load
|
||||
# as initial load happens before the bot can ever be ready.
|
||||
lavalink.set_logging_level(self.bot._cli_flags.logging_level)
|
||||
self.cog_init_task = self.bot.loop.create_task(self.initialize())
|
||||
self.cog_init_task.add_done_callback(task_callback)
|
||||
|
||||
@@ -139,7 +140,9 @@ class StartUpTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
tries += 1
|
||||
except Exception as exc:
|
||||
tries += 1
|
||||
debug_exc_log(log, exc, "Failed to restore music voice channel")
|
||||
debug_exc_log(
|
||||
log, exc, "Failed to restore music voice channel %s", vc_id
|
||||
)
|
||||
if vc is None:
|
||||
break
|
||||
else:
|
||||
@@ -160,8 +163,9 @@ class StartUpTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
player.maybe_shuffle()
|
||||
if not player.is_playing:
|
||||
await player.play()
|
||||
log.info("Restored %r", player)
|
||||
except Exception as err:
|
||||
debug_exc_log(log, err, f"Error restoring player in {guild_id}")
|
||||
debug_exc_log(log, err, "Error restoring player in %d", guild_id)
|
||||
await self.api_interface.persistent_queue_api.drop(guild_id)
|
||||
|
||||
for guild_id, (notify_channel_id, vc_id) in metadata.items():
|
||||
@@ -208,7 +212,7 @@ class StartUpTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
tries += 1
|
||||
except Exception as exc:
|
||||
tries += 1
|
||||
debug_exc_log(log, exc, "Failed to restore music voice channel")
|
||||
debug_exc_log(log, exc, "Failed to restore music voice channel %s", vc_id)
|
||||
if vc is None:
|
||||
break
|
||||
else:
|
||||
@@ -222,6 +226,7 @@ class StartUpTasks(MixinMeta, metaclass=CompositeMetaClass):
|
||||
if player.volume != volume:
|
||||
await player.set_volume(volume)
|
||||
player.maybe_shuffle()
|
||||
log.info("Restored %r", player)
|
||||
if not player.is_playing:
|
||||
notify_channel = player.fetch("channel")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user