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

@@ -5,6 +5,7 @@ from typing import List
import discord
import lavalink
from lavalink import NodeNotFound, PlayerNotFound
from red_commons.logging import getLogger
from redbot.core import commands
@@ -27,7 +28,7 @@ class EqualizerUtilities(MixinMeta, metaclass=CompositeMetaClass):
try:
await lavalink.get_player(guild_id).node.send({**const})
except (KeyError, IndexError):
except (NodeNotFound, PlayerNotFound):
pass
async def _apply_gains(self, guild_id: int, gains: List[float]) -> None:
@@ -39,7 +40,7 @@ class EqualizerUtilities(MixinMeta, metaclass=CompositeMetaClass):
try:
await lavalink.get_player(guild_id).node.send({**const})
except (KeyError, IndexError):
except (NodeNotFound, PlayerNotFound):
pass
async def _eq_check(self, ctx: commands.Context, player: lavalink.Player) -> None:

View File

@@ -10,6 +10,8 @@ import lavalink
from red_commons.logging import getLogger
from discord.embeds import EmptyEmbed
from lavalink import NodeNotFound
from redbot.core import commands
from redbot.core.i18n import Translator
from redbot.core.utils import AsyncIter
@@ -91,7 +93,7 @@ class FormattingUtilities(MixinMeta, metaclass=CompositeMetaClass):
):
if not self._player_check(ctx):
if self.lavalink_connection_aborted:
msg = _("Connection to Lavalink has failed")
msg = _("Connection to Lavalink node has failed")
description = EmptyEmbed
if await self.bot.is_owner(ctx.author):
description = _("Please check your console or logs for details.")
@@ -103,9 +105,9 @@ class FormattingUtilities(MixinMeta, metaclass=CompositeMetaClass):
)
except AttributeError:
return await self.send_embed_msg(ctx, title=_("Connect to a voice channel first."))
except IndexError:
except NodeNotFound:
return await self.send_embed_msg(
ctx, title=_("Connection to Lavalink has not yet been established.")
ctx, title=_("Connection to Lavalink node has not yet been established.")
)
player = lavalink.get_player(ctx.guild.id)
player.store("notify_channel", ctx.channel.id)
@@ -161,7 +163,7 @@ class FormattingUtilities(MixinMeta, metaclass=CompositeMetaClass):
f"{search_choice.title} {search_choice.author} {search_choice.uri} {str(query)}",
query_obj=query,
):
log.debug("Query is not allowed in %r (%d)", ctx.guild.name, ctx.guild.id)
log.debug("Query is not allowed in %r (%s)", ctx.guild.name, ctx.guild.id)
self.update_player_lock(ctx, False)
return await self.send_embed_msg(
ctx, title=_("This track is not allowed in this server.")

View File

@@ -20,7 +20,7 @@ from redbot.core.utils import AsyncIter
from redbot.core.utils.chat_formatting import humanize_number
from ...apis.playlist_interface import get_all_playlist_for_migration23
from ...utils import PlaylistScope, task_callback_trace
from ...utils import PlaylistScope
from ..abc import MixinMeta
from ..cog_utils import CompositeMetaClass, DataReader
@@ -35,9 +35,7 @@ class MiscellaneousUtilities(MixinMeta, metaclass=CompositeMetaClass):
self, message: discord.Message, emoji: MutableMapping = None
) -> asyncio.Task:
"""Non blocking version of clear_react."""
task = asyncio.create_task(self.clear_react(message, emoji))
task.add_done_callback(task_callback_trace)
return task
return asyncio.create_task(self.clear_react(message, emoji))
async def maybe_charge_requester(self, ctx: commands.Context, jukebox_price: int) -> bool:
jukebox = await self.config.guild(ctx.guild).jukebox()
@@ -125,8 +123,8 @@ class MiscellaneousUtilities(MixinMeta, metaclass=CompositeMetaClass):
async def update_external_status(self) -> bool:
external = await self.config.use_external_lavalink()
if not external:
if self.player_manager is not None:
await self.player_manager.shutdown()
if self.managed_node_controller is not None:
await self.managed_node_controller.shutdown()
await self.config.use_external_lavalink.set(True)
return True
else:

