change how configs are handled
This commit is contained in:
parent
328c817136
commit
cca482079c
8 changed files with 96 additions and 43 deletions
|
|
@ -1,5 +1,8 @@
|
|||
import { xxh64 } from "@node-rs/xxhash";
|
||||
import { encode } from "html-entities";
|
||||
import { JSDOM } from "jsdom";
|
||||
import util from "util";
|
||||
import fs from "fs";
|
||||
|
||||
function execute(client, event, args) {
|
||||
var c = "";
|
||||
|
|
@ -17,6 +20,6 @@ export default {
|
|||
name: "eval",
|
||||
usage: "<code>",
|
||||
owner: true,
|
||||
desc: "Run JS code and reply with the result",
|
||||
desc: "run JS code and reply with the result",
|
||||
execute
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ function execute(client, event, args) {
|
|||
|
||||
if(args != "") {
|
||||
if(!command && !module) {
|
||||
client.reply(event, `Section "${args}" not found.\nRun "${process.env.PREFIX}help" for a list of commands and modules.`);
|
||||
client.reply(event, `section "${args}" not found.\nrun "${process.env.PREFIX}help" for a list of commands and modules.`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
function execute(client, event, args) {
|
||||
var info = `Source code: https://git.lgbt/root/possumbot\n`;
|
||||
info += `Commands: ${client.commands.length}\n`;
|
||||
info += `Modules: ${client.modules.length}\n`;
|
||||
info += `Prefix: ${process.env.PREFIX} (you can also mention the bot!)\n`;
|
||||
info += `Owner: ${process.env.OWNER_ID}`;
|
||||
var info = `source code: https://git.lgbt/root/possumbot\n`;
|
||||
info += `commands: ${client.commands.length}\n`;
|
||||
info += `modules: ${client.modules.length}\n`;
|
||||
info += `prefix: ${process.env.PREFIX} (you can also mention the bot!)\n`;
|
||||
info += `owner: ${process.env.OWNER_ID}`;
|
||||
|
||||
client.reply(event, info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { exec } from "node:child_process";
|
||||
|
||||
function execute(client, event, args) {
|
||||
process.exit(255);
|
||||
process.exit(255);
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ function execute(client, event, args) {
|
|||
var module = client.modules.filter(m=>m.name.toLowerCase()==name)[0];
|
||||
var specific = command ?? module ?? false;
|
||||
|
||||
var config = client.cache.get(event.sender.roomId) ?? {};
|
||||
var config = client.config.get(event.sender.roomId);
|
||||
|
||||
if(args != "") {
|
||||
if(!module) {
|
||||
|
|
@ -15,23 +15,18 @@ function execute(client, event, args) {
|
|||
return;
|
||||
}
|
||||
|
||||
if(config[module.name] !== undefined)
|
||||
config[module.name] = !config[module.name];
|
||||
else
|
||||
config[module.name] = false;
|
||||
|
||||
var state = (config[module.name] ? "En" : "Dis") + "abled";
|
||||
config.set(module.name, !(config.get(module.name) ?? true));
|
||||
var state = (config.get(module.name) ? "En" : "Dis") + "abled";
|
||||
|
||||
var reply = state + " " + module.name;
|
||||
var replyHTML = `<b>${state}</b> <code>${encode(module.name)}</code>`;
|
||||
|
||||
client.cache.set(event.sender.roomId, config);
|
||||
client.reply(event, reply, replyHTML);
|
||||
return;
|
||||
}
|
||||
|
||||
var modules = client.modules.map(m=>m.name);
|
||||
var enabled = modules.filter(m=>config[m]!==false);
|
||||
var enabled = modules.filter(m=>config.get(m)!==false);
|
||||
|
||||
var reply = `enabled modules:\n${enabled.join(", ")}`;
|
||||
var replyHTML = `enabled modules:<br><code>${enabled.join("</code>, <code>")}</code>`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue