WIP: Make Lavalink optional

At the moment, there's a broken instance of the Lavalink system running.
When executing `.play`, our home-hosted `musicbot` will start playing,
but the production TravBot instance will error.

I haven't implemented this as a choice in the setup yet, that's for
another time.
Right now, all I need is for it to be optional.
This commit is contained in:
Alyxia Sother 2021-05-21 11:54:20 +00:00
parent 1e673a3969
commit ac81b6a103
No known key found for this signature in database
GPG Key ID: 355968D14144B739
2 changed files with 43 additions and 39 deletions

View File

@ -2,6 +2,7 @@ import attachClientToLavalink from "discord.js-lavalink-lib";
import {Config} from "../structures";
import {client} from "../index";
if (Config.lavalink) {
// Although the example showed to do "client.music = LavaLink(...)" and "(client as any).music = Lavalink(...)" was done to match that, nowhere in the library is client.music ever actually used nor does the function return anything. In other words, client.music is undefined and is never used.
attachClientToLavalink(client, {
lavalink: {
@ -47,3 +48,4 @@ for (const listener of process.listeners("uncaughtException")) {
process.off("uncaughtException", listener);
}
}
}

View File

@ -13,6 +13,7 @@ class ConfigStructure extends GenericStructure {
public owner: string;
public admins: string[];
public support: string[];
public lavalink: boolean | null;
public systemLogsChannel: string | null;
public webhooks: {[id: string]: string}; // id-token pairs
@ -23,6 +24,7 @@ class ConfigStructure extends GenericStructure {
this.owner = select(data.owner, "", String);
this.admins = select(data.admins, [], String, true);
this.support = select(data.support, [], String, true);
this.lavalink = select(data.lavalink, null, Boolean);
this.systemLogsChannel = select(data.systemLogsChannel, null, String);
this.webhooks = {};