73 lines
2.5 KiB
JavaScript
73 lines
2.5 KiB
JavaScript
const { inspect } = require("util");
|
|
|
|
exports.run = async (client, message, [action, key, ...value], level) => {
|
|
const defaults = client.settings.get("default");
|
|
|
|
if (action === "add") {
|
|
if (!key) return message.reply("please specify a key to add.");
|
|
if (defaults[key]) return message.reply("this key already exists in the default settings!");
|
|
if (value.length < 1) return message.reply("please specify a value.");
|
|
|
|
defaults[key] = value.join(" ");
|
|
|
|
client.settings.set("default", defaults);
|
|
message.reply(`${key} successfully added with the value of ${value.join(" ")}.`);
|
|
} else
|
|
|
|
if (action === "edit") {
|
|
if (!key) return message.reply("please specify a key to edit.");
|
|
if (!defaults[key]) return message.reply("this key does not exist in the settings!");
|
|
if (value.length < 1) return message.reply("please specify a new value!");
|
|
|
|
defaults[key] = value.join(" ");
|
|
|
|
client.settings.set("default", defaults);
|
|
message.reply(`${key} successfully edited to ${value.join(" ")}.`);
|
|
} else
|
|
|
|
if (action === "del") {
|
|
if (!key) return message.reply("please specify a key to delete.");
|
|
if (!defaults[key]) return message.reply("this key does not exist in the settings!");
|
|
|
|
const response = await client.awaitReply(message, `Are you sure you want to permanently delete ${key} from all guilds? This **CANNOT** be undone.`);
|
|
|
|
if (["y", "yes"].includes(response)) {
|
|
|
|
delete defaults[key];
|
|
client.settings.set("default", defaults);
|
|
|
|
for (const [guildid, conf] of client.settings.filter((setting, id) => setting[key] && id !== "default")) {
|
|
delete conf[key];
|
|
client.settings.set(guildid, conf);
|
|
}
|
|
|
|
message.reply(`${key} was successfully deleted.`);
|
|
} else
|
|
if (["n","no","cancel"].includes(response)) {
|
|
message.reply("action cancelled.");
|
|
}
|
|
} else
|
|
|
|
if (action === "get") {
|
|
if (!key) return message.reply("please specify a key to view.");
|
|
if (!defaults[key]) return message.reply("this key does not exist in the settings!");
|
|
message.reply(`the value of ${key} is currently ${defaults[key]}.`);
|
|
|
|
} else {
|
|
await message.channel.send(`***__Bot Default Settings__***\n\`\`\`json\n${inspect(defaults)}\n\`\`\``);
|
|
}
|
|
};
|
|
|
|
exports.conf = {
|
|
enabled: true,
|
|
guildOnly: true,
|
|
aliases: ["defaults"],
|
|
permLevel: "Bot Admin"
|
|
};
|
|
|
|
exports.help = {
|
|
name: "conf",
|
|
category: "System",
|
|
description: "Modify the default configuration for all guilds.",
|
|
usage: "conf <view/get/edit> <key> <value>"
|
|
};
|