Improve running the bot in a global context
This commit is contained in:
parent
3ffb7f4949
commit
57cd37d1eb
9 changed files with 24 additions and 15 deletions
|
@ -5,7 +5,7 @@ let queryValue = 0;
|
|||
|
||||
// load command into memory
|
||||
export async function load(command, soundStatus) {
|
||||
const { default: props } = await import(`../${command}?v=${queryValue}`);
|
||||
const { default: props } = await import(`${command}?v=${queryValue}`);
|
||||
queryValue++;
|
||||
if (props.requires.includes("sound") && soundStatus) return log("warn", `Failed to connect to some Lavalink nodes, skipped loading command ${command}...`);
|
||||
const commandArray = command.split("/");
|
||||
|
@ -15,7 +15,7 @@ export async function load(command, soundStatus) {
|
|||
commands.set(commandName, props);
|
||||
|
||||
info.set(commandName, {
|
||||
category: commandArray[2],
|
||||
category: commandArray[commandArray.length - 2],
|
||||
description: props.description,
|
||||
aliases: props.aliases,
|
||||
params: props.arguments,
|
||||
|
|
|
@ -8,7 +8,7 @@ export const jobs = {};
|
|||
|
||||
export const connections = new Map();
|
||||
|
||||
export const servers = JSON.parse(fs.readFileSync("./servers.json", { encoding: "utf8" })).image;
|
||||
export const servers = JSON.parse(fs.readFileSync(new URL("../servers.json", import.meta.url), { encoding: "utf8" })).image;
|
||||
|
||||
export async function getType(image, extraReturnTypes) {
|
||||
if (!image.startsWith("http")) {
|
||||
|
|
|
@ -24,7 +24,7 @@ export async function clean(text) {
|
|||
.replaceAll("@", `@${String.fromCharCode(8203)}`);
|
||||
|
||||
const { parsed } = config();
|
||||
const imageServers = JSON.parse(fs.readFileSync("./servers.json", { encoding: "utf8" })).image;
|
||||
const imageServers = JSON.parse(fs.readFileSync(new URL("../servers.json", import.meta.url), { encoding: "utf8" })).image;
|
||||
|
||||
if (imageServers && imageServers.length !== 0) {
|
||||
for (const { server, auth } of imageServers) {
|
||||
|
|
|
@ -21,7 +21,7 @@ class ImageWorker extends BaseServiceWorker {
|
|||
if (process.env.API === "true") {
|
||||
this.jobs = {};
|
||||
this.connections = new Map();
|
||||
this.servers = JSON.parse(fs.readFileSync("./servers.json", { encoding: "utf8" })).image;
|
||||
this.servers = JSON.parse(fs.readFileSync(new URL("../../servers.json", import.meta.url), { encoding: "utf8" })).image;
|
||||
this.nextID = 0;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class ImageWorker extends BaseServiceWorker {
|
|||
}
|
||||
|
||||
async repopulate() {
|
||||
const data = await fs.promises.readFile("./servers.json", { encoding: "utf8" });
|
||||
const data = await fs.promises.readFile(new URL("../../servers.json", import.meta.url), { encoding: "utf8" });
|
||||
this.servers = JSON.parse(data).image;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ export let status = false;
|
|||
export let connected = false;
|
||||
|
||||
export async function checkStatus() {
|
||||
const json = await fs.promises.readFile("./servers.json", { encoding: "utf8" });
|
||||
const json = await fs.promises.readFile(new URL("../servers.json", import.meta.url), { encoding: "utf8" });
|
||||
nodes = JSON.parse(json).lava;
|
||||
const newNodes = [];
|
||||
for (const node of nodes) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue