From 1913704e903bf65aabd1d474fc408c575fd2e1e7 Mon Sep 17 00:00:00 2001 From: rhearmas <34490428+qu-ota@users.noreply.github.com> Date: Mon, 23 Dec 2019 20:59:14 -0500 Subject: [PATCH] fixing stuff i guess --- commands/System/conf.js | 54 ++++++++++++----------------------------- commands/System/set.js | 24 +++++++++--------- config_base.txt | 1 - modules/functions.js | 2 +- 4 files changed, 28 insertions(+), 53 deletions(-) diff --git a/commands/System/conf.js b/commands/System/conf.js index 4a08fcc..577313c 100644 --- a/commands/System/conf.js +++ b/commands/System/conf.js @@ -1,62 +1,41 @@ const { inspect } = require("util"); -/* -FOR GUILD SETTINGS SEE set.js ! -This command is used to modify the bot's default configuration values, which affects all guilds. -If a default setting is not specifically overwritten by a guild, changing a default here will -change it for that guild. The `add` action adds a key to the configuration of every guild in -your bot. The `del` action removes the key also from every guild, and loses its value forever. -*/ - -exports.run = async (client, message, [action, key, ...value], level) => { // eslint-disable-line no-unused-vars - - // Retrieve Default Values from the default settings in the bot. +exports.run = async (client, message, [action, key, ...value], level) => { const defaults = client.settings.get("default"); - // Adding a new key adds it to every guild (it will be visible to all of them) 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"); + 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."); - // `value` being an array, we need to join it first. defaults[key] = value.join(" "); - // One the settings is modified, we write it back to the collection client.settings.set("default", defaults); - message.reply(`${key} successfully added with the value of ${value.join(" ")}`); + message.reply(`${key} successfully added with the value of ${value.join(" ")}.`); } else - // Changing the default value of a key only modified it for guilds that did not change it to another value. 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"); + 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(" ")}`); + message.reply(`${key} successfully edited to ${value.join(" ")}.`); } else - // WARNING: DELETING A KEY FROM THE DEFAULTS ALSO REMOVES IT FROM EVERY GUILD - // MAKE SURE THAT KEY IS REALLY NO LONGER NEEDED! 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"); + 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!"); - // Throw the 'are you sure?' text at them. const response = await client.awaitReply(message, `Are you sure you want to permanently delete ${key} from all guilds? This **CANNOT** be undone.`); - // If they respond with y or yes, continue. if (["y", "yes"].includes(response)) { - // We delete the default `key` here. delete defaults[key]; client.settings.set("default", defaults); - // then we loop on all the guilds and remove this key if it exists. - // "if it exists" is done with the filter (if the key is present and it's not the default config!) for (const [guildid, conf] of client.settings.filter((setting, id) => setting[key] && id !== "default")) { delete conf[key]; client.settings.set(guildid, conf); @@ -64,19 +43,16 @@ exports.run = async (client, message, [action, key, ...value], level) => { // es message.reply(`${key} was successfully deleted.`); } else - // If they respond with n or no, we inform them that the action has been cancelled. if (["n","no","cancel"].includes(response)) { - message.reply("Action cancelled."); + message.reply("action cancelled."); } } else - // Display a key's default value 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]}`); + 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]}.`); - // Display all default settings. } else { await message.channel.send(`***__Bot Default Settings__***\n\`\`\`json\n${inspect(defaults)}\n\`\`\``); } diff --git a/commands/System/set.js b/commands/System/set.js index b88c365..33c2f0e 100644 --- a/commands/System/set.js +++ b/commands/System/set.js @@ -5,11 +5,11 @@ exports.run = async (client, message, [action, key, ...value], level) => { if (!client.settings.has(message.guild.id)) client.settings.set(message.guild.id, {}); 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 (!key) return message.reply("please specify a key to edit"); + if (!defaults[key]) return message.reply("this key does not exist in the settings"); const joinedValue = value.join(" "); - if (joinedValue.length < 1) return message.reply("Please specify a new value"); - if (joinedValue === settings[key]) return message.reply("This setting already has that value!"); + if (joinedValue.length < 1) return message.reply("please specify a new value."); + if (joinedValue === settings[key]) return message.reply("this setting already has that value!"); if (!client.settings.has(message.guild.id)) client.settings.set(message.guild.id, {}); @@ -19,9 +19,9 @@ exports.run = async (client, message, [action, key, ...value], level) => { } else if (action === "del" || action === "reset") { - if (!key) return message.reply("Please specify a key to reset."); - if (!defaults[key]) return message.reply("This key does not exist in the settings"); - if (!overrides[key]) return message.reply("This key does not have an override and is already using defaults."); + if (!key) return message.reply("please specify a key to reset."); + if (!defaults[key]) return message.reply("this key does not exist in the settings"); + if (!overrides[key]) return message.reply("this key does not have an override and is already using defaults."); const response = await client.awaitReply(message, `Are you sure you want to reset ${key} to the default value?`); @@ -30,15 +30,15 @@ exports.run = async (client, message, [action, key, ...value], level) => { message.reply(`${key} was successfully reset to default.`); } else if (["n","no","cancel"].includes(response)) { - message.reply(`Your setting for \`${key}\` remains at \`${settings[key]}\``); + message.reply(`your setting for \`${key}\` remains at \`${settings[key]}\``); } } 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"); - const isDefault = !overrides[key] ? "\nThis is the default global default value." : ""; - message.reply(`The value of ${key} is currently ${settings[key]}${isDefault}`); + 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!"); + const isDefault = !overrides[key] ? "\nthis is the default global default value." : ""; + message.reply(`the value of ${key} is currently ${settings[key]}${isDefault}.`); } else { const array = []; Object.entries(settings).forEach(([key, value]) => { diff --git a/config_base.txt b/config_base.txt index 0ef6d5f..4e622cc 100644 --- a/config_base.txt +++ b/config_base.txt @@ -8,7 +8,6 @@ const config = { "token": {{token}}, permLevels: [ - // This is the lowest permisison level, this is for non-roled users. { level: 0, name: "User", check: () => true diff --git a/modules/functions.js b/modules/functions.js index eb07a3d..5abf8df 100644 --- a/modules/functions.js +++ b/modules/functions.js @@ -19,7 +19,7 @@ module.exports = (client) => { }; const defaultSettings = { - "prefix": "/", + "prefix": "b&", "modLogChannel": "mod-log", "modRole": "modinator", "adminRole": "adminator",