add support for multiple nodes

This commit is contained in:
2023-04-11 22:33:48 +02:00
parent f81c89119c
commit 50c4ce8bb7
2 changed files with 13 additions and 14 deletions
+5 -8
View File
@@ -129,15 +129,12 @@ class TuneBot(commands.Bot):
self.lavalink = self.create_lavalink(self.user.id) self.lavalink = self.create_lavalink(self.user.id)
def create_lavalink(self, user_id: int) -> "lavalink.Client": def create_lavalink(self, user_id: int) -> "lavalink.Client":
cfg = self.config["lavalink"] nodes = self.config["nodes"]
client: lavalink.Client = lavalink.Client(user_id, player=CustomPlayer) client: lavalink.Client = lavalink.Client(user_id, player=CustomPlayer)
client.add_node( # get the lavalink nodes from the config
cfg["host"], for node in nodes:
cfg["port"], client.add_node(nodes[node]["host"], nodes[node]["port"], nodes[node]["password"], nodes[node]["region"], nodes[node]["name"])
cfg["password"],
cfg["region"],
cfg["name"],
)
return client return client
async def get_context(self, message: Message, *, cls=CustomContext): async def get_context(self, message: Message, *, cls=CustomContext):
+8 -6
View File
@@ -8,12 +8,14 @@
"prefix": "ck!", "prefix": "ck!",
"redis_url": "", "redis_url": "",
"redis_prefix": "", "redis_prefix": "",
"lavalink": { "nodes": {
"host": "", "example": {
"port": 2333, "host": "",
"password": "", "port": 2333,
"region": "", "password": "",
"name": "" "region": "",
"name": ""
}
}, },
"colors": { "colors": {
"embed": "7289da" "embed": "7289da"