From 3714656f0e97fd63d65114e4f34abc5c2962ce91 Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sun, 5 Feb 2023 23:16:48 -0500 Subject: [PATCH] add version comparison --- pomice/exceptions.py | 4 ++++ pomice/pool.py | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pomice/exceptions.py b/pomice/exceptions.py index 8d2cb24..9eeac42 100644 --- a/pomice/exceptions.py +++ b/pomice/exceptions.py @@ -92,3 +92,7 @@ class QueueFull(QueueException): class QueueEmpty(QueueException): """Exception raised when attempting to retrieve from an empty Queue.""" pass + +class LavalinkVersionIncompatible(PomiceException): + """Lavalink version is incompatible. Must be using Lavalink > 3.7.0 to avoid this error.""" + pass diff --git a/pomice/pool.py b/pomice/pool.py index a3dbd6c..f4b9199 100644 --- a/pomice/pool.py +++ b/pomice/pool.py @@ -21,6 +21,7 @@ from .enums import SearchType, NodeAlgorithm from .exceptions import ( AppleMusicNotEnabled, InvalidSpotifyClientAuthorization, + LavalinkVersionIncompatible, NodeConnectionFailure, NodeCreationError, NodeNotAvailable, @@ -283,9 +284,12 @@ class Node: self._available = True async with self._session.get(f'{self._rest_uri}/version', headers={"Authorization": self._password}) as resp: version: str = await resp.text() - # To make version comparasion easier, lets remove the periods - # from the version numbers and compare them like whole numbers - print(version) + version = version.replace(".", "") + if int(version) < 370: + raise LavalinkVersionIncompatible( + "The Lavalink version you're using is incompatible." + "Lavalink version 3.7.0 or above is required to use this library." + ) return self