From 4bebd207b4c3ab51f79dbe6e01bb437ec4369756 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Mon, 11 May 2020 01:47:09 -0400 Subject: [PATCH 1/6] Moved More Speech To Language Files Moved the economy speech stuff to the language files. Also moved the permission levels to use the language files instead of importing them through settings.json and having the permLevel in the client. --- assets/settingsExample.json | 20 +------- assets/speech/en-CA/config.js | 84 ++++++++++++++++---------------- assets/speech/en-CA/economy.js | 88 ++++++++++++++++++---------------- commands/Economy/daily.js | 6 +-- commands/Economy/exchange.js | 11 ++--- commands/Economy/rep.js | 14 +++--- commands/Economy/revoke.js | 10 ++-- commands/General/help.js | 2 +- commands/System/permlevel.js | 8 ++-- index.js | 1 - languages/en-CA.js | 28 +++++++++++ utilities/presenceHelper.js | 6 +-- 12 files changed, 147 insertions(+), 131 deletions(-) diff --git a/assets/settingsExample.json b/assets/settingsExample.json index 9860964..51ee809 100644 --- a/assets/settingsExample.json +++ b/assets/settingsExample.json @@ -17,23 +17,5 @@ "major": 2000 } }, - "database": "./assets/MargarineData.sqlite", - "permLevels": { - "general": [ - "Level 0: Everyone", - "Level 1: Placeholder", "Level 2: Placeholder", "Level 3: Placeholder", "Level 4: Placeholder", - "Level 5: Guild Moderators", - "Level 6: Guild Admins", - "Level 7: Guild Owners", - "Level 8: Placeholder", - "Level 9: Toast & Butter", - "Level 10: Bot Owner" - ], - "addPerms": [ - "with no additional permissions", - "with guild moderator permissions", - "with guild admin permissions", - "with guild owner permissions" - ] - } + "database": "./assets/MargarineData.sqlite" } \ No newline at end of file diff --git a/assets/speech/en-CA/config.js b/assets/speech/en-CA/config.js index 9703c0f..c599043 100644 --- a/assets/speech/en-CA/config.js +++ b/assets/speech/en-CA/config.js @@ -1,42 +1,46 @@ -exports.starboard = { - "wrongItem": [ - "Nope, that's not going to work. You're going to need something that matches what you want to set.", - "Sorry, that's not going to work. You need to match what you want to set." - ], - "set": [ - "Okay! I've set -target to -item!", - "You're all set! -target is now set to -item!" - ], - "list": [ - "Okay! Here's your starboard settings:\n__Channel:__ <#-channel>\n__Emote:__ -emote\n__Amount:__ -amount" - ], - "noItem": [ - "Hmm... looks like you didn't want me to set anything.", - "Didn't want me to set anything? Okay then..." - ], - "remove": [ - "Okay! I've set -target back to its original state.", - "-target is now back to its original state!", - "Okay! -target will be at it's default value then." - ] -}; +/* + * Speech module for all configuation commands. + */ -exports.setrole = { - "highpos": [ - "I can't assign that role. It's much higher than my highest role. Try lowering its position before making it assignable.", - "That role's position is much higher than my highest. I won't be able to assign that role until you lower its position. Try again once you do!" - ], - "added": [ - "Okay! I'll be sure to distribute -role from now on!", - "-role is now on my list of assignables!" - ], - "remove": [ - "Okay! I'll stop distributing -role from now on!", - "-role has been removed from my list of assignables!" +module.exports = { + "starboard": { + "wrongItem": [ + "Nope, that's not going to work. You're going to need something that matches what you want to set.", + "Sorry, that's not going to work. You need to match what you want to set." + ], + "set": [ + "Okay! I've set -target to -item!", + "You're all set! -target is now set to -item!" + ], + "list": [ + "Okay! Here's your starboard settings:\n__Channel:__ <#-channel>\n__Emote:__ -emote\n__Amount:__ -amount" + ], + "noItem": [ + "Hmm... looks like you didn't want me to set anything.", + "Didn't want me to set anything? Okay then..." + ], + "remove": [ + "Okay! I've set -target back to its original state.", + "-target is now back to its original state!", + "Okay! -target will be at it's default value then." + ] + }, + "setrole": { + "highpos": [ + "I can't assign that role. It's much higher than my highest role. Try lowering its position before making it assignable.", + "That role's position is much higher than my highest. I won't be able to assign that role until you lower its position. Try again once you do!" + ], + "added": [ + "Okay! I'll be sure to distribute -role from now on!", + "-role is now on my list of assignables!" + ], + "remove": [ + "Okay! I'll stop distributing -role from now on!", + "-role has been removed from my list of assignables!" + ] + }, + "setprefix": [ + "Okay! I've updated the guild prefix to -editPrefix.", + "I'll be sure to stay on the lookout for -editPrefix now." ] -}; - -exports.setprefix = [ - "Okay! I've updated the guild prefix to -editPrefix.", - "I'll be sure to stay on the lookout for -editPrefix now." -]; \ No newline at end of file +}; \ No newline at end of file diff --git a/assets/speech/en-CA/economy.js b/assets/speech/en-CA/economy.js index 889786b..2a9585a 100644 --- a/assets/speech/en-CA/economy.js +++ b/assets/speech/en-CA/economy.js @@ -1,45 +1,49 @@ -/*Speech for all commands in the general economy section*/ +/* + * Speech for all commands in the general economy section + */ -exports.balance = []; //Placeholder - -exports.daily = { - "self": [ - "You have redeemed 100 credits!", - "Poof! You are 100 credits richer now!", - "Don't go gambling your 100 credits all in one place now.", - "You have redeemed your daily credits. Come back tomorrow at the same time for more!", - "You should buy me a game with those credits. I won't take all 100 on you, I swear." - ], - "other": [ - "Oh? Feeling generous are we? You have given -user -credit credits!", - "Success! -user is now -credit credits richer!", - "-user is really going to make it rain with -credit extra credits in their pockets!" - ] -}; - -exports.exchange = [ - "-user1 just gave -user2 -credit credits!", - "Looks like -user2 is -credit credits richer because of -user1.", - "Exchange complete, -user1! -user2 has received -credit credits.", - "Credits exchanged! -credit credits have been given to -user2." -]; - -exports.rep = [ - "You have given -mention a reputation point!", - "One new, shiny reputation point for -mention has been given!" -]; - -exports.revoke = { - "prompt": [ - "By doing this, you will delete all of your data. If you want to do this, reply with \"yes\"." - ], - "stopped": [ - "Action aborted. Nothing has happened." +module.exports = { + "balance": null, //Placeholder + "daily": { + "self": [ + "You have redeemed 100 credits!", + "Poof! You are 100 credits richer now!", + "Don't go gambling your 100 credits all in one place now.", + "You have redeemed your daily credits. Come back tomorrow at the same time for more!", + "You should buy me a game with those credits. I won't take all 100 on you, I swear." + ], + "other": [ + "Oh? Feeling generous are we? You have given -user -credit credits!", + "Success! -user is now -credit credits richer!", + "-user is really going to make it rain with -credit extra credits in their pockets!" + ] + }, + "exchange": [ + "-user1 just gave -user2 -credit credits!", + "Looks like -user2 is -credit credits richer because of -user1.", + "Exchange complete, -user1! -user2 has received -credit credits.", + "Credits exchanged! -credit credits have been given to -user2." ], - "success": [ - "Okay. I've deleted your data from my systems. If you want to give it to me again, wait 24 hours." + "rep": [ + "You have given -mention a reputation point!", + "One new, shiny reputation point for -mention has been given!" ], - "timeout": [ - "Whoops! Looks like you forgot to respond to me. I'm not waiting around anymore." - ] -} + "revoke": { + "prompt": [ + "By doing this, you will delete all of your data. If you want to do this, reply with \"yes\".", + "You will delete all of your data if you do this. To confirm your action, reply with \"yes\"." + ], + "stopped": [ + "Action aborted. Nothing has happened.", + "Action cancelled! Nothing has happened." + ], + "success": [ + "Okay. I've deleted your data from my systems. If you want to give it to me again, wait 24 hours.", + "Just like that, your data is deleted. If you want to give it to me again, wait 24 hours before redeeming a daily." + ], + "timeout": [ + "Whoops! Looks like you forgot to respond to me. I'm not waiting around anymore.", + "I can't wait all day. Try again when ready to." + ] + } +}; \ No newline at end of file diff --git a/commands/Economy/daily.js b/commands/Economy/daily.js index 81f1b8b..3cddab9 100644 --- a/commands/Economy/daily.js +++ b/commands/Economy/daily.js @@ -28,7 +28,7 @@ module.exports = class extends Command { } this.client.dataManager("add", msg.author.id); - return msg.channel.send(this.client.speech(msg, ["daily", "self"])); + return msg.sendLocale("DAILY_SELF", [msg]); } var cooldown = JSON.parse(data.cooldowns); @@ -38,7 +38,7 @@ module.exports = class extends Command { cooldown.credit = Date.now(); this.client.dataManager("update", [`credits=${(data.credits + 100)}, cooldowns='${JSON.stringify(cooldown)}'`, msg.author.id], "users"); - return msg.channel.send(this.client.speech(msg, ["daily", "self"])); + return msg.sendLocale("DAILY_SELF", [msg]); } var tarData = this.client.dataManager("select", user.id, "users"); @@ -49,6 +49,6 @@ module.exports = class extends Command { this.client.dataManager("update", [`credits=${(tarData.credits + 100)}`, user.id], "users"); this.client.dataManager("update", [`cooldowns='${JSON.stringify(cooldown)}'`, msg.author.id], "users"); - return msg.channel.send(this.client.speech(msg, ["daily", "other"], [["-user", user.username], ["-credit", 100]])); + msg.sendLocale("DAILY_SUCCESS", [msg, user.username, 100]); } }; \ No newline at end of file diff --git a/commands/Economy/exchange.js b/commands/Economy/exchange.js index 9fecea7..692a7c6 100644 --- a/commands/Economy/exchange.js +++ b/commands/Economy/exchange.js @@ -8,7 +8,7 @@ module.exports = class extends Command { runIn: ["text"], cooldown: 10, description: "Give someone some of your credits", - usage: " [credit:intcheck{1,}]", usageDelim: " " + usage: " ", usageDelim: " " }); this.humanUse = " "; @@ -24,12 +24,9 @@ module.exports = class extends Command { var tarData = this.client.dataManager("select", user.id, "users"); if (!tarData) { return msg.sendLocale("DATACHECK_NOUSER"); } - data.credits -= credit; - tarData.credits += credit; + this.client.dataManager("update", [`credits=${(tarData.credits + credit)}`, user.id], "users"); + this.client.dataManager("update", [`credits=${(data.credits - credit)}`, msg.author.id], "users"); - this.client.dataManager("update", [`credits=${tarData.credits}`, user.id], "users"); - this.client.dataManager("update", [`credits=${data.credits}`, msg.author.id], "users"); - - msg.channel.send(this.client.speech(msg, ["exchange"], [["-user1", msg.author.username], ["-user2", `<@${user.id}>`], ["-credit", credit]])); + msg.sendLocale("EXCHANGE", [msg, msg.author.username, `<@${user.id}>`, credit]); } }; \ No newline at end of file diff --git a/commands/Economy/rep.js b/commands/Economy/rep.js index 81d1f42..ab8ab14 100644 --- a/commands/Economy/rep.js +++ b/commands/Economy/rep.js @@ -9,21 +9,21 @@ module.exports = class extends Command { description: "Give someone a reputation point!", usage: " [note:str]", usageDelim: "|" }); + + this.humanUse = " [note]"; } async run(msg, [user, note]) { - if (user.id === msg.author.id) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "sameUser"])); } + if (user.id === msg.author.id) { return msg.sendLocale("DATACHECK_SAMEUSER"); } var data = this.client.dataManager("select", msg.author.id, "users"); - if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } + if (!data) { return msg.sendLocale("DATACHECK_NOACCOUNT"); } var tarData = this.client.dataManager("select", user.id, "users"); - if (!tarData) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noUser"])); } + if (!tarData) { return msg.sendLocale("DATACHECK_NOUSER"); } var cooldown = JSON.parse(data.cooldowns); - if (cooldown.rep !== null && cooldown.rep + 86400000 > Date.now()) { - return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "cooldown"])); - } + if (cooldown.rep !== null && cooldown.rep + 86400000 > Date.now()) { return msg.sendLocale("DATACHECK_COOLDOWN"); } cooldown.rep = Date.now(); @@ -34,6 +34,6 @@ module.exports = class extends Command { user.send(`Delivery here! Someone has included a note with your rep!\n\n${note.join(" ")}\n-${msg.author.tag}`); } - msg.channel.send(this.client.speech(msg, ["rep"], [["-mention", `<@${user.id}>`]])); + msg.sendLocale("REP", [msg, `<@${user.id}>`]); } }; \ No newline at end of file diff --git a/commands/Economy/revoke.js b/commands/Economy/revoke.js index cd3d63c..6b67f30 100644 --- a/commands/Economy/revoke.js +++ b/commands/Economy/revoke.js @@ -13,20 +13,20 @@ module.exports = class extends Command { async run(msg) { var data = this.client.dataManager("select", msg.author.id, "users"); - if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } + if (!data) { return msg.sendLocale("DATACHECK_NOACCOUNT"); } let filterArr = ["yes", "no"]; let filter = m => filterArr.includes(m.content.toLowerCase()) && m.author === msg.author; - await msg.channel.send(this.client.speech(msg, ["revoke", "prompt"])).then(() => { + await msg.sendLocale("REVOKE_PROMPT", [msg]).then(() => { msg.channel.awaitMessages(filter, { max: 1, time: 130000, errors: ["time"] }).then((answer) => { answer = answer.first().content.toLowerCase(); - if (answer === "no") { return msg.channel.send(this.client.speech(msg, ["revoke", "stopped"])); } + if (answer === "no") { return msg.sendLocale("REVOKE_STOPPED", [msg]); } this.client.settings.usedDaily.set(msg.author.id, Date.now()); //Start cooldown timer. this.client.dataManager("delete", msg.author.id); //Purge data in the database - msg.channel.send(this.client.speech(msg, ["revoke", "success"])); //Respond with success - }).catch((collected) => { msg.channel.send(this.client.speech(msg, ["revoke", "timeout"])); }); + msg.sendLocale("REVOKE_SUCCESS", [msg]); //Respond with success + }).catch((collected) => { msg.sendLocale("REVOKE_TIMEOUT", [msg]); }); }); } }; \ No newline at end of file diff --git a/commands/General/help.js b/commands/General/help.js index 2f86c53..2d3a872 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -62,7 +62,7 @@ module.exports = class extends Command { .setTitle(cmd.name + alias) .setDescription(cmd.description) .addField("Usage:", `\`${msg.guild.settings.prefix + cmd.name} ${usageAct}\``) - .addField("Permission level:", this.client.ownerSetting.get("permLevel").general[cmd.permissionLevel]); + .addField("Permission level:", msg.language.get("PERMLEVEL")[cmd.permissionLevel]); if (typeof cmd.extendedHelp === "string") { embed.addField("Extended Help:", cmd.extendedHelp); } msg.send({embed}); } diff --git a/commands/System/permlevel.js b/commands/System/permlevel.js index 627ec5a..f1da92f 100644 --- a/commands/System/permlevel.js +++ b/commands/System/permlevel.js @@ -25,8 +25,10 @@ module.exports = class extends Command { else if (author.roles.cache.has(guild.settings.modRole)) { permLevel = 1; } else { permLevel = 0; } - var info = this.client.ownerSetting.get("permLevel").addPerms[permLevel]; - return msg.channel.send(`Your permission level is ${this.client.ownerSetting.get("permLevel").general[authorLvl]} ${info}`); + + + var info = msg.language.get("ADDPERMS")[permLevel]; + return msg.channel.send(`Your permission level is ${msg.language.get("PERMLEVEL")[authorLvl]} ${info}`); } for (var i = 5; i < 8; i++) { @@ -34,6 +36,6 @@ module.exports = class extends Command { if (check) { permLevel = i; } } - msg.channel.send(`Your permission level is ${this.client.ownerSetting.get("permLevel").general[permLevel]}`); + msg.channel.send(`Your permission level is ${msg.language.get("PERMLEVEL")[permLevel]}`); } }; \ No newline at end of file diff --git a/index.js b/index.js index a193f96..954cfb3 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,6 @@ for (var x = 0; keys.length > x; x++) { } } -client.ownerSetting.set("permLevel", config.permLevels); client.ownerSetting.set("globalPrefix", config.prefix); client.itemData = require("./assets/items.json"); diff --git a/languages/en-CA.js b/languages/en-CA.js index f9ed20d..1e7f987 100644 --- a/languages/en-CA.js +++ b/languages/en-CA.js @@ -25,6 +25,22 @@ module.exports = class extends Language { DEFAULT_LANGUAGE: "Default Language", NOCHANNEL: "No channel set", MISSINGTERM: (action) => this.client.speech(falseMsg, ["func-system", "missingterm"], ["-action", action]), + PERMLEVEL: [ + "Level 0 - Everyone", + "Level 1 - Placeholder", "Level 2 - Placeholder", "Level 3 - Placeholder", "Level 4 - Placeholder", + "Level 5 - Guild Moderators", + "Level 6 - Guild Admins", + "Level 7 - Guild Owners", + "Level 8 - Placeholder", + "Level 9 - Toast & Butter", + "Level 10 - Bot Owner" + ], + ADDPERMS: [ + "with no additional permissions", + "with guild moderator permissions", + "with guild admin permissions", + "with guild owner permissions" + ], /* * Klasa System - Margarine Style Responses @@ -206,6 +222,18 @@ module.exports = class extends Language { ROLL_NOZERO: (msg) => this.client.speech(msg, ["roll", "zero"]), ROLL_NONEGATIVE: (msg) => this.client.speech(msg, ["roll", "negative"]), ROLL_SUCCESS: (msg, value) => this.client.speech(msg, ["roll", "success"]).replace("-value", value), + + /* + * Commands - Economy + */ + DAILY_SELF: (msg) => this.client.speech(msg, ["daily", "self"]), + DAILY_SUCCESS: (msg, target, amount) => this.client.speech(msg, ["daily", "other"], [["-user", target], ["-credit", amount]]), + EXCHANGE: (msg, author, target, credit) => this.client.speech(msg, ["exchange"], [["-user1", author], ["-user2", target], ["-credit", credit]]), + REP: (msg, target) => this.client.speech(msg, ["rep"], [["-mention", target]]), + REVOKE_PROMPT: (msg) => this.client.speech(msg, ["revoke", "prompt"]), + REVOKE_STOPPED: (msg) => this.client.speech(msg, ["revoke", "stopped"]), + REVOKE_TIMEOUT: (msg) => this.client.speech(msg, ["revoke", "timeout"]), + REVOKE_SUCCESS: (msg) => this.client.speech(msg, ["revoke", "success"]), }; } }; \ No newline at end of file diff --git a/utilities/presenceHelper.js b/utilities/presenceHelper.js index f992e32..5446807 100644 --- a/utilities/presenceHelper.js +++ b/utilities/presenceHelper.js @@ -10,10 +10,10 @@ function Presence(client, type, name, status) { /** * Sets the presence for Margarine and starts a 15 minute interval for automatic change - * @param { KlasaClient } client - Required. Needed to grab the user and additional functions. + * @param { KlasaClient } client - Needed to grab the user and additional functions. * @param { String } name - Customize a presence. Will not reset until the user sends additional commands. - * @param { String } type - Type of activity to be displayed. Either play, stream, listen, or watch. - * @param { String } status - Changes the colour on the status. Either online, idle, dnd, or invisible. + * @param { String } [type=play] - Type of activity to be displayed. Either play, stream, listen, or watch. + * @param { String } [status=online] - Changes the colour on the status. Either online, idle, dnd, or invisible. */ module.exports = (client, name, type=0, status="online") => { //Type defaulted to play and status defaulted to online. const sliceCheck = `${client.ownerSetting.get("globalPrefix")}help |`.length; From 5bbd46fa17a8b1d66493026506ff22be6b261273 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Mon, 11 May 2020 14:19:29 -0400 Subject: [PATCH 2/6] Updated Games Updated all of the game commands to utilize the en-CA file and the integerCheck argument to verify a positive integer. --- commands/Economy/Games/chouhan.js | 10 +++++----- commands/Economy/Games/coin.js | 10 +++++----- commands/Economy/Games/hazard.js | 6 +++--- commands/Economy/Games/twoup.js | 15 +++++++-------- languages/en-CA.js | 10 ++++++++++ 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/commands/Economy/Games/chouhan.js b/commands/Economy/Games/chouhan.js index 7f61c25..1d192df 100644 --- a/commands/Economy/Games/chouhan.js +++ b/commands/Economy/Games/chouhan.js @@ -8,7 +8,7 @@ module.exports = class extends Command { runIn: ["text"], aliases: ["chōhan"], description: "Bet your credits on if the sum of six dice are even or odd.", - usage: " ", usageDelim: " ", + usage: " ", usageDelim: " ", extendedHelp: "A simple Japanese dice game. Six dice are rolled and the results kept secret. Players bet on whether the sum on the dice is odd or even." }); @@ -17,8 +17,8 @@ module.exports = class extends Command { async run(msg, [choice=choice.toLowerCase(), bet]) { var data = this.client.dataManager("select", msg.author.id, "users"); - if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } - if (data.credits < bet) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "lackCredits"])); } + if (!data) { return msg.sendLocale("DATACHECK_NOACCOUNT"); } + if (data.credits < bet) { return msg.sendLocale("DATACHECK_LACKCREDIT"); } let rolls = []; for (var z = 0; z < 6; z++) { rolls.push(Math.floor(Math.random() * (Math.floor(6) - Math.ceil(1) + 1)) + Math.ceil(1)); } @@ -27,10 +27,10 @@ module.exports = class extends Command { if ((sum%2 === 0 && bet === "even") || (sum%2 !== 0 && bet === "odd")) { this.client.dataManager("update", [`credits=${data.credits + (bet * 2)}`, msg.author.id], "users"); - return msg.channel.send(this.client.speech(msg, ["chouhan", "win"], [["-sum", sum], ["-guess", choice], ["-earning", (bet * 2)]])); + return msg.sendLocale("CHOUHAN_SUCCESS", [msg, sum, choice, (bet * 2)]); } this.client.dataManager("update", [`credits=${data.credits - bet}`, msg.author.id], "users"); - msg.channel.send(this.client.speech(msg, ["chouhan", "lose"], [["-sum", sum], ["-guess", choice], ["-earning", bet]])); + msg.sendLocale("CHOUHAN_LOSS", [msg, sum, choice, bet]); } }; \ No newline at end of file diff --git a/commands/Economy/Games/coin.js b/commands/Economy/Games/coin.js index 43c58e0..1dcbd01 100644 --- a/commands/Economy/Games/coin.js +++ b/commands/Economy/Games/coin.js @@ -7,7 +7,7 @@ module.exports = class extends Command { enabled: true, runIn: ["text"], description: "Flip a coin!", - usage: " ", usageDelim: " " + usage: " ", usageDelim: " " }); this.humanUse = " "; @@ -15,17 +15,17 @@ module.exports = class extends Command { async run(msg, [choice=choice.toLowerCase(), bet]) { var data = this.client.dataManager("select", msg.author.id, "users"); - if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } - if (data.credits < bet) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "lackCredits"])); } + if (!data) { return msg.sendLocale("DATACHECK_NOACCOUNT"); } + if (data.credits < bet) { return msg.sendLocale("DATACHECK_LACKCREDIT"); } let y = Math.random() > .5 ? "Heads": "Tails"; if (y.toLowerCase() === choice) { this.client.dataManager("update", [`credits=${data.credits + (bet * 2)}`, msg.author.id], "users"); - return msg.channel.send(this.client.speech(msg, ["coin", "win"], [["-result", y], ["-earning", bet]])); + return msg.sendLocale("COIN_SUCCESS", [msg, y, bet]); } this.client.dataManager("update", [`credits=${data.credits - bet}`, msg.author.id], "users"); - msg.channel.send(this.client.speech(msg, ["coin", "lose"], [["-result", y], ["-earning", bet]])); + msg.sendLocale("COIN_LOSS", [msg, y, bet]); } }; \ No newline at end of file diff --git a/commands/Economy/Games/hazard.js b/commands/Economy/Games/hazard.js index 97c3353..c2a5e0e 100644 --- a/commands/Economy/Games/hazard.js +++ b/commands/Economy/Games/hazard.js @@ -18,7 +18,7 @@ module.exports = class extends Command { enabled: true, runIn: ["text"], description: "Gamble your credits in a early version of craps, a dice game.", - usage: "", usageDelim: " ", + usage: "", usageDelim: " ", extendedHelp: "An early English game played with two dice. The game 'Craps' developed from hazard. The game is popular in North America but is not in the rest of the world." }); @@ -27,8 +27,8 @@ module.exports = class extends Command { async run(msg, [bet]) { var data = this.client.dataManager("select", msg.author.id, "users"); - if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } - if (data.credits < bet) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "lackCredits"])); } + if (!data) { return msg.sendLocale("DATACHECK_NOACCOUNT"); } + if (data.credits < bet) { return msg.sendLocale("DATACHECK_LACKCREDIT"); } const embed = new MessageEmbed() .setTimestamp() diff --git a/commands/Economy/Games/twoup.js b/commands/Economy/Games/twoup.js index 831ba40..fd20fa7 100644 --- a/commands/Economy/Games/twoup.js +++ b/commands/Economy/Games/twoup.js @@ -7,7 +7,7 @@ module.exports = class extends Command { enabled: true, runIn: ["text"], description: "Bet on coin flips. Get two heads in a row and win or hope for all five odds!", - usage: "", + usage: "", extendedHelp: "Two-up is a traditional Australian gambling game, involving a designated 'spinner' throwing two coins into the air. Players bet on whether the coins will fall with both heads up, both tails up, or with one head and one tail up (known as 'odds'). It is traditionally played on Anzac Day in pubs and clubs throughout Australia." }); @@ -16,13 +16,12 @@ module.exports = class extends Command { async run(msg, [bet]) { var data = this.client.dataManager("select", msg.author.id, "users"); - if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } - if (data.credits < bet) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "lackCredits"])); } + if (!data) { return msg.sendLocale("DATACHECK_NOACCOUNT"); } + if (data.credits < bet) { return msg.sendLocale("DATACHECK_LACKCREDIT"); } let rolls = []; for (var z = 0; z < 7; z++) { - var x = (Math.random() > .5) ? "heads" : "tails"; - rolls.push(x); + rolls.push(((Math.random() > .5) ? "heads" : "tails")); } let fact = []; @@ -35,10 +34,10 @@ module.exports = class extends Command { if (result[0] === "won") { this.client.dataManager("update", [`credits=${data.credits + (bet * result[1])}`, msg.author.id], "users"); - msg.channel.send(this.client.speech(msg, ["twoup", "win"], [["-result", rolls.join(", ")], ["-earnings", bet]])); + return msg.sendLocale("TWOUP_SUCCESS", [msg, rolls.join(", "), bet]); } - this.client.dataManager("update", [`credits=${data.credits - bet}`, msg.author.id], "users"); - msg.channel.send(this.client.speech(msg, ["twoup", "lose"], [["-result", rolls.join(", ")], ["-earnings", bet]])); + this.client.dataManager("update", [`credits=${data.credits - bet}`, msg.author.id], "users"); + msg.sendLocale("TWOUP_LOSS", [msg, rolls.join(", "), bet]); } }; \ No newline at end of file diff --git a/languages/en-CA.js b/languages/en-CA.js index 1e7f987..48fc32a 100644 --- a/languages/en-CA.js +++ b/languages/en-CA.js @@ -234,6 +234,16 @@ module.exports = class extends Language { REVOKE_STOPPED: (msg) => this.client.speech(msg, ["revoke", "stopped"]), REVOKE_TIMEOUT: (msg) => this.client.speech(msg, ["revoke", "timeout"]), REVOKE_SUCCESS: (msg) => this.client.speech(msg, ["revoke", "success"]), + + /* + * Commands - Economy => Games + */ + TWOUP_SUCCESS: (msg, result, bet) => this.client.speech(msg, ["twoup", "win"], [["-result", result], ["-earnings", bet]]), + TWOUP_LOSS: (msg, result, bet) => this.client.speech(msg, ["twoup", "lose"], [["-result", result], ["-earnings", bet]]), + COIN_SUCCESS: (msg, result, bet) => this.client.speech(msg, ["coin", "win"], [["-result", result], ["-earning", bet]]), + COIN_LOSS: (msg, result, bet) => this.client.speech(msg, ["coin", "lose"], [["-result", result], ["-earning", bet]]), + CHOUHAN_SUCCESS: (msg, sum, guess, bet) => this.client.speech(msg, ["chouhan", "win"], [["-sum", sum], ["-guess", guess], ["-earning", (bet * 2)]]), + CHOUHAN_LOSS: (msg, sum, guess, bet) => this.client.speech(msg, ["chouhan", "lose"], [["-sum", sum], ["-guess", guess], ["-earning", bet]]), }; } }; \ No newline at end of file From cdf1c48fff010034e09230de4ebc1d7ad0cf26d5 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Sun, 17 May 2020 04:10:08 -0400 Subject: [PATCH 3/6] Customized Daily Amounts + Fixes - Fixed an issue with the report command not sending the embeds to the channel - Moved a lot of values set in settings.json into a client schema. These are also configurable via commands. - Removed a large amount of the ownerSettings in favour of the client schema settings. - Daily command can now give different amounts set by the owner. - Rewrote more speech modules --- assets/settingsExample.json | 12 --- assets/speech/en-CA/fun.js | 155 ++++++++++++++++++---------------- assets/speech/en-CA/mod.js | 60 +++++++------ assets/speech/en-CA/system.js | 6 +- commands/Economy/daily.js | 11 +-- commands/Owner/setChannel.js | 26 ++++++ commands/Owner/setDaily.js | 22 +++++ commands/System/report.js | 6 +- index.js | 11 +-- languages/en-CA.js | 22 ++++- package-lock.json | 12 +-- package.json | 4 +- utilities/dataManager.js | 4 +- utilities/schemaManager.js | 19 ++++- utilities/utilExport.js | 19 ++--- 15 files changed, 238 insertions(+), 151 deletions(-) create mode 100644 commands/Owner/setChannel.js create mode 100644 commands/Owner/setDaily.js diff --git a/assets/settingsExample.json b/assets/settingsExample.json index 51ee809..8eab7ce 100644 --- a/assets/settingsExample.json +++ b/assets/settingsExample.json @@ -5,17 +5,5 @@ "version": "Release 1.2.2", "releaseDate": "May 7th, 2020" }, - "owner": { - "channels": { - "award": "Channel ID", - "report": "Channel ID" - }, - "awards": { - "suggest": 250, - "bug": 500, - "minor": 600, - "major": 2000 - } - }, "database": "./assets/MargarineData.sqlite" } \ No newline at end of file diff --git a/assets/speech/en-CA/fun.js b/assets/speech/en-CA/fun.js index 1ef9d12..b72d15c 100644 --- a/assets/speech/en-CA/fun.js +++ b/assets/speech/en-CA/fun.js @@ -1,75 +1,88 @@ -exports.roll = { - "zero": [ - "You can't roll from 0!", - "A die with 0 sides? You got to be joking.", - "Rolling a die is like dividing... you can't have zero in certain places!" - ], - "negative": [ - "You can't roll a negative number, baka!", - "You need a positive number! A negative sided die is impossible!" - ], - "success": [ - "🎲 You rolled a -value! 🎲", - "You've rolled -value! 🎲", - "🎲 Ah ha! You've rolled a -value!" - ] -}; +/* + * Speech for all commands in the fun module + */ -exports.rps = { - "sameUser": [ - "Hey! You can't play rock, paper, scissors with yourself! Invite someone into the mix or play with me instead!", - "You can't play rock, paper, scissors by yourself! At least invite me to play!" +module.exports = { + "roll": { + "zero": [ + "You can't roll from 0!", + "A die with 0 sides? You got to be joking.", + "Rolling a die is like dividing... you can't have zero in certain places!" + ], + "negative": [ + "You can't roll a negative number, baka!", + "You need a positive number! A negative sided die is impossible!" + ], + "success": [ + "🎲 You rolled a -value! 🎲", + "You've rolled -value! 🎲", + "🎲 Ah ha! You've rolled a -value!" + ] + }, + "rps": { + "sameUser": [ + "Hey! You can't play rock, paper, scissors with yourself! Invite someone into the mix or play with me instead!", + "You can't play rock, paper, scissors by yourself! At least invite me to play!" + ], + "success": [ + "-user1 plays -hand1! -user2 plays -hand2! **-result!**" + ] + }, + "poll": { + "noQuestion": [ + "You need to provide a question!", + "There's no question here!" + ], + "noChoice": [ + "You'll need more options than that!", + "You need to provide at least two options!" + ], + "maxChoice": [ + "That's a really large list you got there. Shrink it a bit and come back.", + "Whoa! You have a giant list of options! Not even I can handle all of these!" + ], + "created": [ + "Okay! Your poll is up and ready for voting!", + "Let the polling begin!" + ], + "voted": [ + "I have recieved your vote for -option. You're all set", + "Okay! You've voted for -option." + ], + "noPoll": [ + "It doesn't look like there's a poll going on at the moment. Make one and come back.", + "No one is polling opinions at the moment." + ] + }, + "say": [ + "You need to provide me with a message!", + "I need a message to echo before I can do this!" ], - "success": [ - "-user1 plays -hand1! -user2 plays -hand2! **-result!**" - ] -}; - -exports.poll = { - "noQuestion": [ - "You need to provide a question!", - "There's no question here!" + "eightball": [ + "It is certain, -user", + "As I see it, yes, -user", + "It's looking a bit hazy. Try again", + "Don't count on it, -user", + "It is decidedly so, -user", + "Most likely.", + "Ask again later, -user. You may have better luck.", + "Reply sent.... no", + "Without a doubt, -user!", + "Outlook is good", + "Better to leave you wondering, -user", + "Sources say no.", + "Yes! Most definitely!", + "Yes.", + "Seems my prediction powers are weak at the moment. Try again later.", + "Outlook is not so good, -user.", + "The stars say yes, -user.", + "You may rely on it.", + "FOCUS! Concentrate your mindset and ask again.", + "Very doubtful, -user" ], - "noChoice": [ - "You'll need more options than that!", - "You need to provide at least two options!" - ], - "maxChoice": [ - "That's a really large list you got there. Shrink it a bit and come back.", - "Whoa! You have a giant list of options! Not even I can handle all of these!" + "crash": [ + "Wow. That's awful of you, -user. I'm just here trying to be helpful and make friends but you want to shut me down. Quite rude!", + "Ouch! Am I not doing a good enough job for you? BAKA!", + "-user! So mean! I'm just trying to have fun here!" ] -}; - -exports.say = [ - "You need to provide me with a message!", - "I need a message to echo before I can do this!" -]; - -exports.eightball = [ - "It is certain, -user", - "As I see it, yes, -user", - "It's looking a bit hazy. Try again", - "Don't count on it, -user", - "It is decidedly so, -user", - "Most likely.", - "Ask again later, -user. You may have better luck.", - "Reply sent.... no", - "Without a doubt, -user!", - "Outlook is good", - "Better to leave you wondering, -user", - "Sources say no.", - "Yes! Most definitely!", - "Yes.", - "Seems my prediction powers are weak at the moment. Try again later.", - "Outlook is not so good, -user.", - "The stars say yes, -user.", - "You may rely on it.", - "FOCUS! Concentrate your mindset and ask again.", - "Very doubtful, -user" -]; - -exports.crash = [ - "Wow. That's awful of you, -user. I'm just here trying to be helpful and make friends but you want to shut me down. Quite rude!", - "Ouch! Am I not doing a good enough job for you? BAKA!", - "-user! So mean! I'm just trying to have fun here!" -]; \ No newline at end of file +}; \ No newline at end of file diff --git a/assets/speech/en-CA/mod.js b/assets/speech/en-CA/mod.js index b53fb89..bd73d94 100644 --- a/assets/speech/en-CA/mod.js +++ b/assets/speech/en-CA/mod.js @@ -1,29 +1,35 @@ -exports.kick = []; //Placeholder -exports.ban = []; //Placeholder +/* + * Speech for all moderator commands + */ -exports.mute = { - "noRole": [ - "Your server does not have a mute role set up!" - ], - "admin": [ - "I guess you can... they are an admin so this won't be effective at all..." - ], - "rolePos": [ - "I can't do this! The role is too high for me to access!" - ], - "unmuted": [ - "-user has been unmuted!" - ], - "muted": [ - "-user has been muted!" - ] -}; - -exports.purge = { - "badCount": [ //Count is not between 2 and 99 - "You didn't give me an amount between 2 and 99 to delete!" - ], - "success": [ - "Purged -amount messages -userfrom the channel." - ] +module.exports = { + "kick": null, //Placeholder + "ban": null, //Placeholder + "mute": { + "noRole": [ + "Your server does not have a mute role set up!" + ], + "admin": [ + "I guess you can... they are an admin so this won't be effective at all..." + ], + "rolePos": [ + "I can't do this! The role is too high for me to access!" + ], + "unmuted": [ + "-user has been unmuted!", + "Speak -user! You have been unmuted." + ], + "muted": [ + "-user has been muted!", + "There shall be silence! -user has been muted." + ] + }, + "purge": { + "badCount": [ //Count is not between 2 and 99 + "You didn't give me an amount between 2 and 99 to delete!" + ], + "success": [ + "Purged -amount messages -userfrom the channel." + ] + } }; \ No newline at end of file diff --git a/assets/speech/en-CA/system.js b/assets/speech/en-CA/system.js index a343f91..2aedd8e 100644 --- a/assets/speech/en-CA/system.js +++ b/assets/speech/en-CA/system.js @@ -31,7 +31,11 @@ module.exports = { "It seems you have timed out with making a report. When you are ready, feel free to try again!", "Looks like the time ran out! Take a moment to prepare yourself and then contact me when ready." ] - } + }, + "noChannel": [ + "Huh, it looks like the owner hasn't setup a report channel to recieve feedback.", + "There's no report channel to send your feedback to... looks like the owner doesn't want any feedback." + ] }, "award": { "noType": [ //User does not provide an award type. diff --git a/commands/Economy/daily.js b/commands/Economy/daily.js index 3cddab9..9ab9a9b 100644 --- a/commands/Economy/daily.js +++ b/commands/Economy/daily.js @@ -16,6 +16,7 @@ module.exports = class extends Command { async run(msg, [user]) { var data = this.client.dataManager("select", msg.author.id, "users"); if (!data && user.id !== msg.author.id) { return msg.sendLocale("DATACHECK_NOACCOUNT"); } + var dailyAmt = this.client.settings.get("daily"); if (!data) { if (this.client.settings.usedDaily.has(msg.author.id)) { //Check if user has recently deleted their own data. @@ -27,8 +28,8 @@ module.exports = class extends Command { this.client.settings.usedDaily.delete(msg.author.id); } - this.client.dataManager("add", msg.author.id); - return msg.sendLocale("DAILY_SELF", [msg]); + this.client.dataManager("add", [msg.author.id, dailyAmt]); + return msg.sendLocale("DAILY_SELF", [msg, dailyAmt]); } var cooldown = JSON.parse(data.cooldowns); @@ -37,7 +38,7 @@ module.exports = class extends Command { if (user.id === msg.author.id) { cooldown.credit = Date.now(); - this.client.dataManager("update", [`credits=${(data.credits + 100)}, cooldowns='${JSON.stringify(cooldown)}'`, msg.author.id], "users"); + this.client.dataManager("update", [`credits=${(data.credits + dailyAmt)}, cooldowns='${JSON.stringify(cooldown)}'`, msg.author.id], "users"); return msg.sendLocale("DAILY_SELF", [msg]); } @@ -46,9 +47,9 @@ module.exports = class extends Command { cooldown.credit = Date.now(); - this.client.dataManager("update", [`credits=${(tarData.credits + 100)}`, user.id], "users"); + this.client.dataManager("update", [`credits=${(tarData.credits + dailyAmt)}`, user.id], "users"); this.client.dataManager("update", [`cooldowns='${JSON.stringify(cooldown)}'`, msg.author.id], "users"); - msg.sendLocale("DAILY_SUCCESS", [msg, user.username, 100]); + msg.sendLocale("DAILY_SUCCESS", [msg, user.username, dailyAmt]); } }; \ No newline at end of file diff --git a/commands/Owner/setChannel.js b/commands/Owner/setChannel.js new file mode 100644 index 0000000..2df7bc5 --- /dev/null +++ b/commands/Owner/setChannel.js @@ -0,0 +1,26 @@ +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "setchannel", + enabled: true, + runIn: ["text", "dm"], + permissionLevel: 10, + description: "Set the award or report channels.", + usage: " " + }); + + this.humanUse = " "; + } + + async run(msg, [type, channel]) { + var channelType; + + if (type === "award") { channelType = "awardChannel"; } + else { channelType = "reportChannel"; } + + this.client.settings.update(channelType, channel); + msg.sendLocale("CHANNEL_UPDATE", [channelType, channel.name]); + } +}; \ No newline at end of file diff --git a/commands/Owner/setDaily.js b/commands/Owner/setDaily.js new file mode 100644 index 0000000..57d4e56 --- /dev/null +++ b/commands/Owner/setDaily.js @@ -0,0 +1,22 @@ +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "setdaily", + enabled: true, + runIn: ["text", "dm"], + permissionLevel: 9, + description: "Set the amount each user should earn with the daily command.", + usage: "" + }); + + this.humanUse = ""; + } + + async run(msg, [amount]) { + this.client.settings.update("daily", amount); + + msg.sendLocale("DAILY_UPDATE", [amount]); + } +}; \ No newline at end of file diff --git a/commands/System/report.js b/commands/System/report.js index 8e33e79..f730e4c 100644 --- a/commands/System/report.js +++ b/commands/System/report.js @@ -24,6 +24,8 @@ module.exports = class extends Command { const filter = m => Object.keys(reportTypes).includes(m.content.toLowerCase()); + if (!this.client.settings.reportChannel) { return msg.sendLocale("REPORT_NOCHANNEL"); } + await msg.reply(this.client.speech(msg, ["report", "start"])); await msg.author.send(this.client.speech(msg, ["report", "q1"])).then(() => { msg.author.dmChannel.awaitMessages(filter, { max: 1, time: 160000, errors: ["time"], }).then((collected) => { @@ -47,8 +49,8 @@ module.exports = class extends Command { .setTimestamp() .setDescription(`**Report number:** ${reportNumber} \n**Issue:** ${desc.first().content} \nYour report has been sent! Any more questions, please ask ${this.client.owner.tag}!`); - - this.client.channels.get(this.client.ownerSetting.get("channels").report).send(embed); + + this.client.channels.cache.get(this.client.settings.reportChannel).send(embed); msg.author.send({embed: DMembed}); this.client.dataManager("update", [`count=${reportNumber}`, "report"], "stats"); }).catch(() => { msg.author.send(this.client.speech(msg, ["report", "timeout", "t2"])); }); diff --git a/index.js b/index.js index 954cfb3..3dee297 100644 --- a/index.js +++ b/index.js @@ -32,16 +32,7 @@ if (!existsSync(config.database)) { dataManager("init"); } //Init the SQLite Dat client.ownerSetting = new Collection(); client.music = new Collection(); -var keys = Object.keys(config); -for (var x = 0; keys.length > x; x++) { - switch (keys[x]) { - case "owner": - var key = Object.keys(config.owner); - for (var y = 0; key.length > y; y++) { client.ownerSetting.set(key[y], config.owner[key[y]]); } break; - case "build": client.ownerSetting.set("build", config.build); break; - } -} - +client.ownerSetting.set("build", config.build); client.ownerSetting.set("globalPrefix", config.prefix); client.itemData = require("./assets/items.json"); diff --git a/languages/en-CA.js b/languages/en-CA.js index 48fc32a..c480e1c 100644 --- a/languages/en-CA.js +++ b/languages/en-CA.js @@ -171,6 +171,10 @@ module.exports = class extends Language { DATACHECK_LACKCREDIT: this.client.speech(falseMsg, ["func-dataCheck", "lackCredits"]), DATACHECK_SAMEUSER: this.client.speech(falseMsg, ["func-dataCheck", "sameUser"]), DATACHECK_COOLDOWN: this.client.speech(falseMsg, ["func-dataCheck", "cooldown"]), + MUSICCHECK_USERNOVC: this.client.speech(falseMsg, ["func-music", "general", "userVC"]), + MUSICCHECK_NOQUEUE: this.client.speech(falseMsg, ["func-music", "general", "noQueue"]), + MUSICCHECK_MISMATCHVC: this.client.speech(falseMsg, ["func-music", "general", "mismatch"]), + MUSICCHECK_NOHANDLER: this.client.speech(falseMsg, ["func-music", "general", "noHandler"]), /* * Commands - Config @@ -221,12 +225,15 @@ module.exports = class extends Language { */ ROLL_NOZERO: (msg) => this.client.speech(msg, ["roll", "zero"]), ROLL_NONEGATIVE: (msg) => this.client.speech(msg, ["roll", "negative"]), - ROLL_SUCCESS: (msg, value) => this.client.speech(msg, ["roll", "success"]).replace("-value", value), + ROLL_SUCCESS: (msg, value) => this.client.speech(msg, ["roll", "success"], [["-value", value]]), + POLL_CREATED: (msg) => this.client.speech(msg, ["poll", "created"]), + POLL_VOTED: (msg, option) => this.client.speech(msg, ["poll", "voted"], [["-option", option]]), + POLL_NOPOLL: (msg) => this.client.speech(msg, ["poll", "noPoll"]), /* * Commands - Economy */ - DAILY_SELF: (msg) => this.client.speech(msg, ["daily", "self"]), + DAILY_SELF: (msg, amount) => this.client.speech(msg, ["daily", "self"], [["-credit", amount]]), DAILY_SUCCESS: (msg, target, amount) => this.client.speech(msg, ["daily", "other"], [["-user", target], ["-credit", amount]]), EXCHANGE: (msg, author, target, credit) => this.client.speech(msg, ["exchange"], [["-user1", author], ["-user2", target], ["-credit", credit]]), REP: (msg, target) => this.client.speech(msg, ["rep"], [["-mention", target]]), @@ -244,6 +251,17 @@ module.exports = class extends Language { COIN_LOSS: (msg, result, bet) => this.client.speech(msg, ["coin", "lose"], [["-result", result], ["-earning", bet]]), CHOUHAN_SUCCESS: (msg, sum, guess, bet) => this.client.speech(msg, ["chouhan", "win"], [["-sum", sum], ["-guess", guess], ["-earning", (bet * 2)]]), CHOUHAN_LOSS: (msg, sum, guess, bet) => this.client.speech(msg, ["chouhan", "lose"], [["-sum", sum], ["-guess", guess], ["-earning", bet]]), + + /* + * Commands - Owner + */ + CHANNEL_UPDATE: (type, channel) => this.client.speech(falseMsg, ["func-owner", "setchannel"], [["-target", type], ["-channel", channel]]), + DAILY_UPDATE: (amount) => this.client.speech(falseMsg, ["func-owner", "setdaily"], [["-amount", amount]]), + + /* + * Commands - System + */ + REPORT_NOCHANNEL: this.client.speech(falseMsg, ["func-system", "report", "noChannel"]), }; } }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 37e4745..66c9300 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1400,18 +1400,18 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" }, "youtube-playlist": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/youtube-playlist/-/youtube-playlist-1.0.2.tgz", - "integrity": "sha512-2NpfFqBGUYBl085kcGNctiEd6vRMXRPGHwzcFTsaEap63zUiEmmHpP6StNFu4DGnuEOfn46gt3yNXm0r8K6xvg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/youtube-playlist/-/youtube-playlist-1.0.3.tgz", + "integrity": "sha512-ivNL/OXv7mnCHbxlSk5yybwhKIWeMSUHdkMZJIxntTilhXMg8YzSF0vWIjcDXZj5ZG962EH2TlbMQe49Szx7Vw==", "requires": { "cheerio": "^1.0.0-rc.2", "got": "^6.3.0" } }, "ytdl-core": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-2.1.0.tgz", - "integrity": "sha512-UmblkTLSV0v3y9I3oqrZkllyT0FnK1Owm7WftEkcTIlqnjip1mnyaLICz0P6+W3Ji/AtBFSwy/mLG2dlEvP6Vw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-2.1.2.tgz", + "integrity": "sha512-/tOT9Pka6nX+LuvzNLBU8AbVHe8XELn3aZ69mvCxzvwO/ty9k8cRvF6jXqti7l5M+0hf+UPpP9jYPSAFAuoBUA==", "requires": { "html-entities": "^1.3.1", "m3u8stream": "^0.6.3", diff --git a/package.json b/package.json index 431d569..327aa36 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "querystring": "^0.2.0", "request": "^2.88.2", "snekfetch": "^4.0.4", - "youtube-playlist": "^1.0.2", - "ytdl-core": "^2.1.0" + "youtube-playlist": "^1.0.3", + "ytdl-core": "^2.1.2" }, "devDependencies": {}, "repository": { diff --git a/utilities/dataManager.js b/utilities/dataManager.js index c96f55f..5ab7ed2 100644 --- a/utilities/dataManager.js +++ b/utilities/dataManager.js @@ -30,10 +30,10 @@ module.exports = function dataManager(args, values, table) { db.prepare("CREATE TABLE product (userID TEXT, recycle INTEGER, fishcake INTEGER, cookie INTEGER, oden INTEGER, sushi INTEGER, sake INTEGER)").run(); return; case "add": - var data = db.prepare("SELECT * FROM users WHERE userID=?").get(values); + var data = db.prepare("SELECT * FROM users WHERE userID=?").get(values[0]); if (data) { return console.log("ERROR: This user already exists"); } - db.prepare("INSERT INTO users (userID, credits, rep, cooldowns, profiles) VALUES (?, ?, ?, ?, ?)").run(values, 100, 0, JSON.stringify({ credit: Date.now(), rep: null }), JSON.stringify({ Anilist: "", MAL: "" })); + db.prepare("INSERT INTO users (userID, credits, rep, cooldowns, profiles) VALUES (?, ?, ?, ?, ?)").run(values[0], values[1], 0, JSON.stringify({ credit: Date.now(), rep: null }), JSON.stringify({ Anilist: "", MAL: "" })); db.prepare("INSERT INTO awards (userID) VALUES (?)").run(values); db.prepare("INSERT INTO fishing (userID) VALUES (?)").run(values); diff --git a/utilities/schemaManager.js b/utilities/schemaManager.js index c1f5e6a..7746439 100644 --- a/utilities/schemaManager.js +++ b/utilities/schemaManager.js @@ -3,7 +3,18 @@ * @param { KlasaClient } client - The bot instance of the client. */ module.exports = function(client) { - client.gateways.guilds.schema //Add all configurable settings + client.gateways.clientStorage.schema //Global Configurations + .add("daily", "Integer", { default: 100, min: 1 }) + .add("awardChannel", "channel") + .add("reportChannel", "channel") + .add("awards", folder => folder + .add("suggest", "Integer", { default: 250, min: 10 }) //Suggestion Added + .add("bug", "Integer", { default: 500, min: 25 }) //Bug fixed + .add("minor", "Integer", { default: 600, min: 50 }) //Minor issue resolved + .add("major", "Integer", { default: 2000, min: 100 }) //Major issue resolved + ); + + client.gateways.guilds.schema //Guild-specific Configurations .add("modRole", "role") .add("muteRole", "role") .add("defaultChannel", "channel") @@ -18,5 +29,11 @@ module.exports = function(client) { .add("roles", folder => folder .add("name", "string", { array: true, configurable: false }) //Linked with id. Indexes are linked as a sudo-relation .add("id", "string", { array: true, configurable: false }) + ) + .add("poll", folder => folder + .add("info", "string", { configurable: false }) + .add("options", "string", { array: true, configurable: false }) + .add("votes", "string", { configurable: false }) + .add("userVotes", "string", { default: "{}", configurable: false }) ); }; \ No newline at end of file diff --git a/utilities/utilExport.js b/utilities/utilExport.js index 7c61d2d..14fcd43 100644 --- a/utilities/utilExport.js +++ b/utilities/utilExport.js @@ -32,7 +32,7 @@ exports.envCheck = function() { if (djsVersion !== "12.2.0") { missingDep.push("You are not using the right discord.js package! Required version: v12.2.0"); } if (kVersion !== "0.5.0-dev") { missingDep.push("You are not using the right Klasa version! Required version: v0.5.0-dev"); } - if (nVersion < 10.0) { missingDep.push("You are not using the right node.js version! Required version: v10.0.0+"); } + if (nVersion < 12.0) { missingDep.push("You are not using the right node.js version! Required version: v12.0.0+"); } if (missingDep.length > 0) { console.log(missingDep.join("\n")); process.exit(); } }; @@ -43,8 +43,8 @@ exports.util = { modEmbed: require("./modEmbed.js"), /** * Returns the best matching channel for channel messages. - * @param { KlasaGuild } guild - Required. Needed to search for the channel and settings. - * @param { String } args - Defaults to "default". Takes either "default" or "mod" depending on the action needed. + * @param { KlasaGuild } guild - Needed to search for the channel and settings. + * @param { String } [args] - Defaults to "default". Takes either "default" or "mod" depending on the action needed. * @returns { KlasaChannel } Returns a channel that best fits the arguements given. */ defaultChannel: (guild, args="default") => { @@ -68,25 +68,24 @@ exports.util = { }, /** * Goes over all common checks to ensure the user is able to interact with a music command - * @param { KlasaMessage } msg - Required + * @param { KlasaMessage } msg * @param { String } tag - A tag for specific cases such as the join command. * @returns { Boolean | Object } Returns true if passed and false if failed. If tag is not join, will return the music instance. */ musicCheck: (msg, tag) => { - var client = msg.client; if (!msg.member.voice.channelID) { - msg.channel.send(client.speech(msg, ["func-music", "general", "userVC"])); + msg.sendLocale("MUSICCHECK_USERNOVC"); return false; } else if (tag !== "join") { - var handler = client.music.get(msg.guild.id); + var handler = msg.client.music.get(msg.guild.id); if (!handler) { - msg.channel.send(client.speech(msg, ["func-music", "general", "noQueue"])); + msg.sendLocale("MUSICCHECK_NOQUEUE"); return false; } else if (msg.member.voice.channelID !== handler.channel.id) { - msg.channel.send(client.speech(msg, ["func-music", "general", "mismatch"])); + msg.sendLocale("MUSICCHECK_MISMATCHVC"); return false; } else if (tag === "handler" && !handler.dispatcher) { - msg.channel.send(client.speech(msg, ["func-music", "general", "noHandler"])); + msg.sendLocale("MUSICCHECK_NOHANDLER"); } return handler; From e93efd187135c692bcf27d213bef20f2192690e8 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Sun, 17 May 2020 16:32:49 -0400 Subject: [PATCH 4/6] New product + A bit of cleanup - Added a new craftable food: pancake - Cleaned up a bit of the speech and checks with some of the commands --- assets/items.json | 11 +++++ assets/speech/en-CA/cooking.js | 86 ++++++++++++++++++---------------- assets/speech/en-CA/economy.js | 12 +++-- assets/speech/en-CA/fun.js | 22 +++------ assets/speech/en-CA/games.js | 59 +++++++++++++---------- assets/speech/en-CA/mod.js | 18 ++++--- assets/speech/en-CA/owner.js | 17 +++++++ commands/Fun/roll.js | 5 +- commands/General/avatar.js | 2 + commands/General/award.js | 2 +- commands/Mod/ban.js | 2 + commands/Mod/kick.js | 2 + commands/Mod/mute.js | 2 + commands/Mod/purge.js | 11 +++-- commands/Owner/giveAward.js | 6 +-- commands/System/invite.js | 5 +- commands/System/permlevel.js | 4 +- events/guildCreate.js | 4 -- events/starboardAdd.js | 4 +- languages/en-CA.js | 9 ++-- utilities/dataManager.js | 2 +- 21 files changed, 157 insertions(+), 128 deletions(-) create mode 100644 assets/speech/en-CA/owner.js diff --git a/assets/items.json b/assets/items.json index 322fa6e..e8116be 100644 --- a/assets/items.json +++ b/assets/items.json @@ -119,6 +119,17 @@ ["chocolate", 2] ] }, + "pancake": { + "sell": 30, + "name": "pancake", + "emote": "πŸ₯ž", + "category": "product", + "subcategory": "food", + "recipe": [ + ["egg", 2], + ["bread", 2] + ] + }, "oden": { "sell": 125, "name": "oden", diff --git a/assets/speech/en-CA/cooking.js b/assets/speech/en-CA/cooking.js index df2feb1..994bd37 100644 --- a/assets/speech/en-CA/cooking.js +++ b/assets/speech/en-CA/cooking.js @@ -1,45 +1,49 @@ -/* Speech for cooking specific commands */ +/* + * Speech for cooking specific commands + */ -exports.craft = { - "noRecipe": [ - "I couldn't find a recipe like that!" +module.exports = { + "craft": { + "noRecipe": [ + "I couldn't find a recipe like that!", + "There's no recipe like that!" + ], + "success": [ + "Oh! You've crafted -amount of -item!", + "Success! You've crafted -amount of -item" + ] + }, + "fish": [ + "Nice catch! You just caught yourself -kind and placed it in your inventory.", + "Looks like you'll be dining on -kind tonight. You place it in your inventory.", + "You have caught -kind! You placed it in your inventory.", + "Oh! A -kind. Looks like that's a winner. You have placed it in your inventory." ], - "success": [ - "Oh! You've crafted -amount of -item!" - ] -}; - -exports.fish = [ - "Nice catch! You just caught yourself -kind and placed it in your inventory.", - "Looks like you'll be dining on -kind tonight. You place it in your inventory.", - "You have caught -kind! You placed it in your inventory.", - "Oh! A -kind. Looks like that's a winner. You have placed it in your inventory." -]; - -exports.harvest = { - "noRow": [ - "You should redeem your first daily. Then, you can harvest all you like." - ], - "noCredits": [ - "Hmm... you seem to be lacking in credits. Find some and come back." - ], - "success": [ - "You found a -kind. You placed it in your inventory", - "That looks like a fine -kind. You placed it in your inventory.", - "A -kind! You could make a good meal out of that one. You placed it in your inventory." - ] -}; - -exports.inventory = [ //No account. Seperate from dataCheck since no credits are needed - "Doesn't look like you've redeemed your first daily yet. Do that and then you'll have an inventory to look at!", - "You don't have an inventory yet. Redeem your first daily to get one!" -]; - -exports.sell = { - "notEnough": [ - "You don't have enough of this to sell!" + "harvest": { + "noRow": [ + "You should redeem your first daily. Then, you can harvest all you like." + ], + "noCredits": [ + "Hmm... you seem to be lacking in credits. Find some and come back." + ], + "success": [ + "You found a -kind. You placed it in your inventory", + "That looks like a fine -kind. You placed it in your inventory.", + "A -kind! You could make a good meal out of that one. You placed it in your inventory." + ] + }, + "inventory": [ //No account. Seperate from dataCheck since no credits are needed + "Doesn't look like you've redeemed your first daily yet. Do that and then you'll have an inventory to look at!", + "You don't have an inventory yet. Redeem your first daily to get one!" ], - "success": [ - "Success! You've sold -amount of -item for -price!" - ] + "sell": { + "notEnough": [ + "You don't have enough of this to sell!", + "That's more than you have! You can't sell this much." + ], + "success": [ + "Success! You've sold -amount of -item for -price!", + "Okay! You've earned -price for selling -amount of -item" + ] + } }; \ No newline at end of file diff --git a/assets/speech/en-CA/economy.js b/assets/speech/en-CA/economy.js index 2a9585a..8304984 100644 --- a/assets/speech/en-CA/economy.js +++ b/assets/speech/en-CA/economy.js @@ -6,11 +6,12 @@ module.exports = { "balance": null, //Placeholder "daily": { "self": [ - "You have redeemed 100 credits!", - "Poof! You are 100 credits richer now!", - "Don't go gambling your 100 credits all in one place now.", + "You have redeemed -credit credits!", + "Poof! You are -credit credits richer now!", + "Don't go gambling your -credit credits all in one place now.", "You have redeemed your daily credits. Come back tomorrow at the same time for more!", - "You should buy me a game with those credits. I won't take all 100 on you, I swear." + "You should buy me a game with those credits. I won't take all -credit on you, I swear.", + "Nice! Now you'll be able to buy me a game with those credits! Don't worry, I won't take all -credit on you." ], "other": [ "Oh? Feeling generous are we? You have given -user -credit credits!", @@ -26,7 +27,8 @@ module.exports = { ], "rep": [ "You have given -mention a reputation point!", - "One new, shiny reputation point for -mention has been given!" + "One new, shiny reputation point for -mention has been given!", + "-mention has been awarded a reputation point!" ], "revoke": { "prompt": [ diff --git a/assets/speech/en-CA/fun.js b/assets/speech/en-CA/fun.js index b72d15c..ed85191 100644 --- a/assets/speech/en-CA/fun.js +++ b/assets/speech/en-CA/fun.js @@ -3,22 +3,12 @@ */ module.exports = { - "roll": { - "zero": [ - "You can't roll from 0!", - "A die with 0 sides? You got to be joking.", - "Rolling a die is like dividing... you can't have zero in certain places!" - ], - "negative": [ - "You can't roll a negative number, baka!", - "You need a positive number! A negative sided die is impossible!" - ], - "success": [ - "🎲 You rolled a -value! 🎲", - "You've rolled -value! 🎲", - "🎲 Ah ha! You've rolled a -value!" - ] - }, + "roll": [ + "🎲 You rolled a -value! 🎲", + "You've rolled -value! 🎲", + "🎲 Ah ha! You've rolled a -value!", + "BEHOLD! 🎲 You've rolled -value! *Is that a good thing?*" + ], "rps": { "sameUser": [ "Hey! You can't play rock, paper, scissors with yourself! Invite someone into the mix or play with me instead!", diff --git a/assets/speech/en-CA/games.js b/assets/speech/en-CA/games.js index 2697ac2..3fa809f 100644 --- a/assets/speech/en-CA/games.js +++ b/assets/speech/en-CA/games.js @@ -1,28 +1,35 @@ -exports.chouhan = { - "win": [ - "**Sum:** -sum \n**Guess:** -guess \nYou have won -earning credits!" - ], - "lose": [ - "**Sum:** -sum \n**Guess:** -guess \nYou have lost -earning credits." - ] -}; +/* + * Speech for economy type game commands + */ -exports.coin = { - "win": [ - "**-result!** You have won -earning credits!" - ], - "lose": [ - "**-result!** You have lost -earning credits!" - ] -}; - -exports.hazard = []; //Placeholder, not needed at the moment. - -exports.twoup = { - "win": [ - "**Coins:** -result\n You have won -earnings credits!" - ], - "lose": [ - "**Coins:** -result\n You have lost -earnings credits!" - ] +module.exports = { + "chouhan": { + "win": [ + "**Sum:** -sum \n**Guess:** -guess \nYou have won -earning credits!", + "**Sum:** -sum \n**Guess:** -guess \nVictory! You have won -earning credits!" + ], + "lose": [ + "**Sum:** -sum \n**Guess:** -guess \nYou have lost -earning credits.", + "**Sum:** -sum \n**Guess:** -guess \nYou have lost -earning credits. Better luck next time." + ] + }, + "coin": { + "win": [ + "**-result!** You have won -earning credits!", + "**-result!** You got -earning credits for winning." + ], + "lose": [ + "**-result!** You have lost -earning credits!", + "**-result!** You lost -earning credits for losing." + ] + }, + "hazard": null, //Placeholder + "twoup": { + "win": [ + "**Coins:** -result\n You have won -earnings credits!" + ], + "lose": [ + "**Coins:** -result\n You have lost -earnings credits!" + ] + } }; \ No newline at end of file diff --git a/assets/speech/en-CA/mod.js b/assets/speech/en-CA/mod.js index bd73d94..4a0f450 100644 --- a/assets/speech/en-CA/mod.js +++ b/assets/speech/en-CA/mod.js @@ -7,10 +7,12 @@ module.exports = { "ban": null, //Placeholder "mute": { "noRole": [ - "Your server does not have a mute role set up!" + "Your server does not have a mute role set up!", + "There is no mute role set up in this server. I can't mute anyone!" ], "admin": [ - "I guess you can... they are an admin so this won't be effective at all..." + "I guess you can... they are an admin so this won't be effective at all...", + "This won't be effective at all... they are an admin." ], "rolePos": [ "I can't do this! The role is too high for me to access!" @@ -24,12 +26,8 @@ module.exports = { "There shall be silence! -user has been muted." ] }, - "purge": { - "badCount": [ //Count is not between 2 and 99 - "You didn't give me an amount between 2 and 99 to delete!" - ], - "success": [ - "Purged -amount messages -userfrom the channel." - ] - } + "purge": [ + "Purged -amount messages -userfrom the channel.", + "-amount message -userhas been removed from the channel!" + ] }; \ No newline at end of file diff --git a/assets/speech/en-CA/owner.js b/assets/speech/en-CA/owner.js new file mode 100644 index 0000000..b8b1c00 --- /dev/null +++ b/assets/speech/en-CA/owner.js @@ -0,0 +1,17 @@ +/* + * Speech for all owner commands + */ + +module.exports = { + "giveaward": null, + "presence": null, + "setavatar": null, + "setchannel": [ + "-type is now set to -channel", + "From this day forward, -channel will be the new -type!" + ], + "setdaily": [ + "Okay! I've updated the daily amount to -amount.", + "I'll be sure to give out -amount credits now." + ] +}; \ No newline at end of file diff --git a/commands/Fun/roll.js b/commands/Fun/roll.js index d86e463..e75c9f6 100644 --- a/commands/Fun/roll.js +++ b/commands/Fun/roll.js @@ -13,10 +13,7 @@ module.exports = class extends Command { } async run(msg, [sides]) { - if (sides === 0) { return msg.sendLocale("ROLL_NOZERO", [msg]); } - if (sides < 0) { return msg.sendLocale("ROLL_NOZERO", [msg]); } - var value = Math.floor(Math.random() * (Math.floor(sides) - Math.ceil(1) + 1)) + Math.ceil(1); - msg.sendLocale("ROLL_SUCCESS", [msg, value]); + msg.sendLocale("ROLL", [msg, value]); } }; \ No newline at end of file diff --git a/commands/General/avatar.js b/commands/General/avatar.js index 4673f3c..4d38e2c 100644 --- a/commands/General/avatar.js +++ b/commands/General/avatar.js @@ -10,6 +10,8 @@ module.exports = class extends Command { description: "Fetch a user's avatar!", usage: "" }); + + this.humanUse = ""; } async run(msg, [user]) { msg.channel.send("", { files: [user.displayAvatarURL()]}); } diff --git a/commands/General/award.js b/commands/General/award.js index 64e6db2..c6a6017 100644 --- a/commands/General/award.js +++ b/commands/General/award.js @@ -14,7 +14,7 @@ module.exports = class extends Command { async run(msg) { var statData = this.client.dataManager("select", "Overall", "awards"); - var awardAmt = this.client.ownerSetting.get("awards"); + var awardAmt = this.client.settings.get("awards"); var sum = statData.suggest + statData.bug + statData.minor + statData.major; var rewarded = (statData.suggest * awardAmt.suggest) + (statData.bug * awardAmt.bug) + (statData.minor * awardAmt.minor) + (statData.major * awardAmt.major); diff --git a/commands/Mod/ban.js b/commands/Mod/ban.js index b663228..6e9d6a9 100644 --- a/commands/Mod/ban.js +++ b/commands/Mod/ban.js @@ -11,6 +11,8 @@ module.exports = class extends Command { description: "Ban someone.", usage: " ", usageDelim: "," }); + + this.humanUse = "_"; } async run(msg, [user, reason]) { diff --git a/commands/Mod/kick.js b/commands/Mod/kick.js index 48d5acb..999bd34 100644 --- a/commands/Mod/kick.js +++ b/commands/Mod/kick.js @@ -12,6 +12,8 @@ module.exports = class extends Command { description: "Kicks the mentioned user.", usage: " ", usageDelim: "," }); + + this.humanUse = "_" } async run(msg, [user, reason]) { diff --git a/commands/Mod/mute.js b/commands/Mod/mute.js index a532291..8f6ba7d 100644 --- a/commands/Mod/mute.js +++ b/commands/Mod/mute.js @@ -12,6 +12,8 @@ module.exports = class extends Command { extendedHelp: "Requires a server moderator to identify the mute role in the guild configurations first.", usage: " [reason:str]", usageDelim: "," }); + + this.humanUse = "_[reason]"; } async run(msg, [user, reason="No reason given."]) { diff --git a/commands/Mod/purge.js b/commands/Mod/purge.js index 6fc3681..eb82e53 100644 --- a/commands/Mod/purge.js +++ b/commands/Mod/purge.js @@ -10,15 +10,16 @@ module.exports = class extends Command { permissionLevel: 5, cooldown: 30, requiredPermissions: ["MANAGE_MESSAGES"], - description: "Purges X amount of messages from a given channel. Amount will default to 10, if none is given.", - usage: "[amount:int] [user:usersearch]", usageDelim: " ", + description: "Purges X amount of messages from a given channel.", + usage: " [user:usersearch]", usageDelim: " ", extendedHelp: "Due to limitations, purge can only delete between 2 and 99 messages. If you wish to purge more, please wait out the cooldown (30 seconds) and do it again." }); + + this.humanUse = " [user]"; } - async run(msg, [amount=10, user]) { + async run(msg, [amount, user]) { let msgCount = amount + 1; - if (msgCount < 2 || msgCount > 100) { return msg.channel.send(this.client.speech(msg, ["purge", "badCount"])); } let userCheck = msg.content.slice(msg.content.search("purge")).split(this.usageDelim); if (user === null && userCheck[2]) { return; } //User not found. Exit command. @@ -41,7 +42,7 @@ module.exports = class extends Command { } msg.channel.bulkDelete(messages).catch(error => console.log(error.stack)); - msg.channel.send(this.client.speech(msg, ["purge", "success"], [["-amount", amount], ["-user", (extra || "")]])); + msg.channel.send(this.client.speech(msg, ["purge"], [["-amount", amount], ["-user", (extra || "")]])); }); } }; \ No newline at end of file diff --git a/commands/Owner/giveAward.js b/commands/Owner/giveAward.js index a465c21..689a96b 100644 --- a/commands/Owner/giveAward.js +++ b/commands/Owner/giveAward.js @@ -25,10 +25,10 @@ module.exports = class extends Command { var overallData = this.client.dataManager("select", "Overall", "awards"); var userData = this.client.dataManager("select", user.id, "awards"); - if (!userData) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noUser"])); } + if (!userData) { return msg.sendLocale("DATACHECK_NOUSER"); } type = type.toLowerCase(); - const awards = this.client.ownerSetting.get("awards"); + const awards = this.client.settings.get("awards"); this.client.dataManager("update", [`${type}=${overallData[type] + 1}`, "Overall"], "awards"); this.client.dataManager("update", [`${type}=${userData[type] + 1}`, user.id], "awards"); @@ -44,6 +44,6 @@ module.exports = class extends Command { .setFooter(`Awarded to: ${user.tag} (${user.id}) on`, user.displayAvatarURL()); msg.channel.send(this.client.speech(msg, ["func-system", "award", "success"], [["-id", user.id], ["-credit", awards[type]]])); - this.client.channels.get(this.client.ownerSetting.get("channels").award).send({embed}); + this.client.channels.get(this.client.settings.get("awardChannel")).send({embed}); } }; \ No newline at end of file diff --git a/commands/System/invite.js b/commands/System/invite.js index 0c74d59..998ce9c 100644 --- a/commands/System/invite.js +++ b/commands/System/invite.js @@ -10,8 +10,5 @@ module.exports = class extends Command { }); } - async run(msg) { - return msg.send(`My invite link: <${this.client.invite}> - \nThe above invite link is generated requesting the minimum permissions required to run all of my current commands. If there is a command that requires another permission that is not selected, I will let you know so that you can make those changes. :smile:`); - } + async run(msg) { msg.sendLocale("INVITE", [this.client.invite]); } }; \ No newline at end of file diff --git a/commands/System/permlevel.js b/commands/System/permlevel.js index f1da92f..5870f22 100644 --- a/commands/System/permlevel.js +++ b/commands/System/permlevel.js @@ -28,7 +28,7 @@ module.exports = class extends Command { var info = msg.language.get("ADDPERMS")[permLevel]; - return msg.channel.send(`Your permission level is ${msg.language.get("PERMLEVEL")[authorLvl]} ${info}`); + return msg.sendLocale("PERMLEVEL_OWNER", [msg.language.get("PERMLEVEL")[authorLvl], info]); } for (var i = 5; i < 8; i++) { @@ -36,6 +36,6 @@ module.exports = class extends Command { if (check) { permLevel = i; } } - msg.channel.send(`Your permission level is ${msg.language.get("PERMLEVEL")[permLevel]}`); + msg.sendLocale("PERMLEVEL_USER", [msg.language.get("PERMLEVEL")[permLevel]]); } }; \ No newline at end of file diff --git a/events/guildCreate.js b/events/guildCreate.js index a3980bf..f0c8cac 100644 --- a/events/guildCreate.js +++ b/events/guildCreate.js @@ -22,9 +22,5 @@ module.exports = class extends Event { var channel = this.client.util.defaultChannel(guild); await channel.send({ embed }); - - guild.members.fetch(this.client.owner.id).then(data => { - if (data !== null) { channel.send(`Oh! こんにけは <@${this.client.owner.id}>. I'm ready to work here! Watch me excel! :thumbsup:`); } - }); } }; \ No newline at end of file diff --git a/events/starboardAdd.js b/events/starboardAdd.js index c3ec27f..92b1a1f 100644 --- a/events/starboardAdd.js +++ b/events/starboardAdd.js @@ -46,9 +46,9 @@ module.exports = class extends Event { const embed = new MessageEmbed() .setColor(0x04d5fd) - .setDescription("*On " + this.client.util.timekeeper.timeMaker(msg.createdAt) + "*") + .setDescription(`*On ${this.client.util.timekeeper.timeMaker(msg.createdAt)}*`) .setThumbnail(msg.author.displayAvatarURL()) - .setFooter("Count: " + reaction.count) + .setFooter(`Count: ${reaction.count}`) .setAuthor(`${msg.author.tag} posted about...`, null, msg.url) .setTimestamp(); diff --git a/languages/en-CA.js b/languages/en-CA.js index c480e1c..d22f625 100644 --- a/languages/en-CA.js +++ b/languages/en-CA.js @@ -223,9 +223,7 @@ module.exports = class extends Language { /* * Commands - Fun */ - ROLL_NOZERO: (msg) => this.client.speech(msg, ["roll", "zero"]), - ROLL_NONEGATIVE: (msg) => this.client.speech(msg, ["roll", "negative"]), - ROLL_SUCCESS: (msg, value) => this.client.speech(msg, ["roll", "success"], [["-value", value]]), + ROLL: (msg, value) => this.client.speech(msg, ["roll"], [["-value", value]]), POLL_CREATED: (msg) => this.client.speech(msg, ["poll", "created"]), POLL_VOTED: (msg, option) => this.client.speech(msg, ["poll", "voted"], [["-option", option]]), POLL_NOPOLL: (msg) => this.client.speech(msg, ["poll", "noPoll"]), @@ -262,6 +260,9 @@ module.exports = class extends Language { * Commands - System */ REPORT_NOCHANNEL: this.client.speech(falseMsg, ["func-system", "report", "noChannel"]), - }; + INVITE: (invite) => `My invite link: <${invite}> \nThe above invite link is generated requesting the minimum permissions required to run all of my current commands. If there is a command that requires another permission that is not selected, I will let you know so that you can make those changes. :smile:`, + PERMLEVEL_OWNER: (permLvl, info) => `Your permission level is ${permLvl} ${info}`, + PERMLEVEL_USER: (permLvl) => `Your permission level is ${permLvl}`, + }; } }; \ No newline at end of file diff --git a/utilities/dataManager.js b/utilities/dataManager.js index 5ab7ed2..22f42a3 100644 --- a/utilities/dataManager.js +++ b/utilities/dataManager.js @@ -27,7 +27,7 @@ module.exports = function dataManager(args, values, table) { db.prepare("CREATE TABLE fishing (userID TEXT, trash INTEGER, fish INTEGER, crab INTEGER, squid INTEGER, shark INTEGER)").run(); db.prepare("CREATE TABLE harvest (userID TEXT, potato INTEGER, egg INTEGER, bread INTEGER, chocolate INTEGER, greenapple INTEGER, apple INTEGER, lemon INTEGER, rice INTEGER)").run(); - db.prepare("CREATE TABLE product (userID TEXT, recycle INTEGER, fishcake INTEGER, cookie INTEGER, oden INTEGER, sushi INTEGER, sake INTEGER)").run(); + db.prepare("CREATE TABLE product (userID TEXT, recycle INTEGER, fishcake INTEGER, cookie INTEGER, oden INTEGER, sushi INTEGER, sake INTEGER, pancake INTEGER)").run(); return; case "add": var data = db.prepare("SELECT * FROM users WHERE userID=?").get(values[0]); From 4b58d43ed6617028b3b62127c578d05d4fc49093 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Mon, 18 May 2020 21:40:56 -0400 Subject: [PATCH 5/6] Redone Poll Comamnd + Fixes - Rewrote the poll command. Users can now create, vote, and pull up current results via the command. Also added the poll data to be saved in the guild schema for persistant storage during the poll's lifespan - Fixed an issue with the mean scores not displaying in the MAL command - Added a setAward command for the owner to modify how much each award gives out. - ownerSetting no longer exists - Update version numbers, more speech, grammar fixes, etc... --- README.md | 4 +- assets/settingsExample.json | 4 +- assets/speech/en-CA/fun.js | 16 +-- assets/speech/en-CA/owner.js | 9 +- assets/speech/en-CA/system.js | 10 +- commands/Fun/poll.js | 102 ++++++++++++++---- commands/General/award.js | 2 +- commands/General/mal.js | 22 ++-- commands/Mod/kick.js | 2 +- commands/Owner/setAward.js | 21 ++++ commands/Owner/setChannel.js | 2 +- commands/System/about.js | 2 +- index.js | 4 +- languages/en-CA.js | 11 +- package-lock.json | 193 +++++++++++++++++++++------------- package.json | 8 +- utilities/modEmbed.js | 6 +- 17 files changed, 285 insertions(+), 133 deletions(-) create mode 100644 commands/Owner/setAward.js diff --git a/README.md b/README.md index 2dc0175..bfec136 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# MargarineBot - Version: Release 1.2.2 +# MargarineBot - Version: Release 1.3.0 ![License](https://img.shields.io/github/license/Butterstroke/MargarineBot.svg?style=flat-square) ![Support Server](https://discordapp.com/api/guilds/303253034551476225/widget.png) Dependencies @@ -11,7 +11,7 @@ A Discord bot coded in Node.js using the Discord.js Library and the Klasa framew MargarineBot is a multi-purpose Discord bot that ranges in features such as server moderation, to an economy system using a SQLite database, to starboards, and much more. MargarineBot also features highly customizable settings for your guild to personalize and maximize his potential in your server! -Created through part-desire, part-what can I do in Discord, part-I'm going to learn Javascript, and part-it's only midnight thoughts, MargarineBot has been my personal project for several years now. For the amount of time and effort I've spent, I'm quite proud of my work and the functionality I've be able to pull off. Ever since the start of his development, I've recieved plenty of support and can't thank those people enough. As without it, Margarine would never be as big or as good as he is today. So, take a look...get some inspiration...just be sure to enjoy Margarine as much as I do. +Created through part-desire, part-what can I do in Discord, part-I'm going to learn Javascript, and part-it's only midnight thoughts, MargarineBot has been my personal project for several years now. For the amount of time and effort I've spent, I'm quite proud of my work and the functionality I've be able to pull off. Ever since the start of his development, I've recieved plenty of support and can't thank those people enough. As without it, Margarine would never be as big or as good as he is today. So, take a look... get some inspiration... just be sure to enjoy Margarine as much as I do. ### Looking to invite me? You can do so here! However, music is a self-hosted feature and is not present in the bot. diff --git a/assets/settingsExample.json b/assets/settingsExample.json index 8eab7ce..79a3ac4 100644 --- a/assets/settingsExample.json +++ b/assets/settingsExample.json @@ -2,8 +2,8 @@ "token": "Token Key", "prefix": "Prefix", "build": { - "version": "Release 1.2.2", - "releaseDate": "May 7th, 2020" + "version": "Release 1.3.0", + "releaseDate": "May 19th, 2020" }, "database": "./assets/MargarineData.sqlite" } \ No newline at end of file diff --git a/assets/speech/en-CA/fun.js b/assets/speech/en-CA/fun.js index ed85191..213da68 100644 --- a/assets/speech/en-CA/fun.js +++ b/assets/speech/en-CA/fun.js @@ -19,17 +19,21 @@ module.exports = { ] }, "poll": { - "noQuestion": [ - "You need to provide a question!", - "There's no question here!" + "noTitle": [ + "You need to explain what this poll is before starting one!", + "So you want to create a poll but not add in the details? That's not going to happen." + ], + "noDesc": [ + "I recommend explaining your poll before starting one. That way everyone knows what it's for!", + "No description, no poll. Is this just a weeb reference? Yes, but it's true." ], "noChoice": [ "You'll need more options than that!", "You need to provide at least two options!" ], - "maxChoice": [ - "That's a really large list you got there. Shrink it a bit and come back.", - "Whoa! You have a giant list of options! Not even I can handle all of these!" + "noCreate": [ + "Nope! There's already a poll ongoing!", + "You can't have more than one poll at once. Try again once the other one has finished" ], "created": [ "Okay! Your poll is up and ready for voting!", diff --git a/assets/speech/en-CA/owner.js b/assets/speech/en-CA/owner.js index b8b1c00..2b838cd 100644 --- a/assets/speech/en-CA/owner.js +++ b/assets/speech/en-CA/owner.js @@ -5,7 +5,10 @@ module.exports = { "giveaward": null, "presence": null, - "setavatar": null, + "setavatar": [ + "I've updated my avatar image to the one you sent me.", + "Nice! I got a new look to show off!" + ], "setchannel": [ "-type is now set to -channel", "From this day forward, -channel will be the new -type!" @@ -13,5 +16,9 @@ module.exports = { "setdaily": [ "Okay! I've updated the daily amount to -amount.", "I'll be sure to give out -amount credits now." + ], + "setaward": [ + "-type will now be set to -amount.", + "Okay! -type will now be giving out -amount credits." ] }; \ No newline at end of file diff --git a/assets/speech/en-CA/system.js b/assets/speech/en-CA/system.js index 2aedd8e..1401953 100644 --- a/assets/speech/en-CA/system.js +++ b/assets/speech/en-CA/system.js @@ -117,7 +117,15 @@ module.exports = { "-name has to be less than -max.", "That's too high! -name has to be less than -max." ] - } + }, + "channel": [ + "Hold on! -name must be a channel tag or valid channel id!", + "That's not a channel tag or valid channel id, so I can't do anything with this!" + ], + "integer": [ + "-name needs to be an integer. And that doesn't look like one!", + "That doesn't look like an integer. -name needs to be an integer if it's to work!" + ] }, "commandhandler": { "missing": [ diff --git a/commands/Fun/poll.js b/commands/Fun/poll.js index 243fd3c..e8dcc4b 100644 --- a/commands/Fun/poll.js +++ b/commands/Fun/poll.js @@ -1,34 +1,90 @@ -const { Command } = require("klasa"); -const { MessageEmbed } = require("discord.js"); +const { Command, Possible } = require("klasa"); + +function pollDisplay(pollData, ending) { + var title = pollData.info.split("|")[0], + desc = pollData.info.split("|")[1], + votes = JSON.parse(pollData.votes), + optionDisplay = "" + header = `__${title}__\n${desc}\n\n`; + + for (var x = 0; x < pollData.options.length; x++) { + optionDisplay = optionDisplay.concat(`${x + 1}) ${pollData.options[x]}: ${votes[x]}\n`); + } + + if (ending) { header = "The poll has ended!\n" + header; } + + return header + optionDisplay; +}; module.exports = class extends Command { constructor(...args) { super(...args, { name: "poll", runIn: ["text"], - description: "Poll users", - usage: "[question:str] [option:str][...]", usageDelim: ",", - extendedHelp: "Poll between 2 and 8 different options at a time! If more options are needed, consider shrinking the list." + subcommands: true, + description: "Poll users and decide what's the best option!", + usage: " [title:str] [description:str] [options:str][...]", usageDelim: ",", + extendedHelp: "Note: end will bring up the display one more time and then clear the poll." }); + + this.humanUse = "_[title (if new) or option number (if vote)]_[description (new only)]_[...options (new only)]" + } + + async new(msg, [title, desc, ...option]) { + if (!title) { return msg.sendLocale("POLL_NOTITLE", [msg]); } + if (!desc) { return msg.sendLocale("POLL_NODESC", [msg]); } + if (option.length < 2) { return msg.sendLocale("POLL_NOOPTION", [msg]); } + + if (msg.guild.settings.poll.info) { return msg.sendLocale("POLL_NOCREATE", [msg]); } + + var votes = {}; + for (var x = 0; x < option.length; x++) { votes[x.toString()] = 0; } + + msg.guild.settings.update([ + ["poll.info", `${title.trim()}|${desc.trim()}`], + ["poll.options", option], + ["poll.votes", JSON.stringify(votes)] + ]); + + msg.sendLocale("POLL_CREATED", [msg]); } - async run(msg, [question, ...option]) { - var emote = ["βœ…", "❎", "β˜‘", "βœ”", "❌", "βœ–", "β­•", "πŸ”˜"]; - - if (!question) { return msg.channel.send(this.client.speech(msg, ["poll", "noQuestion"])); } - else if (option.length < 2) { return msg.channel.send(this.client.speech(msg, ["poll", "noChoice"])); } - else if (option.length > emote.length) { return msg.channel.send(this.client.speech(msg, ["poll", "maxChoice"])); } - - msg.delete().catch(); - const embed = new MessageEmbed() - .setColor("#FFFFFF") - .setTimestamp() - .setDescription(`A poll has been started by ${msg.author.username}!`) - .addField("Question: ", `${question}`); - - for (var x = 0; x < option.length; x++) { embed.addField(`Option ${x + 1} - ${emote[x]}:`, option[x]); } - - const message = await msg.channel.send({embed}); - for (var x = 0; x < option.length; x++) { message.react(emote[x]); } + async vote(msg, [option]) { + //Can't use integerCheck in the usage alongside title. Run the argument within the vote method instead. + //Method will stop automatically if integerCheck detects a bad number. + option = await this.client.arguments.get("integerCheck").run(option, new Possible([, "option", "integercheck", 1, undefined, undefined]), msg); + option--; //Reduce option by one to work with array index of 0. + + var pollData = msg.guild.settings.poll, + userResults = JSON.parse(pollData.userVotes), + voteTotal = JSON.parse(pollData.votes); + + if (Object.keys(userResults).includes(msg.author.id)) { + var previousVote = userResults[msg.author.id]; + voteTotal[previousVote]--; + } + + userResults[msg.author.id] = option; + voteTotal[option]++; + + msg.guild.settings.update([ + ["poll.votes", JSON.stringify(voteTotal)], + ["poll.userVotes", JSON.stringify(userResults)] + ]); + + msg.sendLocale("POLL_VOTED", [msg, pollData.options[option]]); + } + + async end(msg) { + msg.channel.send(pollDisplay(msg.guild.settings.poll, true)); + msg.guild.settings.reset(["poll.info", "poll.options", "poll.votes", "poll.userVotes"]); + } + + async show(msg) { + var pollData = msg.guild.settings.poll; + //No poll happening + if (!pollData.info) { return msg.sendLocale("POLL_NOPOLL", [msg]); } + + msg.channel.send(pollDisplay(pollData)); } }; \ No newline at end of file diff --git a/commands/General/award.js b/commands/General/award.js index c6a6017..9821858 100644 --- a/commands/General/award.js +++ b/commands/General/award.js @@ -25,7 +25,7 @@ module.exports = class extends Command { .setTitle(`${this.client.user.username}'s Award System`) .setDescription(`${sum} awards given with ${rewarded} credits awarded!`) .setFooter(msg.guild.name, msg.guild.iconURL()) - .addField("Description:", "For those who have a profile with Margarine, users can earn more credits by submitting suggestions, bugs, and issues via the report command. Upon completion/fix, the user is awarded an amount of credits.") + .addField("Description:", "For those who have a profile with Margarine, users can earn more credits by submitting suggestions, bugs, and issues via the report command. Upon completion, the user is awarded an amount of credits.") .addField(`Suggestions (${awardAmt.suggest}):`, statData.suggest, true) .addField(`Bugs (${awardAmt.bug}):`, statData.bug, true) .addField(`Minor Issues (${awardAmt.minor}):`, statData.minor, true) diff --git a/commands/General/mal.js b/commands/General/mal.js index 91c5731..c73a346 100644 --- a/commands/General/mal.js +++ b/commands/General/mal.js @@ -50,7 +50,7 @@ module.exports = class extends Command { request(url, function(err, res, body) { var loadBody = cheerio.load(body); - var text = loadBody.text().split(" "); var x = 0; var info = { aStats: {}, mStats: {} }; + var text = loadBody.text().split(" "); var x = 100; var info = { aStats: {}, mStats: {} }; do { var z = text[x].trim(); var y = text[x + 1] ? text[x + 1].trim() : ""; var zed = text[x + 2] ? text[x + 2].trim() : ""; @@ -87,19 +87,17 @@ module.exports = class extends Command { } } } else if (z === "All" && !info.friends) { info.friends = `πŸ‘« Friends: ${y.slice(1, -8)}`; } - else if (isNaN(y) === false) { - if (z === "Days:") { - if (!info.aStats.days) { info.aStats.days = y; } - else { info.mStats.days = y; } - } - else if (z === "Score:") { - if (!info.aStats.mean) { info.aStats.mean = y; } - else { info.mStats.mean = y; } - } - } } x++; - } while (x < text.length); + } while (!info.mStats.plan); + + var animeStats = loadBody(".anime")[0].children[3]; + info.aStats.days = animeStats.children[1].children[1].data; + info.aStats.mean = animeStats.children[3].children[3].children[0].data; + + var mangaStats = loadBody(".manga")[0].children[3]; + info.mStats.days = mangaStats.children[1].children[1].data; + info.mStats.mean = mangaStats.children[3].children[3].children[0].data; var list = []; if (info.gender) { list.push(info.gender); } diff --git a/commands/Mod/kick.js b/commands/Mod/kick.js index 999bd34..59f5ddd 100644 --- a/commands/Mod/kick.js +++ b/commands/Mod/kick.js @@ -13,7 +13,7 @@ module.exports = class extends Command { usage: " ", usageDelim: "," }); - this.humanUse = "_" + this.humanUse = "_"; } async run(msg, [user, reason]) { diff --git a/commands/Owner/setAward.js b/commands/Owner/setAward.js new file mode 100644 index 0000000..4d29079 --- /dev/null +++ b/commands/Owner/setAward.js @@ -0,0 +1,21 @@ +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "setaward", + enabled: true, + runIn: ["text", "dm"], + permissionLevel: 10, + description: "Sets how much an award gives out for credits", + usage: " ", usageDelim: " " + }); + + this.humanUse = " "; + } + + async run(msg, [type, amount]) { + this.client.settings.update(`awards.${type}`, amount); + msg.sendLocale("AWARD_UPDATE", [type, amount]); + } +}; \ No newline at end of file diff --git a/commands/Owner/setChannel.js b/commands/Owner/setChannel.js index 2df7bc5..6cb1654 100644 --- a/commands/Owner/setChannel.js +++ b/commands/Owner/setChannel.js @@ -8,7 +8,7 @@ module.exports = class extends Command { runIn: ["text", "dm"], permissionLevel: 10, description: "Set the award or report channels.", - usage: " " + usage: " ", usageDelim: " " }); this.humanUse = " "; diff --git a/commands/System/about.js b/commands/System/about.js index 11bf369..8896376 100644 --- a/commands/System/about.js +++ b/commands/System/about.js @@ -25,7 +25,7 @@ module.exports = class extends Command { \n**Name Origin:** Butterstroke#7150's typical nickname is Butter. As in the stuff that you put on toast. My name comes from the artificial butter *(He tends to call it 'Fake Butter')* you can buy in stores called, Margarine. \n**Creation:** I was created on ${this.client.util.timekeeper.dateMaker(this.client.user.createdAt)} by Butterstroke#7150.`) .setThumbnail(this.client.user.displayAvatarURL()) - .setFooter(`Running on Margarine ${this.client.ownerSetting.get("build").version} | Released on: ${this.client.ownerSetting.get("build").releaseDate}`); + .setFooter(`Running on Margarine ${this.client.build.version} | Released on: ${this.client.build.releaseDate}`); msg.channel.send({embed}); } diff --git a/index.js b/index.js index 3dee297..b2646ce 100644 --- a/index.js +++ b/index.js @@ -32,8 +32,8 @@ if (!existsSync(config.database)) { dataManager("init"); } //Init the SQLite Dat client.ownerSetting = new Collection(); client.music = new Collection(); -client.ownerSetting.set("build", config.build); -client.ownerSetting.set("globalPrefix", config.prefix); +client.build = config.build; +client.globalPrefix = config.prefix; client.itemData = require("./assets/items.json"); diff --git a/languages/en-CA.js b/languages/en-CA.js index d22f625..fdc2e13 100644 --- a/languages/en-CA.js +++ b/languages/en-CA.js @@ -24,6 +24,7 @@ module.exports = class extends Language { DEFAULT: (key) => `${key} has not been localized for en-CA yet.`, DEFAULT_LANGUAGE: "Default Language", NOCHANNEL: "No channel set", + MISSINGPERMISSION: "❌ ERROR: MISSING PERMISSIONS! ❌", MISSINGTERM: (action) => this.client.speech(falseMsg, ["func-system", "missingterm"], ["-action", action]), PERMLEVEL: [ "Level 0 - Everyone", @@ -66,6 +67,8 @@ module.exports = class extends Language { RESOLVER_MINMAX_MAX: (name, max, suffix) => this.client.speech(falseMsg, ["func-system", "resolver", "minMax", "max"], [ ["-name", name], ["-max", max] ]), + RESOLVER_INVALID_CHANNEL: (name) => this.client.speech(falseMsg, ["func-system", "resolver", "channel"], [["-name", name]]), + RESOLVER_INVALID_INT: (name) => this.client.speech(falseMsg, ["func-system", "resolver", "integer"], [["-name", name]]), /* * Klasa System. Copied over from Klasa's en-US. @@ -80,14 +83,12 @@ module.exports = class extends Language { SETTING_GATEWAY_INVALID_FILTERED_VALUE: (piece, value) => `${piece.key} doesn't accept the value: ${value}`, RESOLVER_MULTI_TOO_FEW: (name, min = 1) => `Provided too few ${name}s. At least ${min} ${min === 1 ? 'is' : 'are'} required.`, RESOLVER_INVALID_BOOL: (name) => `${name} must be true or false.`, - RESOLVER_INVALID_CHANNEL: (name) => `${name} must be a channel tag or valid channel id.`, RESOLVER_INVALID_CUSTOM: (name, type) => `${name} must be a valid ${type}.`, RESOLVER_INVALID_DATE: (name) => `${name} must be a valid date.`, RESOLVER_INVALID_DURATION: (name) => `${name} must be a valid duration string.`, RESOLVER_INVALID_EMOJI: (name) => `${name} must be a custom emoji tag or valid emoji id.`, RESOLVER_INVALID_FLOAT: (name) => `${name} must be a valid number.`, RESOLVER_INVALID_GUILD: (name) => `${name} must be a valid guild id.`, - RESOLVER_INVALID_INT: (name) => `${name} must be an integer.`, RESOLVER_INVALID_LITERAL: (name) => `Your option did not match the only possibility: ${name}`, RESOLVER_INVALID_MEMBER: (name) => `${name} must be a mention or valid user id.`, RESOLVER_INVALID_MESSAGE: (name) => `${name} must be a valid message id.`, @@ -224,6 +225,10 @@ module.exports = class extends Language { * Commands - Fun */ ROLL: (msg, value) => this.client.speech(msg, ["roll"], [["-value", value]]), + POLL_NOTITLE: (msg) => this.client.speech(msg, ["poll", "noTitle"]), + POLL_NODESC: (msg) => this.client.speech(msg, ["poll", "noDesc"]), + POLL_NOOPTIONS: (msg) => this.client.speech(msg, ["poll", "noChoice"]), + POLL_NOCREATE: (msg) => this.client.speech(msg, ["poll", "noCreate"]), POLL_CREATED: (msg) => this.client.speech(msg, ["poll", "created"]), POLL_VOTED: (msg, option) => this.client.speech(msg, ["poll", "voted"], [["-option", option]]), POLL_NOPOLL: (msg) => this.client.speech(msg, ["poll", "noPoll"]), @@ -255,6 +260,8 @@ module.exports = class extends Language { */ CHANNEL_UPDATE: (type, channel) => this.client.speech(falseMsg, ["func-owner", "setchannel"], [["-target", type], ["-channel", channel]]), DAILY_UPDATE: (amount) => this.client.speech(falseMsg, ["func-owner", "setdaily"], [["-amount", amount]]), + AWARD_UPDATE: (type, amount) => this.client.speech(falseMsg, ["func-owner", "setaward"], [["-type", type], ["-amount", amount]]), + AVATAR_UPDATE: this.client.speech(falseMsg, ["func-owner", "setavatar"]), /* * Commands - System diff --git a/package-lock.json b/package-lock.json index 66c9300..9ea2444 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "margarine", - "version": "1.2.2", + "version": "1.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -19,13 +19,50 @@ "mime-types": "^2.1.12" } }, - "@discordjs/opus": { + "@discordjs/node-pre-gyp": { "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@discordjs/opus/-/opus-0.1.0.tgz", - "integrity": "sha512-VWsrsgqSktxOEHx9SFcnOWJhYQOsyzaW3JVN73LDSzKrycEjtRIS+axlm4qeMGx60u6RH1SY15b3pl5G4+Y+gA==", + "resolved": "https://registry.npmjs.org/@discordjs/node-pre-gyp/-/node-pre-gyp-0.1.0.tgz", + "integrity": "sha512-6u3EbK2x+j9bM3iK9/pE7BWLxOXZ1PvcsbDo3ZBdPocu95qPHj8zCVsBBk3Cao7V6o8QpwxUyJl6oVJ6T3ZgAg==", "requires": { - "node-addon-api": "^2.0.0", - "node-pre-gyp": "^0.14.0" + "detect-libc": "^1.0.3", + "mkdirp": "^0.5.5", + "needle": "^2.4.1", + "nopt": "^4.0.3", + "npm-packlist": "^1.4.8", + "npmlog": "^4.1.2", + "rc": "^1.2.8", + "rimraf": "^3.0.2", + "semver": "^7.3.0", + "tar": "^6.0.2" + }, + "dependencies": { + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==" + } + } + }, + "@discordjs/opus": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@discordjs/opus/-/opus-0.3.2.tgz", + "integrity": "sha512-T/ubykd4Xi19vDfw7/Oe+iTQBJ28yMI2PQAzK+Zue0PB9OpEYaeIXU7k5255061RwL+rHX9w7P/P2of+x2Vu2A==", + "requires": { + "@discordjs/node-pre-gyp": "^0.1.0", + "node-addon-api": "^2.0.0" } }, "@types/node": { @@ -167,12 +204,11 @@ } }, "better-sqlite3": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-6.0.1.tgz", - "integrity": "sha512-4aV1zEknM9g1a6B0mVBx1oIlmYioEJ8gSS3J6EpN1b1bKYEE+N5lmpmXHKNKTi0qjHziSd7XrXwHl1kpqvEcHQ==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-7.0.1.tgz", + "integrity": "sha512-fsVcoGXxnseNajbfFbth0BKnDWebPY6x77UWfrBHApCKq1yo41DlWnFsffOsLpjkQ4VKgDU5C3aUtiw3wGGU0Q==", "requires": { "bindings": "^1.5.0", - "integer": "^3.0.1", "prebuild-install": "^5.3.3", "tar": "4.4.10" }, @@ -226,9 +262,9 @@ } }, "buffer": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.5.0.tgz", - "integrity": "sha512-9FTEDjLjwoAkEwyMGDjYJQN2gfRgOKBKRfiglhvibGbpeeU/pQn1bJxQqm32OD/AIeEuHxU9roxXxg34Byp/Ww==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz", + "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==", "requires": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" @@ -653,15 +689,6 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, - "integer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/integer/-/integer-3.0.1.tgz", - "integrity": "sha512-OqtER6W2GIJTIcnT5o2B/pWGgvurnVOYs4OZCgay40QEIbMTnNq4R0KSaIw1TZyFtPWjm5aNM+pBBMTfc3exmw==", - "requires": { - "bindings": "^1.5.0", - "prebuild-install": "^5.3.3" - } - }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", @@ -819,14 +846,14 @@ } }, "mkdirp-classic": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.2.tgz", - "integrity": "sha512-ejdnDQcR75gwknmMw/tx02AuRs8jCtqFoFqDZMjiNxsu85sRIJVXDKHuLYvUUPRBUtV2FpSZa9bL1BUa3BdR2g==" + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" }, "moment": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", - "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + "version": "2.25.3", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.25.3.tgz", + "integrity": "sha512-PuYv0PHxZvzc15Sp8ybUCoQ+xpyPWvjOuK72a5ovzp2LI32rJXOiIfyoFoYvG3s6EwwrdkMyWuRiEHSZRLJNdg==" }, "moment-duration-format": { "version": "2.3.2", @@ -844,9 +871,9 @@ "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" }, "needle": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.3.2.tgz", - "integrity": "sha512-DUzITvPVDUy6vczKKYTnWc/pBZ0EnjMJnQ3y+Jo5zfKFimJs7S3HFCxCRZYB9FUZcrzUQr3WsmvZgddMEIZv6w==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.1.tgz", + "integrity": "sha512-x/gi6ijr4B7fwl6WYL9FwlCvRQKGlUNvnceho8wxkwXqN8jvVmmmATTmZPRRG7b/yC1eode26C2HO9jl78Du9g==", "requires": { "debug": "^3.2.6", "iconv-lite": "^0.4.4", @@ -854,9 +881,9 @@ } }, "node-abi": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.15.0.tgz", - "integrity": "sha512-FeLpTS0F39U7hHZU1srAK4Vx+5AHNVOTP+hxBNQknR/54laTHSFIJkDWDqiquY1LeLUgTfPN7sLPhMubx0PLAg==", + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.16.0.tgz", + "integrity": "sha512-+sa0XNlWDA6T+bDLmkCUYn6W5k5W6BPRL6mqzSCs6H/xUgtl4D5x2fORKDzopKiU6wsyn/+wXlRXwXeSp+mtoA==", "requires": { "semver": "^5.4.1" } @@ -871,32 +898,15 @@ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, - "node-pre-gyp": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz", - "integrity": "sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA==", - "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4.4.2" - } - }, "noop-logger": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=" }, "nopt": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", - "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", + "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", "requires": { "abbrev": "1", "osenv": "^0.1.4" @@ -1145,9 +1155,9 @@ } }, "rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "requires": { "glob": "^7.1.3" } @@ -1262,23 +1272,64 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "tar": { - "version": "4.4.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz", - "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==", - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.8.6", - "minizlib": "^1.2.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.3" + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.2.tgz", + "integrity": "sha512-Glo3jkRtPcvpDlAs/0+hozav78yoXKFr+c4wgw62NNMO3oo4AaJdCo21Uu7lcwr55h39W2XD1LMERc64wtbItg==", + "requires": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.0", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "dependencies": { + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" + }, + "fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "requires": { + "minipass": "^3.0.0" + } + }, + "minipass": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz", + "integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==", + "requires": { + "yallist": "^4.0.0" + } + }, + "minizlib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.0.tgz", + "integrity": "sha512-EzTZN/fjSvifSX0SlqUERCN39o6T40AMarPbv0MrarSFtIITCBh7bi+dU8nxGFHuqs9jdIAeoYoKuQAAASsPPA==", + "requires": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + } + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } } }, "tar-fs": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.1.tgz", - "integrity": "sha512-6tzWDMeroL87uF/+lin46k+Q+46rAJ0SyPGz7OW7wTgblI273hsBqk2C1j0/xNadNLKDTUL9BukSjB7cwgmlPA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.0.tgz", + "integrity": "sha512-9uW5iDvrIMCVpvasdFHW0wJPez0K4JnMZtsuIeDI7HyMGJNxmDZDOCQROr7lXyS+iL/QMpj07qcjGYTSdRFXUg==", "requires": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", diff --git a/package.json b/package.json index 327aa36..57432ee 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,17 @@ { "name": "margarine", - "version": "1.2.2", + "version": "1.3.0", "description": "Javascript bot using the Klasa framework", "main": "index.js", "dependencies": { - "@discordjs/opus": "^0.1.0", + "@discordjs/opus": "^0.3.2", "anilist-node": "^1.4.0", - "better-sqlite3": "^6.0.1", + "better-sqlite3": "^7.0.1", "cheerio": "^1.0.0-rc.3", "discord.js": "^12.2.0", "ffmpeg": "0.0.4", "klasa": "github:dirigeants/klasa", - "moment": "^2.24.0", + "moment": "^2.25.3", "moment-duration-format": "^2.3.2", "ms": "^2.1.2", "node-fetch": "^2.6.0", diff --git a/utilities/modEmbed.js b/utilities/modEmbed.js index e289c42..b8613cf 100644 --- a/utilities/modEmbed.js +++ b/utilities/modEmbed.js @@ -2,7 +2,7 @@ const { MessageEmbed } = require("discord.js"); /** * Creates an embed for a moderation action. - * @param { KlasaMessage } msg - Required. + * @param { KlasaMessage } msg * @param { String } action - The action done. Either ban or kick. * @param { KlasaUser } user - The user affected by the action. * @param { String } reason - The reason behind the action. @@ -23,11 +23,11 @@ module.exports = function(msg, action=action.toLowerCase(), user, reason) { if (msg.channel.permissionsFor(msg.author).has(options[0]) === false) { embed.setColor(0xDD2E44) - .setTitle("❌ ERROR: MISSING PERMISSIONS! ❌") + .setTitle(msg.language.get("MISSINGPERMISSION")) .setDescription("You do not have the correct permissions for this command!"); } else if (msg.channel.permissionsFor(client.user).has(options[0]) === false) { embed.setColor(0xDD2E44) - .setTitle("❌ ERROR: MISSING PERMISSIONS! ❌") + .setTitle(msg.language.get("MISSINGPERMISSION")) .setDescription("I do not have the correct permissions for this command!"); } else { embed.setColor(options[2]) From 89d64d6b98f5daae7df46f400502e8a450a8c7bf Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Tue, 19 May 2020 15:16:53 -0400 Subject: [PATCH 6/6] Quick Patch Missed a few things that should have been changed. Whoops. --- README.md | 2 +- languages/en-CA.js | 2 +- utilities/presenceHelper.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bfec136..aa232e4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Dependencies -![discord.js](https://img.shields.io/badge/discord.js-v12.2.0-brightgreen.svg) ![klasa](https://img.shields.io/badge/Klasa-v0.22.0-brightgreen.svg) ![node](https://img.shields.io/badge/Node-v10.0.0+-brightgreen.svg) +![discord.js](https://img.shields.io/badge/discord.js-v12.2.0-brightgreen.svg) ![klasa](https://img.shields.io/badge/Klasa-v0.22.0-brightgreen.svg) ![node](https://img.shields.io/badge/Node-v12.0.0+-brightgreen.svg) A Discord bot coded in Node.js using the Discord.js Library and the Klasa framework. diff --git a/languages/en-CA.js b/languages/en-CA.js index fdc2e13..f45ac1e 100644 --- a/languages/en-CA.js +++ b/languages/en-CA.js @@ -258,7 +258,7 @@ module.exports = class extends Language { /* * Commands - Owner */ - CHANNEL_UPDATE: (type, channel) => this.client.speech(falseMsg, ["func-owner", "setchannel"], [["-target", type], ["-channel", channel]]), + CHANNEL_UPDATE: (type, channel) => this.client.speech(falseMsg, ["func-owner", "setchannel"], [["-type", type], ["-channel", channel]]), DAILY_UPDATE: (amount) => this.client.speech(falseMsg, ["func-owner", "setdaily"], [["-amount", amount]]), AWARD_UPDATE: (type, amount) => this.client.speech(falseMsg, ["func-owner", "setaward"], [["-type", type], ["-amount", amount]]), AVATAR_UPDATE: this.client.speech(falseMsg, ["func-owner", "setavatar"]), diff --git a/utilities/presenceHelper.js b/utilities/presenceHelper.js index 5446807..ad579eb 100644 --- a/utilities/presenceHelper.js +++ b/utilities/presenceHelper.js @@ -3,7 +3,7 @@ let games = require("../assets/localization.json")["games"]; function Presence(client, type, name, status) { const tList = { "play": "PLAYING", "stream": "STREAMING", "listen": "LISTENING", "watch": "WATCHING" }; type = tList[type]; - name = (name !== "-null") ? `${client.ownerSetting.get("globalPrefix")}help | ${name}` : null; + name = (name !== "-null") ? `${client.globalPrefix}help | ${name}` : null; client.user.setPresence({ activity: { name, type }, status }); } @@ -16,7 +16,7 @@ function Presence(client, type, name, status) { * @param { String } [status=online] - Changes the colour on the status. Either online, idle, dnd, or invisible. */ module.exports = (client, name, type=0, status="online") => { //Type defaulted to play and status defaulted to online. - const sliceCheck = `${client.ownerSetting.get("globalPrefix")}help |`.length; + const sliceCheck = `${client.globalPrefix}help |`.length; if (name === "-start" || name === "-reset") { var items = games[Math.floor(Math.random() * games.length)]; //For random status upon startup