2024-08-22 18:22:52 +02:00
|
|
|
import { encode } from "html-entities";
|
|
|
|
|
|
|
|
function execute(client, event, args) {
|
|
|
|
var name = args.toLowerCase();
|
|
|
|
|
|
|
|
var command = client.commands.filter(c=>(c.name.toLowerCase()==name || c.command.toLowerCase()==name))[0];
|
|
|
|
var module = client.modules.filter(m=>m.name.toLowerCase()==name)[0];
|
|
|
|
var specific = command ?? module ?? false;
|
|
|
|
|
2024-08-27 21:52:32 +02:00
|
|
|
var config = client.config.get(event.sender.roomId);
|
2024-08-22 18:22:52 +02:00
|
|
|
|
|
|
|
if(args != "") {
|
|
|
|
if(!module) {
|
|
|
|
client.reply(event, `Module "${args}" not found.\nRun "${process.env.PREFIX}help" for a list of commands and modules.`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-27 21:52:32 +02:00
|
|
|
config.set(module.name, !(config.get(module.name) ?? true));
|
|
|
|
var state = (config.get(module.name) ? "En" : "Dis") + "abled";
|
2024-08-22 18:22:52 +02:00
|
|
|
|
2024-08-23 11:57:03 +02:00
|
|
|
var reply = state + " " + module.name;
|
|
|
|
var replyHTML = `<b>${state}</b> <code>${encode(module.name)}</code>`;
|
2024-08-22 18:22:52 +02:00
|
|
|
|
|
|
|
client.reply(event, reply, replyHTML);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-23 11:57:03 +02:00
|
|
|
var modules = client.modules.map(m=>m.name);
|
2024-08-27 21:52:32 +02:00
|
|
|
var enabled = modules.filter(m=>config.get(m)!==false);
|
2024-08-23 11:57:03 +02:00
|
|
|
|
|
|
|
var reply = `enabled modules:\n${enabled.join(", ")}`;
|
|
|
|
var replyHTML = `enabled modules:<br><code>${enabled.join("</code>, <code>")}</code>`;
|
|
|
|
|
|
|
|
reply += `\navailable modules:\n${modules.join(", ")}`;
|
|
|
|
replyHTML += `<br>available modules:<br><code>${modules.join("</code>, <code>")}</code>`;
|
2024-08-22 18:22:52 +02:00
|
|
|
|
|
|
|
client.reply(event, reply, replyHTML);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
command: "toggle",
|
|
|
|
name: "toggle",
|
2024-08-25 15:10:16 +02:00
|
|
|
usage: "<module>",
|
2024-08-25 15:15:45 +02:00
|
|
|
minPwr: 50,
|
2024-08-22 18:22:52 +02:00
|
|
|
desc: "toggle a module on or off in current channel",
|
|
|
|
execute
|
|
|
|
}
|