help: {
params: "[<command>]",
help: "Display help for a commands or show list of available commands",
- func: (msg, [cmd]) => {
+ func: (msg, [cmd], {commands}) => {
if (cmd) {
let def = commands[cmd]
module.exports.storageLoad = name => {
try {
- return require(`storage/${name}.json`)
+ return require(`./storage/${name}.json`)
} catch {}
}
module.exports.listCommand = (title, list) => new Object({
help: "Show list of " + title,
- func: msg => msg.reply(`List of ${title}: ${Object.keys(list).join(", ")}`)
+ func: (msg, _, fb) => msg.reply(`List of ${title}: ${Object.keys(fb[list]).map(entry => "<@!" + entry + ">").join(", ")}`)
})
-module.exports.listChangeCommand = (action, list, listName, status) => new Object({
+module.exports.listChangeCommand = (action, list, status) => new Object({
operator: true,
- func: (msg, [targetPing]) => {
+ func: (msg, [targetPing], fb) => {
const target = getPing(msg, targetPing, true)
if (target) {
- if (list[target] == status) {
+ if (fb[list][target] == status) {
msg.reply(`<@!${target}> ${status ? "already" : "not"} ${action}.`)
} else {
- list[target] = status
- module.exports.storageSave(listName, list)
+ fb[list][target] = status
+ module.exports.storageSave(list, fb[list])
msg.reply(`Successfully ${action} <@!${target}>.`)
}
}
verse: {
func: msg => fetch("https://labs.bible.org/api/?type=json&passage=random")
.then(res => res.json())
- .then(data => msg.reply(`${data[0].text} [${data[0].bookname} ${data[0].chapter}, ${data[0].verse}]`))
+ .then(data => msg.reply(`${data[0].text}\n\t${data[0].bookname} ${data[0].chapter}, ${data[0].verse}`))
},
define: {
func: (msg, term) => term.length > 0 ? fetch("https://api.dictionaryapi.dev/api/v1/entries/en_US/" + term.join(" "))
if (def.operator && !fb.operators[msg.author.id])
msg.reply(`Sorry, you need to be an operator run this command: ${cmd}`)
else
- def.func(msg, args)
+ def.func(msg, args, fb)
} else {
msg.reply(`Invalid command: ${cmd}`)
}
}
})
-//const modules = ["nsfw", "random", "operator"]
-const modules = ["basic", "bullshit", "marriage", "http", "roleplay", "death", "economy", "waifu"]
+//const modules = ["nsfw", "random"]
+const modules = ["basic", "bullshit", "marriage", "http", "roleplay", "death", "economy", "waifu", "operator"]
for (let f of modules) {
let m = require(`./${f}.js`)
if (m)
for (let k in m)
- if (k != "__init")
- fb.commands[k] = m[k]
-
- m?.__init?.(fb)
+ fb.commands[k] = m[k]
}
-let operators, ignored
+const common = require("./common.js")
-furrybot.list_change_command("op", "operators", "an operator", true)
-furrybot.list_change_command("deop", "operators", "an operator", nil)
-furrybot.list_command("oplist", "operators", "operators")
-
-furrybot.list_change_command("ignore", "ignored", "ignored", true)
-furrybot.list_change_command("unignore", "ignored", "ignored", nil)
-furrybot.list_command("ignorelist", "ignored", "ignored players")
+module.exports = {
+ op: common.listChangeCommand("oped", "operators", true),
+ deop: common.listChangeCommand("oped", "operators", false),
+ oplist: common.listCommand("operators", "operators"),
+ ignore: common.listChangeCommand("ignored", "ignored", true),
+ unignore: common.listChangeCommand("ignored", "ignored", false),
+ ignorelist: common.listCommand("ignored users", "ignored"),
+}