View File

@@ -9,6 +9,8 @@ import lavalink
from red_commons.logging import getLogger
from discord.embeds import EmptyEmbed
from lavalink import NodeNotFound, PlayerNotFound
from redbot.core import commands
from redbot.core.i18n import Translator
from redbot.core.utils import AsyncIter
@@ -59,7 +61,7 @@ class PlayerUtilities(MixinMeta, metaclass=CompositeMetaClass):
current, self.local_folder_current_path
)
playing_servers = len(lavalink.active_players())
except IndexError:
except (IndexError, NodeNotFound, PlayerNotFound):
get_single_title = None
playing_servers = 0
return get_single_title, playing_servers
@@ -208,7 +210,7 @@ class PlayerUtilities(MixinMeta, metaclass=CompositeMetaClass):
try:
lavalink.get_player(ctx.guild.id)
return True
except (IndexError, KeyError):
except (NodeNotFound, PlayerNotFound):
return False
async def self_deafen(self, player: lavalink.Player) -> None:
@@ -299,7 +301,7 @@ class PlayerUtilities(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."
),
)
@@ -390,7 +392,7 @@ class PlayerUtilities(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 Lavalink node at the moment, "
"try again in a few minutes."
),
)
@@ -450,7 +452,7 @@ class PlayerUtilities(MixinMeta, metaclass=CompositeMetaClass):
f"{track.title} {track.author} {track.uri} " f"{str(query)}",
query_obj=query,
):
log.debug("Query is not allowed in %r (%d)", ctx.guild.name, ctx.guild.id)
log.debug("Query is not allowed in %r (%s)", ctx.guild.name, ctx.guild.id)
continue
elif guild_data["maxlength"] > 0:
if self.is_track_length_allowed(track, guild_data["maxlength"]):
@@ -539,7 +541,7 @@ class PlayerUtilities(MixinMeta, metaclass=CompositeMetaClass):
),
query_obj=query,
):
log.debug("Query is not allowed in %r (%d)", ctx.guild.name, ctx.guild.id)
log.debug("Query is not allowed in %r (%s)", ctx.guild.name, ctx.guild.id)
self.update_player_lock(ctx, False)
return await self.send_embed_msg(
ctx, title=_("This track is not allowed in this server.")
@@ -687,7 +689,7 @@ class PlayerUtilities(MixinMeta, metaclass=CompositeMetaClass):
async def maybe_move_player(self, ctx: commands.Context) -> bool:
try:
player = lavalink.get_player(ctx.guild.id)
except KeyError:
except PlayerNotFound:
return False
try:
in_channel = sum(

View File

@@ -13,6 +13,7 @@ import aiohttp
import discord
import lavalink
from discord.embeds import EmptyEmbed
from lavalink import NodeNotFound
from red_commons.logging import getLogger
from redbot.core import commands
@@ -424,7 +425,7 @@ class PlaylistUtilities(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."
),
)
@@ -523,7 +524,7 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
async def _playlist_check(self, ctx: commands.Context) -> bool:
if not self._player_check(ctx):
if self.lavalink_connection_aborted:
msg = _("Connection to Lavalink has failed")
msg = _("Connection to Lavalink node has failed")
desc = EmptyEmbed
if await self.bot.is_owner(ctx.author):
desc = _("Please check your console or logs for details.")
@@ -547,11 +548,11 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
ctx.author.voice.channel,
deafen=await self.config.guild_from_id(ctx.guild.id).auto_deafen(),
)
except IndexError:
except NodeNotFound:
await self.send_embed_msg(
ctx,
title=_("Unable To Get Playlists"),
description=_("Connection to Lavalink has not yet been established."),
description=_("Connection to Lavalink node has not yet been established."),
)
return False
except AttributeError:
@@ -625,7 +626,7 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
ctx,
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 Lavalink node at the moment, try again in a few "
"minutes."
),
)
@@ -654,7 +655,7 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
ctx,
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 Lavalink node at the moment, try again in a few "
"minutes."
),
)