From 382c42262954767acc3f5ee3e008e03acbfc4f26 Mon Sep 17 00:00:00 2001 From: Parker Date: Thu, 28 Nov 2024 00:04:48 -0600 Subject: Overhaul \`play\` command - Split custom sources into helper functions - Add proper logging and handling - Fix LoadError embed messsage --- code/utils/command_tree.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'code/utils/command_tree.py') diff --git a/code/utils/command_tree.py b/code/utils/command_tree.py index 3d9214d..7ccb8b1 100644 --- a/code/utils/command_tree.py +++ b/code/utils/command_tree.py @@ -84,31 +84,23 @@ class Tree(app_commands.CommandTree): except discord.errors.InteractionResponded: await interaction.followup.send(embed=embed, ephemeral=True) - # If a Spotify song is linked but cannot be found on a provider (e.g. YouTube) - elif isinstance(error, LoadError): + elif (error, LoadError): embed = discord.Embed( - title="Nothing Found", + title="Load Error", description=( - "Spotify does not allow direct play, meaning songs have to" - " be found on a supported provider. In this case, the song" - " couldn't be found. Please try again with a different" - " song, or try searching for just the name and artist" - " manually rather than sending a link." + "Apple Music and Spotify do not allow direct playing from" + " their websites, and I was unable to load a track on a" + " valid source. Please try again." ), color=BOT_COLOR, ) - embed.set_footer( - text=datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%d %H:%M:%S" - ) - + " UTC" - ) + # Only send the error if the interaction is still valid try: await interaction.response.send_message( embed=embed, ephemeral=True ) except discord.errors.InteractionResponded: - await interaction.followup.send(embed=embed, ephemeral=True) + pass else: raise error -- cgit v1.2.3-70-g09d2