Audio changes (#5593)

* Squash tested commits

* remove the code jack is concerned about

* Apply suggestions from code review

* more log lines

* more log lines

* format

* formatting

* style(Rename Xms and Xmx mentions): Rename Xms and Xmx to more use friendly names

- Change Xms to "Initial Heapsize"
- Change Xmx to "Max Heapsize"

Signed-off-by: Draper <27962761+Drapersniper@users.noreply.github.com>
This commit is contained in:
Draper
2022-03-28 16:23:30 +01:00
committed by GitHub
parent 5a5b22003f
commit 9ec85d4819
28 changed files with 1629 additions and 599 deletions

View File

@@ -123,7 +123,7 @@ class AudioEvents(MixinMeta, metaclass=CompositeMetaClass):
bot=self.bot,
)
except Exception as exc:
log.verbose("Failed to delete daily playlist ID: %d", too_old_id, exc_info=exc)
log.verbose("Failed to delete daily playlist ID: %s", too_old_id, exc_info=exc)
try:
await delete_playlist(
scope=PlaylistScope.GLOBAL.value,
@@ -135,7 +135,7 @@ class AudioEvents(MixinMeta, metaclass=CompositeMetaClass):
)
except Exception as exc:
log.verbose(
"Failed to delete global daily playlist ID: %d", too_old_id, exc_info=exc
"Failed to delete global daily playlist ID: %s", too_old_id, exc_info=exc
)
persist_cache = self._persist_queue_cache.setdefault(
guild.id, await self.config.guild(guild).persist_queue()
@@ -195,7 +195,9 @@ class AudioEvents(MixinMeta, metaclass=CompositeMetaClass):
requester: discord.Member,
player: lavalink.Player,
):
notify_channel = self.bot.get_channel(player.fetch("notify_channel"))
if not guild:
return
notify_channel = guild.get_channel(player.fetch("notify_channel"))
has_perms = self._has_notify_perms(notify_channel)
tries = 0
while not player._is_playing:

View File

