From a81541705cebbaced72570a295a46bcb94af84de Mon Sep 17 00:00:00 2001 From: Choco <94597336+ChocoMeow@users.noreply.github.com> Date: Sat, 6 Jul 2024 15:27:53 +0800 Subject: [PATCH] Fixed some bugs --- cogs/basic.py | 2 +- docker-compose.yml | 6 +++--- settings Example.json | 4 ++-- voicelink/spotify/objects.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cogs/basic.py b/cogs/basic.py index 4f147f1..ab7d08c 100644 --- a/cogs/basic.py +++ b/cogs/basic.py @@ -106,7 +106,7 @@ class Basic(commands.Cog): node = voicelink.NodePool.get_node() if node and node.spotify_client: tracks: list[voicelink.Track] = await node.spotifySearch(current, requester=interaction.user) - return history_tracks[:5] + [app_commands.Choice(name=f"🎵 {track.author} - {track.title}", value=f"{track.author} - {track.title}") for track in tracks] + return history_tracks[:5] + [app_commands.Choice(name=truncate_string(f"🎵 {track.author} - {track.title}", 100), value=truncate_string(f"{track.author} - {track.title}", 100)) for track in tracks] @commands.hybrid_command(name="connect", aliases=get_aliases("connect")) @app_commands.describe(channel="Provide a channel to connect.") diff --git a/docker-compose.yml b/docker-compose.yml index e32409a..07edf48 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: environment: - _JAVA_OPTIONS=-Xmx1G - SERVER_PORT=2333 + - LAVALINK_SERVER_PASSWORD=youshallnotpass volumes: ## Use "./" if you want to create a mount from your current directory (where docker-compose.yml is located) ## Having access to files INSIDE the container is complicated. Mount function is used to have access to certain container files or folders. @@ -39,15 +40,14 @@ services: # command: ["mongod", "--oplogSize=1024", "--wiredTigerCacheSizeGB=1", "--auth", "--noscripting"] vocard: - image: ghcr.io/chocomeow/vocard:v2.6.8 container_name: vocard volumes: ## Use "./" if you want to create a mount from your current directory (where docker-compose.yml is located) ## Having access to files INSIDE the container is complicated. Mount function is used to have access to certain container files or folders. ## Read more: https://docs.docker.com/storage/bind-mounts/ - ./settings.json:/app/settings.json - env_file: - - .env + build: + dockerfile: ./Dockerfile depends_on: lavalink: condition: service_started diff --git a/settings Example.json b/settings Example.json index 879fbc8..21a6d12 100644 --- a/settings Example.json +++ b/settings Example.json @@ -8,9 +8,9 @@ "mongodb_name": "YOUR_MONGODB_DB_NAME", "nodes": { "DEFAULT": { - "host": "127.0.0.1", + "host": "lavalink", "port": 2333, - "password": "password", + "password": "youshallnotpass", "secure": false, "identifier": "DEFAULT" } diff --git a/voicelink/spotify/objects.py b/voicelink/spotify/objects.py index 7f1f340..9a26062 100644 --- a/voicelink/spotify/objects.py +++ b/voicelink/spotify/objects.py @@ -13,8 +13,8 @@ class Track: def __init__(self, data: dict, image = None) -> None: self.name: str = data.get('name', 'Unknown') - self.artists: str = ", ".join(artist["name"] for artist in data.get('artists')) - self.artist_id: list[str] = [artist['id'] for artist in data.get('artists')] + self.artists: str = ", ".join(filter(None, (artist["name"] for artist in data.get('artists')))) + self.artist_id: list[str] = [artist["id"] for artist in data.get('artists')] self.length: int = data.get('duration_ms') self.id: str = data.get('id') self.image: str = images[0]["url"] if (images := data.get("album", {}).get("images")) else image @@ -55,7 +55,7 @@ class Album: def __init__(self, data: dict) -> None: self.name: str = data.get('name', 'Unknown') - self.artists: str = ", ".join(artist["name"] for artist in data.get('artists')) + self.artists: str = ", ".join(filter(None, (artist["name"] for artist in data.get('artists')))) self.image: str = data["images"][0]["url"] self.tracks: list[Track] = [Track(track, image=self.image) for track in data["tracks"]["items"]] self.total_tracks: int = data["total_tracks"]