Skip to content

Commit

Permalink
Dev/fix ririko avc (#327)
Browse files Browse the repository at this point in the history
* [FIX] Fixes bug on RirikoAVC

* 0.14.2
  • Loading branch information
earnestangel authored Feb 18, 2024
1 parent 83fa68b commit c3d7f45
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 101 deletions.
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ const cli = require(`./${buildDir}/ririkoCli`);

const configFileExists = fs.existsSync("./config.js");

process
.on("unhandledRejection", (reason, p) => {
console.error(reason, "Unhandled Rejection at Promise", p);
})
.on("uncaughtException", (err) => {
console.error(err, "Uncaught Exception thrown");
console.oLog(err);
});

function createLogDirectory() {
if (!fs.existsSync(logDirectory)) {
fs.mkdirSync(logDirectory);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ririko",
"version": "0.14.1",
"version": "0.14.2",
"description": "Ririko - A powerful AI-powered general Discord bot that you can call your companion",
"author": "Earnest Angel",
"email": "[email protected]",
Expand Down
67 changes: 36 additions & 31 deletions src/app/RirikoAVC.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,38 +94,43 @@ class RirikoAVC {
}

checkAVC(client) {
//remove deleted channels from data
let updatePersistance = false;
this.#_content.primary.forEach((id) => {
if (client.channels.cache.get(id) == null) {
this.#_content.primary.splice(this.#_content.primary.indexOf(id), 1);
updatePersistance = true;
}
});
this.#_content.children.forEach((id) => {
if (client.channels.cache.get(id) == null) {
this.#_content.children.splice(this.#_content.children.indexOf(id), 1);
updatePersistance = true;
}
});
if (updatePersistance) this.#save();
try {
//remove deleted channels from data
let updatePersistance = false;
this.#_content.primary.forEach((id) => {
if (client.channels.cache.get(id) == null) {
this.#_content.primary.splice(this.#_content.primary.indexOf(id), 1);
updatePersistance = true;
}
});
this.#_content.children.forEach((id) => {
if (client.channels.cache.get(id) == null) {
this.#_content.children.splice(
this.#_content.children.indexOf(id),
1
);
updatePersistance = true;
}
});
if (updatePersistance) this.#save();

// Check if channels need to be created
this.#_content.primary.forEach((id) => {
let primary = client.channels.cache.get(id);
if (primary?.members.first() != null) {
primary.members.every((member) => {
this.createChildVoice(primary, member);
});
}
});
//Check if channels need to be deleted
this.#_content.children.forEach((id) => {
let children = client.channels.cache.get(id);
if (children != null && children?.members.first() == null) {
this.deleteChildrenVoice(children);
}
});
// Check if channels need to be created
this.#_content.primary.forEach((id) => {
let primary = client.channels.cache.get(id);
if (primary?.members.first() != null) {
primary.members.every((member) => {
this.createChildVoice(primary, member);
});
}
});
//Check if channels need to be deleted
this.#_content.children.forEach((id) => {
let children = client.channels.cache.get(id);
if (children != null && children?.members.first() == null) {
this.deleteChildrenVoice(children);
}
});
} catch (e) {}
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/ririkoBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ const { RirikoMusic } = require("app/RirikoMusic");
const { getLang } = require("./helpers/language");
const { RirikoAVC } = require("./app/RirikoAVC");

process.on("uncaughtException", function (err) {
console.log("Caught exception: " + err);
});
process
.on("unhandledRejection", (reason, p) => {
console.error(reason, "Unhandled Rejection at Promise", p);
})
.on("uncaughtException", (err) => {
console.error(err, "Uncaught Exception thrown");
console.oLog(err);
});

console.info("0------------------| Ririko AI (Bot):".brightCyan);

Expand Down Expand Up @@ -166,7 +171,7 @@ module.exports = client;
})
.on("uncaughtException", (err) => {
console.error(err, "Uncaught Exception thrown");
process.exit(1);
console.oLog(err);
});

// Use this to remove commands list
Expand Down
9 changes: 9 additions & 0 deletions src/ririkoCli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ const NODE_ENV = process.env.NODE_ENV || "development";
let initialized = false;
let showPrompt = false; // Flag to control prompt display

process
.on("unhandledRejection", (reason, p) => {
console.error(reason, "Unhandled Rejection at Promise", p);
})
.on("uncaughtException", (err) => {
console.error(err, "Uncaught Exception thrown");
console.oLog(err);
});

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
Expand Down
9 changes: 9 additions & 0 deletions src/ririkoExpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ const path = require("path");

const configFileExists = fs.existsSync("./config.js");

process
.on("unhandledRejection", (reason, p) => {
console.error(reason, "Unhandled Rejection at Promise", p);
})
.on("uncaughtException", (err) => {
console.error(err, "Uncaught Exception thrown");
console.oLog(err);
});

console.info("0------------------| Ririko Express (Web Server):".brightCyan);

let Hostname, Port;
Expand Down
9 changes: 9 additions & 0 deletions src/ririkoQueueManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ overrideLoggers();

console.info("[Ririko Queue Manager] Started".brightMagenta);

process
.on("unhandledRejection", (reason, p) => {
console.error(reason, "Unhandled Rejection at Promise", p);
})
.on("uncaughtException", (err) => {
console.error(err, "Uncaught Exception thrown");
console.oLog(err);
});

const { Client, Intents, GatewayIntentBits } = require("discord.js");

const client = new Client({
Expand Down
9 changes: 9 additions & 0 deletions src/ririkoStreamChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ let retries = 0,
max_retries = 5;
let iteration = 1;

process
.on("unhandledRejection", (reason, p) => {
console.error(reason, "Unhandled Rejection at Promise", p);
})
.on("uncaughtException", (err) => {
console.error(err, "Uncaught Exception thrown");
console.oLog(err);
});

(async function () {
require("handlers/mongoose")(false, "Stream Checker", true);

Expand Down
62 changes: 0 additions & 62 deletions test.js

This file was deleted.

1 change: 0 additions & 1 deletion vc.json

This file was deleted.

0 comments on commit c3d7f45

Please sign in to comment.