@@ -1,9 +1,11 @@
import asyncio
import contextlib
import random
import re
from collections import OrderedDict
from pathlib import Path
from string import ascii_letters, digits
from typing import Final, Pattern
import discord
@@ -12,19 +14,145 @@ from red_commons.logging import getLogger
from aiohttp import ClientConnectorError
from discord.ext.commands import CheckFailure
from lavalink import NodeNotFound, PlayerNotFound
from redbot.core import commands
from redbot.core.i18n import Translator
from redbot.core.utils.chat_formatting import box, humanize_list
from redbot.core.utils.antispam import AntiSpam
from redbot.core.utils.chat_formatting import box, humanize_list, underline, bold
from ...errors import TrackEnqueueError
from ...errors import TrackEnqueueError, AudioError
from ..abc import MixinMeta
from ..cog_utils import HUMANIZED_PERM, CompositeMetaClass
from ...utils import task_callback_trace
from ..cog_utils import CompositeMetaClass
log = getLogger("red.cogs.Audio.cog.Events.dpy")
_ = Translator("Audio", Path(__file__))
_T = Translator("Audio", Path(__file__))
_ = lambda s: s
RE_CONVERSION: Final[Pattern] = re.compile('Converting to "(.*)" failed for parameter "(.*)".')
HUMANIZED_PERM = {
"create_instant_invite": _("Create Instant Invite"),
"kick_members": _("Kick Members"),
"ban_members": _("Ban Members"),
"administrator": _("Administrator"),
"manage_channels": _("Manage Channels"),
"manage_guild": _("Manage Server"),
"add_reactions": _("Add Reactions"),
"view_audit_log": _("View Audit Log"),
"priority_speaker": _("Priority Speaker"),
"stream": _("Go Live"),
"read_messages": _("Read Text Channels & See Voice Channels"),
"send_messages": _("Send Messages"),
"send_tts_messages": _("Send TTS Messages"),
"manage_messages": _("Manage Messages"),
"embed_links": _("Embed Links"),
"attach_files": _("Attach Files"),
"read_message_history": _("Read Message History"),
"mention_everyone": _("Mention @everyone, @here, and All Roles"),
"external_emojis": _("Use External Emojis"),
"view_guild_insights": _("View Server Insights"),
"connect": _("Connect"),
"speak": _("Speak"),
"mute_members": _("Mute Members"),
"deafen_members": _("Deafen Members"),
"move_members": _("Move Members"),
"use_voice_activation": _("Use Voice Activity"),
"change_nickname": _("Change Nickname"),
"manage_nicknames": _("Manage Nicknames"),
"manage_roles": _("Manage Roles"),
"manage_webhooks": _("Manage Webhooks"),
"manage_emojis": _("Manage Emojis"),
}
DANGEROUS_COMMANDS = {
"command_llsetup_java": _(
"This command will change the executable path of Java, "
"this is useful if you have multiple installations of Java and the default one is causing issues. "
"Please don't change this unless you are certain that the Java version you are specifying is supported by Red. "
"The default and supported version is currently Java 11."
),
"command_llsetup_heapsize": _(
"This command will change the maximum RAM allocation for the managed Lavalink node, "
"usually you will never have to change this, "
"before considering changing it please consult our support team."
),
"command_llsetup_external": _(
"This command will disable the managed Lavalink node, "
"if you toggle this command you must specify an external Lavalink node to connect to, "
"if you do not do so Audio will stop working."
),
"command_llsetup_host": _(
"This command is used to specify the IP which will be used by Red to connect to an external Lavalink node. "
),
"command_llsetup_password": _(
"This command is used to specify the authentication password used by Red to connect to an "
"external Lavalink node."
),
"command_llsetup_secured": _(
"This command is used toggle between secured and unsecured connections to an external Lavalink node."
),
"command_llsetup_wsport": _(
"This command is used to specify the connection port used by Red to connect to an external Lavalink node."
),
"command_llsetup_config_host": _(
"This command specifies which network interface and IP the managed Lavalink node will bind to, "
"by default this is 'localhost', "
"only change this if you want the managed Lavalink node to bind to a specific IP/interface."
),
"command_llsetup_config_token": _(
"This command changes the authentication password required to connect to this managed node."
"The default value is 'youshallnotpass'."
),
"command_llsetup_config_port": _(
"This command changes the connection port used to connect to this managed node, "
"only change this if the default port '2333' is causing conflicts with existing applications."
),
"command_llsetup_config_source_http": _(
"This command toggles the support of direct url streams like Icecast or Shoutcast streams. "
"An example is <http://ice6.somafm.com/gsclassic-128-mp3>; "
"Disabling this will make the bot unable to play any direct url steam content."
),
"command_llsetup_config_source_bandcamp": _(
"This command toggles the support of Bandcamp audio playback. "
"An example is <http://deaddiskdrive.bandcamp.com/track/crystal-glass>; "
"Disabling this will make the bot unable to play any Bandcamp content",
),
"command_llsetup_config_source_local": _(
"This command toggles the support of local track audio playback. "
"for example `/mnt/data/my_super_funky_track.mp3`; "
"Disabling this will make the bot unable to play any local track content."
),
"command_llsetup_config_source_soundcloud": _(
"This command toggles the support of Soundcloud playback. "
"An example is <https://soundcloud.com/user-103858850/tilla>; "
"Disabling this will make the bot unable to play any Soundcloud content."
),
"command_llsetup_config_source_youtube": _(
"This command toggles the support of YouTube playback (Spotify depends on YouTube). "
"Disabling this will make the bot unable to play any YouTube content, "
"this includes Spotify."
),
"command_llsetup_config_source_twitch": _(
"This command toggles the support of Twitch playback. "
"An example of this is <https://twitch.tv/monstercat>; "
"Disabling this will make the bot unable to play any Twitch content."
),
"command_llsetup_config_source_vimeo": _(
"This command toggles the support of Vimeo playback. "
"An example of this is <https://vimeo.com/157743578>; "
"Disabling this will make the bot unable to play any Vimeo content."
),
"command_llsetup_config_server_framebuffer": _(
"This setting controls the managed nodes framebuffer, "
"Do not change this unless instructed."
),
"command_llsetup_config_server_buffer": _(
"This setting controls the managed nodes NAS buffer, "
"Do not change this unless instructed."
),
"command_llsetup_reset": _("This command will reset every setting changed by `[p]llset`."),
}
_ = _T
class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
@@ -39,12 +167,12 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
elif self.lavalink_connect_task and self.lavalink_connect_task.cancelled():
await ctx.send(
_(
"You have attempted to run Audio's Lavalink server on an unsupported"
"You have attempted to run Audio's managed Lavalink node on an unsupported"
" architecture. Only settings related commands will be available."
)
)
raise RuntimeError(
"Not running audio command due to invalid machine architecture for Lavalink."
raise AudioError(
"Not running Audio command due to invalid machine architecture for the managed Lavalink node."
)
current_perms = ctx.channel.permissions_for(ctx.me)
@@ -62,7 +190,7 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
missing_perms = OrderedDict(sorted(missing_perms.items()))
missing_permissions = missing_perms.keys()
log.debug(
"Missing the following perms in %d, Owner ID: %d: %s",
"Missing the following perms in %s, Owner ID: %s: %s",
ctx.guild.id,
ctx.guild.owner.id,
humanize_list(list(missing_permissions)),
@@ -76,14 +204,14 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
for perm, value in missing_perms.items():
text += "{perm}: [{status}]\n".format(
status=_("Enabled") if value else _("Disabled"),
perm=HUMANIZED_PERM.get(perm),
perm=_(HUMANIZED_PERM.get(perm, perm)),
)
text = text.strip()
if current_perms.send_messages and current_perms.read_messages:
await ctx.send(box(text=text, lang="ini"))
else:
log.info(
"Missing write permission in %d, Owner ID: %d",
"Missing write permission in %s, Owner ID: %s",
ctx.guild.id,
ctx.guild.owner.id,
)
@@ -100,27 +228,65 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
)
if self.local_folder_current_path is None:
self.local_folder_current_path = Path(await self.config.localpath())
if not ctx.guild:
return
dj_enabled = self._dj_status_cache.setdefault(
ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled()
)
self._daily_playlist_cache.setdefault(
ctx.guild.id, await self.config.guild(ctx.guild).daily_playlists()
)
self._persist_queue_cache.setdefault(
ctx.guild.id, await self.config.guild(ctx.guild).persist_queue()
)
if ctx.command.callback.__name__ in DANGEROUS_COMMANDS and await ctx.bot.is_owner(
ctx.author
):
if ctx.command.callback.__name__ not in self.antispam[ctx.author.id]:
self.antispam[ctx.author.id][ctx.command.callback.__name__] = AntiSpam(
self.llset_captcha_intervals
)
if not self.antispam[ctx.author.id][ctx.command.callback.__name__].spammy:
token = random.choices((*ascii_letters, *digits), k=4)
confirm_token = " ".join(i for i in token)
token = confirm_token.replace(" ", "")
message = bold(
underline(_("You should not be running this command.")),
escape_formatting=False,
)
message += _(
"\n{template}\n"
"If you wish to continue, enter this case sensitive token without spaces as your next message."
"\n\n{confirm_token}"
).format(
template=_(DANGEROUS_COMMANDS[ctx.command.callback.__name__]),
confirm_token=box(confirm_token, lang="py"),
)
sent = await ctx.send(message)
try:
message = await ctx.bot.wait_for(
"message",
check=lambda m: m.channel.id == ctx.channel.id
and m.author.id == ctx.author.id,
timeout=120,
)
except asyncio.TimeoutError:
with contextlib.suppress(discord.HTTPException):
await sent.add_reaction("\N{CROSS MARK}")
raise commands.CheckFailure
else:
if message.content.strip() != token:
with contextlib.suppress(discord.HTTPException):
await sent.add_reaction("\N{CROSS MARK}")
raise commands.CheckFailure
with contextlib.suppress(discord.HTTPException):
await sent.add_reaction("\N{WHITE HEAVY CHECK MARK}")
self.antispam[ctx.author.id][ctx.command.callback.__name__].stamp()
if not guild:
return
guild_data = await self.config.guild(ctx.guild).all()
dj_enabled = self._dj_status_cache.setdefault(ctx.guild.id, guild_data["dj_enabled"])
self._daily_playlist_cache.setdefault(ctx.guild.id, guild_data["daily_playlists"])
self._persist_queue_cache.setdefault(ctx.guild.id, guild_data["persist_queue"])
if dj_enabled:
dj_role = self._dj_role_cache.setdefault(
ctx.guild.id, await self.config.guild(ctx.guild).dj_role()
)
dj_role = self._dj_role_cache.setdefault(ctx.guild.id, guild_data["dj_role"])
dj_role_obj = ctx.guild.get_role(dj_role)
if not dj_role_obj:
await self.config.guild(ctx.guild).dj_enabled.set(None)
async with self.config.guild(ctx.guild).all() as write_guild_data:
write_guild_data["dj_enabled"] = None
write_guild_data["dj_role"] = None
self._dj_status_cache[ctx.guild.id] = None
await self.config.guild(ctx.guild).dj_role.set(None)
self._dj_role_cache[ctx.guild.id] = None
await self.send_embed_msg(ctx, title=_("No DJ role found. Disabling DJ mode."))
@@ -167,18 +333,16 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
)
else:
await ctx.send_help()
elif isinstance(error, (IndexError, ClientConnectorError)) and any(
e in str(error).lower() for e in ["no nodes found.", "cannot connect to host"]
):
elif isinstance(error, (NodeNotFound, ClientConnectorError)):
handled = True
await self.send_embed_msg(
ctx,
title=_("Invalid Environment"),
description=_("Connection to Lavalink has been lost."),
description=_("Connection to Lavalink node has been lost."),
error=True,
)
log.trace("This is a handled error", exc_info=error)
elif isinstance(error, KeyError) and "such player for that guild" in str(error):
elif isinstance(error, PlayerNotFound):
handled = True
await self.send_embed_msg(
ctx,
@@ -193,7 +357,7 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
ctx,
title=_("Unable to Get Track"),
description=_(
"I'm unable to get a track from Lavalink at the moment, "
"I'm unable to get a track from the Lavalink node at the moment, "
"try again in a few minutes."
),
error=True,
@@ -230,7 +394,6 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
if not self.cog_cleaned_up:
self.bot.dispatch("red_audio_unload", self)
self.session.detach()
asyncio.create_task(self._close_database()).add_done_callback(task_callback_trace)
if self.player_automated_timer_task:
self.player_automated_timer_task.cancel()
@@ -245,11 +408,10 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
lavalink.unregister_event_listener(self.lavalink_event_handler)
lavalink.unregister_update_listener(self.lavalink_update_handler)
asyncio.create_task(lavalink.close(self.bot)).add_done_callback(task_callback_trace)
if self.player_manager is not None:
asyncio.create_task(self.player_manager.shutdown()).add_done_callback(
task_callback_trace
)
asyncio.create_task(lavalink.close(self.bot))
asyncio.create_task(self._close_database())
if self.managed_node_controller is not None:
asyncio.create_task(self.managed_node_controller.shutdown())
self.cog_cleaned_up = True
@@ -275,7 +437,7 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
):
try:
player = lavalink.get_player(channel.guild.id)
except (KeyError, AttributeError):
except (NodeNotFound, PlayerNotFound, AttributeError):
pass
else:
if player.channel.id == channel.id:
@@ -283,12 +445,12 @@ class DpyEvents(MixinMeta, metaclass=CompositeMetaClass):
@commands.Cog.listener()
async def on_shard_disconnect(self, shard_id):
self._diconnected_shard.add(shard_id)
self._disconnected_shard.add(shard_id)
@commands.Cog.listener()
async def on_shard_ready(self, shard_id):
self._diconnected_shard.discard(shard_id)
self._disconnected_shard.discard(shard_id)
@commands.Cog.listener()
async def on_shard_resumed(self, shard_id):
self._diconnected_shard.discard(shard_id)
self._disconnected_shard.discard(shard_id)

