From 05af4629ce9e0e63795de4c8b6d25bda4248d77c Mon Sep 17 00:00:00 2001 From: NiceAesth Date: Fri, 23 Feb 2024 12:32:44 +0200 Subject: [PATCH] fix: handle renamed exception key for v4 This is a hotfix change. I am working on a refactor to use Pydantic smart unions for all of our types in the future. --- pomice/pool.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pomice/pool.py b/pomice/pool.py index 64564af..b7df203 100644 --- a/pomice/pool.py +++ b/pomice/pool.py @@ -720,9 +720,9 @@ class Node: load_type = data.get("loadType") - # Lavalink v4 changed the name of the key from "tracks" to "data" - # so lets account for that + # Based off of https://github.com/lavalink-devs/Lavalink/blob/ae3deb1ad61ea31f040ddaa4a283a38c298f326f/protocol/src/commonMain/kotlin/dev/arbjerg/lavalink/protocol/v4/loadResult.kt data_type = "data" if self._version.major >= 4 else "tracks" + exception_type = "data" if self._version.major >= 4 else "error" if not load_type: raise TrackLoadError( @@ -730,7 +730,7 @@ class Node: ) elif load_type in ("LOAD_FAILED", "error"): - exception = data["exception"] + exception = data[exception_type] raise TrackLoadError( f"{exception['message']} [{exception['severity']}]", )