2019-11-26 21:22:24 +00:00
|
|
|
const { inspect } = require("util");
|
|
|
|
|
2019-12-24 01:59:14 +00:00
|
|
|
exports.run = async (client, message, [action, key, ...value], level) => {
|
2019-11-26 21:22:24 +00:00
|
|
|
const defaults = client.settings.get("default");
|
|
|
|
|
|
|
|
if (action === "add") {
|
2019-12-24 01:59:14 +00:00
|
|
|
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.");
|
2019-11-26 21:22:24 +00:00
|
|
|
|
|
|
|
defaults[key] = value.join(" ");
|
|
|
|
|
|
|
|
client.settings.set("default", defaults);
|
2019-12-24 01:59:14 +00:00
|
|
|
message.reply(`${key} successfully added with the value of ${value.join(" ")}.`);
|
2019-11-26 21:22:24 +00:00
|
|
|
} else
|
|
|
|
|
|
|
|
if (action === "edit") {
|
2019-12-24 01:59:14 +00:00
|
|
|
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!");
|
2019-11-26 21:22:24 +00:00
|
|
|
|
|
|
|
defaults[key] = value.join(" ");
|
|
|
|
|
|
|
|
client.settings.set("default", defaults);
|
2019-12-24 01:59:14 +00:00
|
|
|
message.reply(`${key} successfully edited to ${value.join(" ")}.`);
|
2019-11-26 21:22:24 +00:00
|
|
|
} else
|
|
|
|
|
|
|
|
if (action === "del") {
|
2019-12-24 01:59:14 +00:00
|
|
|
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!");
|
2019-11-26 21:22:24 +00:00
|
|
|
|
|
|
|
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)) {
|
2019-12-24 01:59:14 +00:00
|
|
|
message.reply("action cancelled.");
|
2019-11-26 21:22:24 +00:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
|
|
|
|
if (action === "get") {
|
2019-12-24 01:59:14 +00:00
|
|
|
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]}.`);
|
2019-11-26 21:22:24 +00:00
|
|
|
|
|
|
|
} 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>"
|
|
|
|
};
|