View File

@@ -14,7 +14,6 @@ from redbot.core.i18n import Translator, set_contextual_locales_from_guild
from ...errors import DatabaseError, TrackEnqueueError
from ..abc import MixinMeta
from ..cog_utils import CompositeMetaClass
from ...utils import task_callback_trace
log = getLogger("red.cogs.Audio.cog.Events.lavalink")
ws_audio_log = getLogger("red.Audio.WS.Audio")
@@ -51,7 +50,8 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
guild_id = self.rgetattr(guild, "id", None)
if not guild:
return
log.debug("Received a new lavalink event for %d: %s: %r", guild_id, event_type, extra)
# This event is rather spammy during playback - specially if there's multiple player
# Lets move it to Verbose that way it still there if needed alongside the other more verbose content.
guild_data = await self.config.guild(guild).all()
disconnect = guild_data["disconnect"]
if event_type == lavalink.LavalinkEvents.FORCED_DISCONNECT:
@@ -70,7 +70,7 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
ws_audio_log.info(
"WS EVENT - SIMPLE RESUME (Healthy Socket) | "
"Voice websocket closed event "
"Code: %d -- Remote: %s -- %s",
"Code: %s -- Remote: %s -- %s",
extra.get("code"),
by_remote,
reason,
@@ -78,7 +78,7 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
ws_audio_log.debug(
"WS EVENT - SIMPLE RESUME (Healthy Socket) | "
"Voice websocket closed event "
"Code: %d -- Remote: %s -- %s, %r",
"Code: %s -- Remote: %s -- %s, %r",
extra.get("code"),
by_remote,
reason,
@@ -100,7 +100,13 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
exc_info=exc,
)
return
if not player.manager.node.ready:
log.debug("Player node is not ready discarding event")
log.verbose(
"Received a new discard lavalink event for %s: %s: %r", guild_id, event_type, extra
)
return
log.verbose("Received a new lavalink event for %s: %s: %r", guild_id, event_type, extra)
await set_contextual_locales_from_guild(self.bot, guild)
current_requester = self.rgetattr(current_track, "requester", None)
current_stream = self.rgetattr(current_track, "is_stream", None)
@@ -160,27 +166,27 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
try:
await self.api_interface.autoplay(player, self.playlist_api)
except DatabaseError:
notify_channel = self.bot.get_channel(notify_channel_id)
notify_channel = guild.get_channel(notify_channel_id)
if notify_channel and self._has_notify_perms(notify_channel):
await self.send_embed_msg(
notify_channel, title=_("Couldn't get a valid track.")
)
return
except TrackEnqueueError:
notify_channel = self.bot.get_channel(notify_channel_id)
notify_channel = guild.get_channel(notify_channel_id)
if notify_channel and self._has_notify_perms(notify_channel):
await self.send_embed_msg(
notify_channel,
title=_("Unable to Get Track"),
description=_(
"I'm unable to get a track from Lavalink at the moment, try again in a few "
"I'm unable to get a track from the Lavalink node at the moment, try again in a few "
"minutes."
),
)
return
if event_type == lavalink.LavalinkEvents.TRACK_START and notify:
notify_channel_id = player.fetch("notify_channel")
notify_channel = self.bot.get_channel(notify_channel_id)
notify_channel = guild.get_channel(notify_channel_id)
if notify_channel and self._has_notify_perms(notify_channel):
if player.fetch("notify_message") is not None:
with contextlib.suppress(discord.HTTPException):
@@ -221,7 +227,7 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
if event_type == lavalink.LavalinkEvents.QUEUE_END:
if not autoplay:
notify_channel_id = player.fetch("notify_channel")
notify_channel = self.bot.get_channel(notify_channel_id)
notify_channel = guild.get_channel(notify_channel_id)
if notify_channel and notify and self._has_notify_perms(notify_channel):
await self.send_embed_msg(notify_channel, title=_("Queue ended."))
if disconnect:
@@ -277,7 +283,7 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
self._ll_guild_updates.discard(guild_id)
self.bot.dispatch("red_audio_audio_disconnect", guild)
if message_channel:
message_channel = self.bot.get_channel(message_channel)
message_channel = guild.get_channel(message_channel)
if early_exit:
log.warning(
"Audio detected multiple continuous errors during playback "
@@ -320,9 +326,10 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
if current_id:
asyncio.create_task(
self.api_interface.global_cache_api.report_invalid(current_id)
).add_done_callback(task_callback_trace)
)
await message_channel.send(embed=embed)
await player.skip()
if player.node.ready:
await player.skip()
async def _websocket_closed_handler(
self,
@@ -357,8 +364,8 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
code = 4014
if event_channel_id != channel_id:
ws_audio_log.debug(
"Received an op code for a channel that is no longer valid; %d "
"Reason: Error code %d & %s, %r",
"Received an op code for a channel that is no longer valid; %s "
"Reason: Error code %s & %s, %r",
event_channel_id,
code,
reason,
@@ -373,9 +380,9 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
if code in (1000,) and has_perm and player.current and player.is_playing:
player.store("resumes", player.fetch("resumes", 0) + 1)
await player.resume(player.current, start=player.position, replace=True)
ws_audio_log.info("Player resumed | Reason: Error code %d & %s", code, reason)
ws_audio_log.info("Player resumed | Reason: Error code %s & %s", code, reason)
ws_audio_log.debug(
"Player resumed | Reason: Error code %d & %s, %r", code, reason, player
"Player resumed | Reason: Error code %s & %s, %r", code, reason, player
)
self._ws_op_codes[guild_id]._init(self._ws_op_codes[guild_id]._maxsize)
return
@@ -388,9 +395,9 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
delay = player._con_delay.delay()
ws_audio_log.debug(
"YOU CAN IGNORE THIS UNLESS IT'S CONSISTENTLY REPEATING FOR THE SAME GUILD - "
"Voice websocket closed for guild %d -> "
"Voice websocket closed for guild %s -> "
"Socket Closed %s. "
"Code: %d -- Remote: %s -- %s, %r",
"Code: %s -- Remote: %s -- %s, %r",
guild_id,
voice_ws.socket._closing or voice_ws.socket.closed,
code,
@@ -399,7 +406,7 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
player,
)
ws_audio_log.info(
"Reconnecting to channel %d in guild: %d | %.2fs",
"Reconnecting to channel %s in guild: %s | %.2fs",
channel_id,
guild_id,
delay,
@@ -414,12 +421,12 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
await player.connect(deafen=deafen)
await player.resume(player.current, start=player.position, replace=True)
ws_audio_log.info(
"Voice websocket reconnected Reason: Error code %d & Currently playing",
"Voice websocket reconnected Reason: Error code %s & Currently playing",
code,
)
ws_audio_log.debug(
"Voice websocket reconnected "
"Reason: Error code %d & Currently playing, %r",
"Reason: Error code %s & Currently playing, %r",
code,
player,
)
@@ -430,12 +437,12 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
player.current, start=player.position, replace=True, pause=True
)
ws_audio_log.info(
"Voice websocket reconnected Reason: Error code %d & Currently Paused",
"Voice websocket reconnected Reason: Error code %s & Currently Paused",
code,
)
ws_audio_log.debug(
"Voice websocket reconnected "
"Reason: Error code %d & Currently Paused, %r",
"Reason: Error code %s & Currently Paused, %r",
code,
player,
)
@@ -444,12 +451,12 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
await player.connect(deafen=deafen)
ws_audio_log.info(
"Voice websocket reconnected "
"Reason: Error code %d & Not playing, but auto disconnect disabled",
"Reason: Error code %s & Not playing, but auto disconnect disabled",
code,
)
ws_audio_log.debug(
"Voice websocket reconnected "
"Reason: Error code %d & Not playing, but auto disconnect disabled, %r",
"Reason: Error code %s & Not playing, but auto disconnect disabled, %r",
code,
player,
)
@@ -458,12 +465,12 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
self.bot.dispatch("red_audio_audio_disconnect", guild)
ws_audio_log.info(
"Voice websocket disconnected "
"Reason: Error code %d & Missing permissions",
"Reason: Error code %s & Missing permissions",
code,
)
ws_audio_log.debug(
"Voice websocket disconnected "
"Reason: Error code %d & Missing permissions, %r",
"Reason: Error code %s & Missing permissions, %r",
code,
player,
)
@@ -477,10 +484,10 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
else:
self.bot.dispatch("red_audio_audio_disconnect", guild)
ws_audio_log.info(
"Voice websocket disconnected Reason: Error code %d & Unknown", code
"Voice websocket disconnected Reason: Error code %s & Unknown", code
)
ws_audio_log.debug(
"Voice websocket disconnected Reason: Error code %d & Unknown, %r",
"Voice websocket disconnected Reason: Error code %s & Unknown, %r",
code,
player,
)
@@ -495,9 +502,9 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
player.store("resumes", player.fetch("resumes", 0) + 1)
await player.connect(deafen=deafen)
await player.resume(player.current, start=player.position, replace=True)
ws_audio_log.info("Player resumed - Reason: Error code %d & %s", code, reason)
ws_audio_log.info("Player resumed - Reason: Error code %s & %s", code, reason)
ws_audio_log.debug(
"Player resumed - Reason: Error code %d & %s, %r", code, reason, player
"Player resumed - Reason: Error code %s & %s, %r", code, reason, player
)
elif code in (4015, 4009, 4006, 4000, 1006):
if player._con_delay:
@@ -506,19 +513,19 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
player._con_delay = ExponentialBackoff(base=1)
delay = player._con_delay.delay()
ws_audio_log.debug(
"Reconnecting to channel %d in guild: %d | %.2fs", channel_id, guild_id, delay
"Reconnecting to channel %s in guild: %s | %.2fs", channel_id, guild_id, delay
)
await asyncio.sleep(delay)
if has_perm and player.current and player.is_playing:
await player.connect(deafen=deafen)
await player.resume(player.current, start=player.position, replace=True)
ws_audio_log.info(
"Voice websocket reconnected Reason: Error code %d & Player is active",
"Voice websocket reconnected Reason: Error code %s & Player is active",
code,
)
ws_audio_log.debug(
"Voice websocket reconnected "
"Reason: Error code %d & Player is active, %r",
"Reason: Error code %s & Player is active, %r",
code,
player,
)
@@ -529,12 +536,12 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
player.current, start=player.position, replace=True, pause=True
)
ws_audio_log.info(
"Voice websocket reconnected Reason: Error code %d & Player is paused",
"Voice websocket reconnected Reason: Error code %s & Player is paused",
code,
)
ws_audio_log.debug(
"Voice websocket reconnected "
"Reason: Error code %d & Player is paused, %r",
"Reason: Error code %s & Player is paused, %r",
code,
player,
)
@@ -543,16 +550,16 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
await player.connect(deafen=deafen)
ws_audio_log.info(
"Voice websocket reconnected "
"to channel %d in guild: %d | "
"Reason: Error code %d & Not playing",
"to channel %s in guild: %s | "
"Reason: Error code %s & Not playing",
channel_id,
guild_id,
code,
)
ws_audio_log.debug(
"Voice websocket reconnected "
"to channel %d in guild: %d | "
"Reason: Error code %d & Not playing, %r",
"to channel %s in guild: %s | "
"Reason: Error code %s & Not playing, %r",
channel_id,
guild_id,
code,
@@ -563,12 +570,12 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
self.bot.dispatch("red_audio_audio_disconnect", guild)
ws_audio_log.info(
"Voice websocket disconnected "
"Reason: Error code %d & Missing permissions",
"Reason: Error code %s & Missing permissions",
code,
)
ws_audio_log.debug(
"Voice websocket disconnected "
"Reason: Error code %d & Missing permissions, %r",
"Reason: Error code %s & Missing permissions, %r",
code,
player,
)
@@ -586,7 +593,7 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
ws_audio_log.info(
"WS EVENT - SIMPLE RESUME (Healthy Socket) | "
"Voice websocket closed event "
"Code: %d -- Remote: %s -- %s",
"Code: %s -- Remote: %s -- %s",
code,
by_remote,
reason,
@@ -594,7 +601,7 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
ws_audio_log.debug(
"WS EVENT - SIMPLE RESUME (Healthy Socket) | "
"Voice websocket closed event "
"Code: %d -- Remote: %s -- %s, %r",
"Code: %s -- Remote: %s -- %s, %r",
code,
by_remote,
reason,
@@ -604,7 +611,7 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
ws_audio_log.info(
"WS EVENT - IGNORED (Healthy Socket) | "
"Voice websocket closed event "
"Code: %d -- Remote: %s -- %s",
"Code: %s -- Remote: %s -- %s",
code,
by_remote,
reason,
@@ -612,7 +619,7 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
ws_audio_log.debug(
"WS EVENT - IGNORED (Healthy Socket) | "
"Voice websocket closed event "
"Code: %d -- Remote: %s -- %s, %r",
"Code: %s -- Remote: %s -- %s, %r",
code,
by_remote,
reason,