mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Audio] Ensure TrackEnqueueError is always handled (#3879)
Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>
This commit is contained in:
parent
0635921d6b
commit
5fba9bc4ed
@ -576,6 +576,16 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
notify_channel = self.bot.get_channel(notify_channel)
|
notify_channel = self.bot.get_channel(notify_channel)
|
||||||
await self.send_embed_msg(notify_channel, title=_("Couldn't get a valid track."))
|
await self.send_embed_msg(notify_channel, title=_("Couldn't get a valid track."))
|
||||||
return
|
return
|
||||||
|
except TrackEnqueueError:
|
||||||
|
self.update_player_lock(ctx, False)
|
||||||
|
return await self.send_embed_msg(
|
||||||
|
ctx,
|
||||||
|
title=_("Unable to Get Track"),
|
||||||
|
description=_(
|
||||||
|
"I'm unable get a track from Lavalink at the moment, try again in a few "
|
||||||
|
"minutes."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
if not guild_data["auto_play"]:
|
if not guild_data["auto_play"]:
|
||||||
await ctx.invoke(self.command_audioset_autoplay_toggle)
|
await ctx.invoke(self.command_audioset_autoplay_toggle)
|
||||||
|
|||||||
@ -22,7 +22,7 @@ from ...apis.playlist_interface import create_playlist, delete_playlist, get_all
|
|||||||
from ...audio_dataclasses import LocalPath, Query
|
from ...audio_dataclasses import LocalPath, Query
|
||||||
from ...audio_logging import IS_DEBUG, debug_exc_log
|
from ...audio_logging import IS_DEBUG, debug_exc_log
|
||||||
from ...converters import ComplexScopeParser, ScopeParser
|
from ...converters import ComplexScopeParser, ScopeParser
|
||||||
from ...errors import MissingGuild, TooManyMatches
|
from ...errors import MissingGuild, TooManyMatches, TrackEnqueueError
|
||||||
from ...utils import PlaylistScope
|
from ...utils import PlaylistScope
|
||||||
from ..abc import MixinMeta
|
from ..abc import MixinMeta
|
||||||
from ..cog_utils import CompositeMetaClass, LazyGreedyConverter, PlaylistConverter, _
|
from ..cog_utils import CompositeMetaClass, LazyGreedyConverter, PlaylistConverter, _
|
||||||
@ -1817,43 +1817,54 @@ class PlaylistCommands(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
uploaded_playlist_name = uploaded_playlist.get(
|
uploaded_playlist_name = uploaded_playlist.get(
|
||||||
"name", (file_url.split("/")[6]).split(".")[0]
|
"name", (file_url.split("/")[6]).split(".")[0]
|
||||||
)
|
)
|
||||||
if self.api_interface is not None and (
|
try:
|
||||||
not uploaded_playlist_url
|
if self.api_interface is not None and (
|
||||||
or not self.match_yt_playlist(uploaded_playlist_url)
|
not uploaded_playlist_url
|
||||||
or not (
|
or not self.match_yt_playlist(uploaded_playlist_url)
|
||||||
await self.api_interface.fetch_track(
|
or not (
|
||||||
|
await self.api_interface.fetch_track(
|
||||||
|
ctx,
|
||||||
|
player,
|
||||||
|
Query.process_input(uploaded_playlist_url, self.local_folder_current_path),
|
||||||
|
)
|
||||||
|
)[0].tracks
|
||||||
|
):
|
||||||
|
if version == "v3":
|
||||||
|
return await self._load_v3_playlist(
|
||||||
|
ctx,
|
||||||
|
scope,
|
||||||
|
uploaded_playlist_name,
|
||||||
|
uploaded_playlist_url,
|
||||||
|
track_list,
|
||||||
|
author,
|
||||||
|
guild,
|
||||||
|
)
|
||||||
|
return await self._load_v2_playlist(
|
||||||
ctx,
|
ctx,
|
||||||
player,
|
|
||||||
Query.process_input(uploaded_playlist_url, self.local_folder_current_path),
|
|
||||||
)
|
|
||||||
)[0].tracks
|
|
||||||
):
|
|
||||||
if version == "v3":
|
|
||||||
return await self._load_v3_playlist(
|
|
||||||
ctx,
|
|
||||||
scope,
|
|
||||||
uploaded_playlist_name,
|
|
||||||
uploaded_playlist_url,
|
|
||||||
track_list,
|
track_list,
|
||||||
|
player,
|
||||||
|
uploaded_playlist_url,
|
||||||
|
uploaded_playlist_name,
|
||||||
|
scope,
|
||||||
author,
|
author,
|
||||||
guild,
|
guild,
|
||||||
)
|
)
|
||||||
return await self._load_v2_playlist(
|
return await ctx.invoke(
|
||||||
ctx,
|
self.command_playlist_save,
|
||||||
track_list,
|
playlist_name=uploaded_playlist_name,
|
||||||
player,
|
playlist_url=uploaded_playlist_url,
|
||||||
uploaded_playlist_url,
|
scope_data=(scope, author, guild, specified_user),
|
||||||
uploaded_playlist_name,
|
)
|
||||||
scope,
|
except TrackEnqueueError:
|
||||||
author,
|
self.update_player_lock(ctx, False)
|
||||||
guild,
|
return await self.send_embed_msg(
|
||||||
|
ctx,
|
||||||
|
title=_("Unable to Get Track"),
|
||||||
|
description=_(
|
||||||
|
"I'm unable get a track from Lavalink at the moment, try again in a few "
|
||||||
|
"minutes."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
return await ctx.invoke(
|
|
||||||
self.command_playlist_save,
|
|
||||||
playlist_name=uploaded_playlist_name,
|
|
||||||
playlist_url=uploaded_playlist_url,
|
|
||||||
scope_data=(scope, author, guild, specified_user),
|
|
||||||
)
|
|
||||||
|
|
||||||
@commands.cooldown(1, 60, commands.BucketType.member)
|
@commands.cooldown(1, 60, commands.BucketType.member)
|
||||||
@command_playlist.command(
|
@command_playlist.command(
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import logging
|
|||||||
import discord
|
import discord
|
||||||
import lavalink
|
import lavalink
|
||||||
|
|
||||||
from ...errors import DatabaseError
|
from ...errors import DatabaseError, TrackEnqueueError
|
||||||
from ..abc import MixinMeta
|
from ..abc import MixinMeta
|
||||||
from ..cog_utils import CompositeMetaClass, _
|
from ..cog_utils import CompositeMetaClass, _
|
||||||
|
|
||||||
@ -62,12 +62,25 @@ class LavalinkEvents(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
await self.api_interface.autoplay(player, self.playlist_api)
|
await self.api_interface.autoplay(player, self.playlist_api)
|
||||||
except DatabaseError:
|
except DatabaseError:
|
||||||
notify_channel = player.fetch("channel")
|
notify_channel = player.fetch("channel")
|
||||||
|
notify_channel = self.bot.get_channel(notify_channel)
|
||||||
if notify_channel:
|
if notify_channel:
|
||||||
notify_channel = self.bot.get_channel(notify_channel)
|
|
||||||
await self.send_embed_msg(
|
await self.send_embed_msg(
|
||||||
notify_channel, title=_("Couldn't get a valid track.")
|
notify_channel, title=_("Couldn't get a valid track.")
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
except TrackEnqueueError:
|
||||||
|
notify_channel = player.fetch("channel")
|
||||||
|
notify_channel = self.bot.get_channel(notify_channel)
|
||||||
|
if notify_channel:
|
||||||
|
await self.send_embed_msg(
|
||||||
|
notify_channel,
|
||||||
|
title=_("Unable to Get Track"),
|
||||||
|
description=_(
|
||||||
|
"I'm unable get a track from Lavalink at the moment, try again in a few "
|
||||||
|
"minutes."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return
|
||||||
if event_type == lavalink.LavalinkEvents.TRACK_START and notify:
|
if event_type == lavalink.LavalinkEvents.TRACK_START and notify:
|
||||||
notify_channel = player.fetch("channel")
|
notify_channel = player.fetch("channel")
|
||||||
if notify_channel:
|
if notify_channel:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user