From 0c37a5e54666851619ee09f461837b5a033e7547 Mon Sep 17 00:00:00 2001 From: Butterstroke Date: Tue, 12 Jun 2018 22:20:00 -0400 Subject: [PATCH 01/38] AniList command Added an AniList search command! --- commands/General/anilist.js | 80 +++++++++ package-lock.json | 313 ++++++++++++++++++++++++++++-------- package.json | 7 +- 3 files changed, 334 insertions(+), 66 deletions(-) create mode 100644 commands/General/anilist.js diff --git a/commands/General/anilist.js b/commands/General/anilist.js new file mode 100644 index 0000000..adfa5ad --- /dev/null +++ b/commands/General/anilist.js @@ -0,0 +1,80 @@ +const puppeteer = require("puppeteer"); + +exports.run = async (client, msg, [term]) => { + const infoHelp = { + terms: ["current", "plan", "finish", "drop", "pause"], + anime: ["šŸ’š Watching", "šŸ—“ Planned", "šŸ’™ Completed", "šŸ’” Dropped", "šŸ’› Paused"], + manga: ["šŸ“— Reading", "šŸ—“ Planned", "šŸ“˜ Completed", "šŸ“• Dropped", "šŸ“™ Paused"] + }; + + const url = "https://anilist.co/user/" + term; + const info = { anime: {}, manga: {} }; terms = infoHelp.terms; + + const browser = await puppeteer.launch(); + const page = await browser.newPage(); + + await page.goto(url + "/stats"); + await page.screenshot({path: "example.png"}); + await page.waitFor(2000); + if (page.target()._targetInfo.url === "https://anilist.co/404") { return msg.channel.send("Whoops! Looks like a user by that name does not exist."); } + + var lists = await page.evaluate(() => { + var aList = document.querySelector('#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-a').innerHTML; + var mList = document.querySelector('#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-b').innerHTML; + return [aList.split(">"), mList.split(">")]; + }); + + await page.goto(url); + + var stats = await page.evaluate(() => { + var ava = document.querySelector('#app > div.page-content > div > div.header-wrap > div.banner > div.container > div > img').getAttribute("src"); + var num = document.querySelector('#app > div.page-content > div > div.content.container > div > div:nth-child(2) > div.stats-wrap > div:nth-child(1) > div.stats-wrap').innerText.split(" "); + var ber = document.querySelector('#app > div.page-content > div > div.content.container > div > div:nth-child(2) > div.stats-wrap > div:nth-child(2) > div.stats-wrap').innerText.split(" "); + return [num[0].slice(0, -5), num[2].slice(6, -5), ber[0].slice(0, -9), ber[2].slice(6, -5), ava]; + }); + + await browser.close(); + + var y = 0; for (var x = 0; x < lists[0].length; x++) { if (!lists[0][x].startsWith("<") && lists[0][x].length > 1) { info.anime[terms[y]] = lists[0][x].slice(0, -6); y++ } } + var y = 0; for (var x = 0; x < lists[1].length; x++) { if (!lists[1][x].startsWith("<") && lists[1][x].length > 1) { info.manga[terms[y]] = lists[1][x].slice(0, -6); y++ } } + + var aDisplay = []; var mDisplay = []; + for (var x = 0; x < 5; x++) { + if (info.anime.hasOwnProperty([terms[x]]) === false) { aDisplay.push(`${infoHelp.anime[x]}: 0`); } + else { aDisplay.push(`${infoHelp.anime[x]}: ${info.anime[terms[x]]}`); } + } + + for (var x = 0; x < 5; x++) { + if (info.manga.hasOwnProperty([terms[x]]) === false) { mDisplay.push(`${infoHelp.manga[x]}: 0`); } + else { mDisplay.push(`${infoHelp.manga[x]}: ${info.manga[terms[x]]}`); } + } + + const embed = new client.methods.Embed() + .setTitle(term + "'s AniList Profile") + .setURL(url + term + "/") + .setDescription("šŸ•“ Watch Days: " + stats[0] + " | šŸ“Š Anime Mean: " + stats[1] + "\nšŸ”– Manga Chapters: " + stats[2] + " | šŸ“Š Manga Mean: " + stats[3]) + .addField("__Anime:__", aDisplay, true) + .addField("__Manga:__", mDisplay, true) + .setTimestamp() + .setColor(0x2E51A2) + .setThumbnail(stats[4]) + .setFooter("Requested by: " + msg.author.tag); + + msg.channel.send({embed}); +}; + +exports.conf = { + enabled: true, + runIn: ["text"], + aliases: [], + permLevel: 0, + botPerms: ["ATTACH_FILES"], + cooldown: 60 +}; + +exports.help = { + name: "anilist", + description: "Fetch a user's profile on AniList", + usage: "[term:str]", + extendedHelp: "There is a 60 second cooldown for each profile search to not spam the site." +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 11f06e4..3dc752f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "margarine", - "version": "0.9.0", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -9,6 +9,14 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.88.tgz", "integrity": "sha512-bYDPZTX0/s1aihdjLuAgogUAT5M+TpoWChEMea2p0yOcfn5bu3k6cJb9cp6nw268XeSNIGGr+4+/8V5K6BGzLQ==" }, + "agent-base": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.0.tgz", + "integrity": "sha512-c+R/U5X+2zz2+UCrCFv6odQzJdoqI+YecuhnAJLa1zYaMc13zPfwMwZrr91Pd1DYNo/yPRbiM4WVf9whgwFsIg==", + "requires": { + "es6-promisify": "5.0.0" + } + }, "ajv": { "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", @@ -50,6 +58,11 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, "bcrypt-pbkdf": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", @@ -77,14 +90,20 @@ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" }, - "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "requires": { - "hoek": "4.2.1" + "balanced-match": "1.0.0", + "concat-map": "0.0.1" } }, + "buffer-from": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz", + "integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==" + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -121,29 +140,27 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==" }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "1.1.0", + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, - "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", - "requires": { - "boom": "5.2.0" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", - "requires": { - "hoek": "4.2.1" - } - } - } - }, "css-select": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", @@ -189,7 +206,7 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "discord.js": { - "version": "github:hydrabolt/discord.js#75747f5b189053203dca8833ad75fa2094ff44ef", + "version": "github:hydrabolt/discord.js#faf27fabc055cb3850e823cf36c0af21c0139c35", "requires": { "pako": "1.0.6", "prism-media": "0.2.1", @@ -257,11 +274,35 @@ "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=" }, + "es6-promise": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==" + }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "requires": { + "es6-promise": "4.2.4" + } + }, "extend": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" }, + "extract-zip": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", + "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "requires": { + "concat-stream": "1.6.2", + "debug": "2.6.9", + "mkdirp": "0.5.1", + "yauzl": "2.4.1" + } + }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -277,6 +318,14 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, + "fd-slicer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", + "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "requires": { + "pend": "1.2.0" + } + }, "ffmpeg": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/ffmpeg/-/ffmpeg-0.0.4.tgz", @@ -305,6 +354,11 @@ "resolved": "https://registry.npmjs.org/fs-nextra/-/fs-nextra-0.3.2.tgz", "integrity": "sha512-ktFNusOmRFt1sWPaRRS3USAb4sFlZvERdG+rZ+VDzPBciC+0K0BhFBs5vMkJZZhhUMi6/gzGAvb7UePP/DLnzA==" }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -313,6 +367,19 @@ "assert-plus": "1.0.0" } }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -327,22 +394,6 @@ "har-schema": "2.0.0" } }, - "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", - "requires": { - "boom": "4.3.1", - "cryptiles": "3.1.2", - "hoek": "4.2.1", - "sntp": "2.1.0" - } - }, - "hoek": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==" - }, "html-entities": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", @@ -371,6 +422,39 @@ "sshpk": "1.14.1" } }, + "https-proxy-agent": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", + "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "requires": { + "agent-base": "4.2.0", + "debug": "3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -429,7 +513,7 @@ "integrity": "sha512-Gbl2OiO1CYvjXrlzQ/rjS3MMvgPtZt0uCassh61QlLGRserdPjIvgRNPIduK1RgzNao1sbwDuIaItNGNO/A8FQ==", "requires": { "fs-nextra": "0.3.2", - "moment": "2.20.1", + "moment": "2.22.2", "moment-duration-format": "1.3.0", "performance-now": "2.1.0" }, @@ -454,6 +538,11 @@ "miniget": "1.2.0" } }, + "mime": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.3.1.tgz", + "integrity": "sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg==" + }, "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", @@ -472,10 +561,31 @@ "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.2.0.tgz", "integrity": "sha1-ADY3Oia71S2+aUX85sjAOR6eEkE=" }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "1.1.11" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, "moment": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.20.1.tgz", - "integrity": "sha512-Yh9y73JRljxW5QxN08Fner68eFLxM5ynNOAw2LbIB1YAGeQzZT8QFSUvkAz609Zf+IHhhaUxqZK8dG3W/+HEvg==" + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" }, "moment-duration-format": { "version": "1.3.0", @@ -525,6 +635,14 @@ "ref-struct": "1.1.0" } }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1.0.2" + } + }, "pako": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", @@ -538,6 +656,16 @@ "@types/node": "6.0.88" } }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -553,11 +681,59 @@ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" }, + "progress": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=" + }, + "proxy-from-env": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", + "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=" + }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" }, + "puppeteer": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.5.0.tgz", + "integrity": "sha512-eELwFtFxL+uhmg4jPZOZXzSrPEYy4CaYQNbcchBbfxY+KjMpnv6XGf/aYWaQG49OTpfi2/DMziXtDM8XuJgoUA==", + "requires": { + "debug": "3.1.0", + "extract-zip": "1.6.7", + "https-proxy-agent": "2.2.1", + "mime": "2.3.1", + "progress": "2.0.0", + "proxy-from-env": "1.0.0", + "rimraf": "2.6.2", + "ws": "5.2.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "ws": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.0.tgz", + "integrity": "sha512-c18dMeW+PEQdDFzkhDsnBAlS4Z8KGStBQQUcQ5mf7Nf689jyGk0594L+i9RaQuf4gog6SvWLJorz2NfSaqxZ7w==", + "requires": { + "async-limiter": "1.0.0" + } + } + } + }, "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", @@ -604,9 +780,9 @@ } }, "request": { - "version": "2.85.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz", - "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==", + "version": "2.87.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", + "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", "requires": { "aws-sign2": "0.7.0", "aws4": "1.6.0", @@ -616,7 +792,6 @@ "forever-agent": "0.6.1", "form-data": "2.3.2", "har-validator": "5.0.3", - "hawk": "6.0.2", "http-signature": "1.2.0", "is-typedarray": "1.0.0", "isstream": "0.1.2", @@ -626,12 +801,19 @@ "performance-now": "2.1.0", "qs": "6.5.1", "safe-buffer": "5.1.1", - "stringstream": "0.0.5", "tough-cookie": "2.3.4", "tunnel-agent": "0.6.0", "uuid": "3.2.1" } }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "7.1.2" + } + }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", @@ -647,14 +829,6 @@ "resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.5.8.tgz", "integrity": "sha512-osq7soqKBObV4u/WE9tGQT/m5JdqTU1PWVPcT0We3sKZ99h9QA7wSj7ZWrwEwgRbELeO5BrVCanYjDYtVYcwrQ==" }, - "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", - "requires": { - "hoek": "4.2.1" - } - }, "sqlite3": { "version": "3.1.13", "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-3.1.13.tgz", @@ -1403,11 +1577,6 @@ "safe-buffer": "5.1.1" } }, - "stringstream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" - }, "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", @@ -1429,6 +1598,11 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz", "integrity": "sha1-cT2LgY2kIGh0C/aDhtBHnmb8ins=" }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -1454,6 +1628,11 @@ "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=" }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, "ws": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz", @@ -1463,6 +1642,14 @@ "safe-buffer": "5.1.1" } }, + "yauzl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", + "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "requires": { + "fd-slicer": "1.0.1" + } + }, "ytdl-core": { "version": "0.20.4", "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.20.4.tgz", diff --git a/package.json b/package.json index 09febb8..9980f0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "margarine", - "version": "0.9.0", + "version": "1.0.0", "description": "Javascript bot using the Komada framework", "main": "index.js", "dependencies": { @@ -8,12 +8,13 @@ "discord.js": "github:hydrabolt/discord.js", "ffmpeg": "0.0.4", "komada": "^0.21.1", - "moment": "^2.19.3", + "moment": "^2.22.2", "moment-duration-format": "^1.3.0", "ms": "^2.0.0", "node-opus": "^0.2.7", + "puppeteer": "^1.5.0", "querystring": "^0.2.0", - "request": "^2.85.0", + "request": "^2.87.0", "snekfetch": "^3.5.8", "sqlite3": "^3.1.13", "steamapi": "^1.3.5", From 594c615da039fbcf8529e8e9224a8dbf179747f2 Mon Sep 17 00:00:00 2001 From: Sova Riddear Date: Wed, 13 Jun 2018 15:18:26 -0400 Subject: [PATCH 02/38] AniList Fixes Fixed an issue with stats not going to the right spots. --- commands/General/anilist.js | 27 +++++++++++---------------- package-lock.json | 2 +- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/commands/General/anilist.js b/commands/General/anilist.js index adfa5ad..c815bf2 100644 --- a/commands/General/anilist.js +++ b/commands/General/anilist.js @@ -14,14 +14,13 @@ exports.run = async (client, msg, [term]) => { const page = await browser.newPage(); await page.goto(url + "/stats"); - await page.screenshot({path: "example.png"}); await page.waitFor(2000); if (page.target()._targetInfo.url === "https://anilist.co/404") { return msg.channel.send("Whoops! Looks like a user by that name does not exist."); } var lists = await page.evaluate(() => { var aList = document.querySelector('#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-a').innerHTML; var mList = document.querySelector('#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-b').innerHTML; - return [aList.split(">"), mList.split(">")]; + return [aList.split(""), mList.split("")]; }); await page.goto(url); @@ -35,26 +34,22 @@ exports.run = async (client, msg, [term]) => { await browser.close(); - var y = 0; for (var x = 0; x < lists[0].length; x++) { if (!lists[0][x].startsWith("<") && lists[0][x].length > 1) { info.anime[terms[y]] = lists[0][x].slice(0, -6); y++ } } - var y = 0; for (var x = 0; x < lists[1].length; x++) { if (!lists[1][x].startsWith("<") && lists[1][x].length > 1) { info.manga[terms[y]] = lists[1][x].slice(0, -6); y++ } } - var aDisplay = []; var mDisplay = []; - for (var x = 0; x < 5; x++) { - if (info.anime.hasOwnProperty([terms[x]]) === false) { aDisplay.push(`${infoHelp.anime[x]}: 0`); } - else { aDisplay.push(`${infoHelp.anime[x]}: ${info.anime[terms[x]]}`); } + var y = 0; for (var x = 0; x < lists[0].length; x++) { + if (!lists[0][x].endsWith(">") && lists[0][x].length > 1) { aDisplay.push(infoHelp.anime[y] + ": " + lists[0][x].slice(lists[0][x].search("text\">") + 6)); y++ } + else if (lists[0][x].endsWith(">")) { aDisplay.push(infoHelp.anime[y] + ": 0"); y++ } } - - for (var x = 0; x < 5; x++) { - if (info.manga.hasOwnProperty([terms[x]]) === false) { mDisplay.push(`${infoHelp.manga[x]}: 0`); } - else { mDisplay.push(`${infoHelp.manga[x]}: ${info.manga[terms[x]]}`); } + var y = 0; for (var x = 0; x < lists[1].length; x++) { + if (!lists[1][x].endsWith(">") && lists[1][x].length > 1) { mDisplay.push(infoHelp.manga[y] + ": " + lists[1][x].slice(lists[1][x].search("text\">") + 6)); y++ } + else if (lists[1][x].endsWith(">")) { mDisplay.push(infoHelp.manga[y] + ": 0"); y++ } } const embed = new client.methods.Embed() .setTitle(term + "'s AniList Profile") - .setURL(url + term + "/") - .setDescription("šŸ•“ Watch Days: " + stats[0] + " | šŸ“Š Anime Mean: " + stats[1] + "\nšŸ”– Manga Chapters: " + stats[2] + " | šŸ“Š Manga Mean: " + stats[3]) - .addField("__Anime:__", aDisplay, true) - .addField("__Manga:__", mDisplay, true) + .setURL(url + "/") + .setDescription("šŸ•“ Watch Days: " + stats[0] + "\nšŸ”– Manga Chapters: " + stats[2]) + .addField("__Anime:__", "šŸ“Š Mean Score: " + stats[1] + "\n" + aDisplay.join("\n"), true) + .addField("__Manga:__", "šŸ“Š Mean Score: " + stats[3] + "\n" + mDisplay.join("\n"), true) .setTimestamp() .setColor(0x2E51A2) .setThumbnail(stats[4]) diff --git a/package-lock.json b/package-lock.json index 3dc752f..06daa94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -206,7 +206,7 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "discord.js": { - "version": "github:hydrabolt/discord.js#faf27fabc055cb3850e823cf36c0af21c0139c35", + "version": "github:hydrabolt/discord.js#ba9a93b0bf4c3611cfc069de29800626e3f682aa", "requires": { "pako": "1.0.6", "prism-media": "0.2.1", From 6ba5bd7642554d8184563a746078e70f451fe4e0 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Sat, 30 Jun 2018 22:12:24 -0400 Subject: [PATCH 03/38] Daily Command Fix Fixed the daily command issue #42. Also removes the fish stats table and an unused package. --- commands/Economy/daily.js | 27 +++++++++++++++------------ commands/General/anilist.js | 25 +++++++++++-------------- commands/System/exit.js | 4 ++-- commands/System/invite.js | 4 ++-- functions/sqlTables.js | 2 -- package-lock.json | 30 +++++++++++++----------------- package.json | 1 - 7 files changed, 43 insertions(+), 50 deletions(-) diff --git a/commands/Economy/daily.js b/commands/Economy/daily.js index d47c106..f318c53 100644 --- a/commands/Economy/daily.js +++ b/commands/Economy/daily.js @@ -11,18 +11,23 @@ exports.run = async (client, msg, [user]) => { var info = []; var talk1 = talk; db.serialize(function() { - db.each(`SELECT daily, credits FROM scores WHERE userId IN ("${msg.author.id}", "${user.id}")`, function (err, row) { + db.each(`SELECT daily, credits FROM scores WHERE userId IN ("${msg.author.id}", "${user.id}")`, [], function (err, row) { if (err) { return console.log(err); } - if (!row) { - if (type === "self") { client.funcs.sqlTables(user, "add"); } - else if (type === "other") { info.push("noRow"); } - } else if (Number(row.daily) + 86400000 > Date.now()) { info.push("multi"); } - else { info.push(type); } + if (row) { + if (Number(row.daily) + 86400000 > Date.now()) { info.push("multi"); } + else { info.push(type); } + } info.push(row.credits); }, function() { - var valid = (type !== info[0]) ? false : true; + if (info.length < 1) { + if (type === "self") { + client.funcs.sqlTables(user, "add"); + info.push(...["self", 100]); + } else if (type === "other") { info.push("noRow"); } + } + if (info[2] !== "noRow") { talk1 = talk1["daily"]; } - var x = 0; + var valid = (type !== info[0]) ? false : true; var x = 0; if (valid === true) { var credit = (type === "other") ? Number((100 * (1 + Math.random())).toFixed(0)) : 100; @@ -32,8 +37,7 @@ exports.run = async (client, msg, [user]) => { db.run(`UPDATE scores SET credits = ${info[1] + credit} WHERE userId = ${user.id}`); } } - - msg.channel.send(talk1[info[x]][Math.floor(Math.random() * talk1[info[x]].length)].replace('-user-', user.prefered).replace('-credit-', credit)); + msg.channel.send(talk1[info[x]][Math.floor(Math.random() * talk1[info[x]].length)].replace("-user-", user.prefered).replace("-credit-", credit)); }); }); }; @@ -50,6 +54,5 @@ exports.conf = { exports.help = { name: "daily", description: "Get a daily amount of credits or give them to someone else.", - usage: "[user:str]", - humanUse: "(user)" + usage: "[user:str]", humanUse: "(user)" }; \ No newline at end of file diff --git a/commands/General/anilist.js b/commands/General/anilist.js index c815bf2..9e6b182 100644 --- a/commands/General/anilist.js +++ b/commands/General/anilist.js @@ -2,15 +2,12 @@ const puppeteer = require("puppeteer"); exports.run = async (client, msg, [term]) => { const infoHelp = { - terms: ["current", "plan", "finish", "drop", "pause"], anime: ["šŸ’š Watching", "šŸ—“ Planned", "šŸ’™ Completed", "šŸ’” Dropped", "šŸ’› Paused"], manga: ["šŸ“— Reading", "šŸ—“ Planned", "šŸ“˜ Completed", "šŸ“• Dropped", "šŸ“™ Paused"] }; const url = "https://anilist.co/user/" + term; - const info = { anime: {}, manga: {} }; terms = infoHelp.terms; - - const browser = await puppeteer.launch(); + const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']}); const page = await browser.newPage(); await page.goto(url + "/stats"); @@ -18,17 +15,17 @@ exports.run = async (client, msg, [term]) => { if (page.target()._targetInfo.url === "https://anilist.co/404") { return msg.channel.send("Whoops! Looks like a user by that name does not exist."); } var lists = await page.evaluate(() => { - var aList = document.querySelector('#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-a').innerHTML; - var mList = document.querySelector('#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-b').innerHTML; + var aList = document.querySelector("#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-a").innerHTML; + var mList = document.querySelector("#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-b").innerHTML; return [aList.split(""), mList.split("")]; }); await page.goto(url); var stats = await page.evaluate(() => { - var ava = document.querySelector('#app > div.page-content > div > div.header-wrap > div.banner > div.container > div > img').getAttribute("src"); - var num = document.querySelector('#app > div.page-content > div > div.content.container > div > div:nth-child(2) > div.stats-wrap > div:nth-child(1) > div.stats-wrap').innerText.split(" "); - var ber = document.querySelector('#app > div.page-content > div > div.content.container > div > div:nth-child(2) > div.stats-wrap > div:nth-child(2) > div.stats-wrap').innerText.split(" "); + var ava = document.querySelector("#app > div.page-content > div > div.header-wrap > div.banner > div.container > div > img").getAttribute("src"); + var num = document.querySelector("#app > div.page-content > div > div.content.container > div > div:nth-child(2) > div.stats-wrap > div:nth-child(1) > div.stats-wrap").innerText.split(" "); + var ber = document.querySelector("#app > div.page-content > div > div.content.container > div > div:nth-child(2) > div.stats-wrap > div:nth-child(2) > div.stats-wrap").innerText.split(" "); return [num[0].slice(0, -5), num[2].slice(6, -5), ber[0].slice(0, -9), ber[2].slice(6, -5), ava]; }); @@ -36,12 +33,12 @@ exports.run = async (client, msg, [term]) => { var aDisplay = []; var mDisplay = []; var y = 0; for (var x = 0; x < lists[0].length; x++) { - if (!lists[0][x].endsWith(">") && lists[0][x].length > 1) { aDisplay.push(infoHelp.anime[y] + ": " + lists[0][x].slice(lists[0][x].search("text\">") + 6)); y++ } - else if (lists[0][x].endsWith(">")) { aDisplay.push(infoHelp.anime[y] + ": 0"); y++ } + if (!lists[0][x].endsWith(">") && lists[0][x].length > 1) { aDisplay.push(infoHelp.anime[y] + ": " + lists[0][x].slice(lists[0][x].search("text\">") + 6)); y++; } + else if (lists[0][x].endsWith(">")) { aDisplay.push(infoHelp.anime[y] + ": 0"); y++; } } var y = 0; for (var x = 0; x < lists[1].length; x++) { - if (!lists[1][x].endsWith(">") && lists[1][x].length > 1) { mDisplay.push(infoHelp.manga[y] + ": " + lists[1][x].slice(lists[1][x].search("text\">") + 6)); y++ } - else if (lists[1][x].endsWith(">")) { mDisplay.push(infoHelp.manga[y] + ": 0"); y++ } + if (!lists[1][x].endsWith(">") && lists[1][x].length > 1) { mDisplay.push(infoHelp.manga[y] + ": " + lists[1][x].slice(lists[1][x].search("text\">") + 6)); y++; } + else if (lists[1][x].endsWith(">")) { mDisplay.push(infoHelp.manga[y] + ": 0"); y++; } } const embed = new client.methods.Embed() @@ -70,6 +67,6 @@ exports.conf = { exports.help = { name: "anilist", description: "Fetch a user's profile on AniList", - usage: "[term:str]", + usage: "[term:str]", humanUse: "(AniList profile name)", extendedHelp: "There is a 60 second cooldown for each profile search to not spam the site." }; \ No newline at end of file diff --git a/commands/System/exit.js b/commands/System/exit.js index dae9cf8..e61d2f2 100644 --- a/commands/System/exit.js +++ b/commands/System/exit.js @@ -9,11 +9,11 @@ exports.conf = { runIn: ["text", "dm"], aliases: ["sleep"], permLevel: 10, - botPerms: [], + botPerms: [] }; exports.help = { name: "exit", description: "Shuts down the bot.", - usage: "", + usage: "" }; \ No newline at end of file diff --git a/commands/System/invite.js b/commands/System/invite.js index 4a1d51f..e386f23 100644 --- a/commands/System/invite.js +++ b/commands/System/invite.js @@ -8,11 +8,11 @@ exports.conf = { runIn: ["text", "dm"], aliases: [], permLevel: 0, - botPerms: [], + botPerms: [] }; exports.help = { name: "invite", description: "Displays the join server link of the bot.", - usage: "", + usage: "" }; \ No newline at end of file diff --git a/functions/sqlTables.js b/functions/sqlTables.js index 5358c1b..437d6ef 100644 --- a/functions/sqlTables.js +++ b/functions/sqlTables.js @@ -5,7 +5,6 @@ module.exports = (user, type) => { if (type === "init") { db.run("CREATE TABLE IF NOT EXISTS scores (userId TEXT, credits INTEGER, level INTEGER, daily TEXT, rep INTEGER, repDaily TEXT)"); - db.run("CREATE TABLE IF NOT EXISTS fish_stats (userId TEXT, trash INTEGER, fish INTEGER, crab INTEGER, squid INTEGER, shark INTERGER)"); db.run("CREATE TABLE IF NOT EXISTS badges (userId TEXT, bugTester TEXT, betaTester TEXT)"); db.run("CREATE TABLE IF NOT EXISTS awards (userId TEXT, suggest INTEGER, bugs INTEGER, minor INTEGER, major INTEGER)", [], (err, row) => { if (err) { return console.log(err); } @@ -21,7 +20,6 @@ module.exports = (user, type) => { sql.close(); } if (type === "add") { db.run("INSERT INTO scores (userId, credits, level, daily, rep, repDaily) VALUES (?, ?, ?, ?, ?, ?)", [user.id, 100, 0, Date.now(), 0, 0]); - db.run("INSERT INTO fish_stats (userId, trash, fish, crab, squid, shark) VALUES (?, ?, ?, ?, ?, ?)", [user.id, 0, 0, 0, 0, 0]); db.run("INSERT INTO badges (userId) VALUES (?)", [user.id]); db.run("INSERT INTO awards (userId) VALUES (?)", [user.id]); db.close(); diff --git a/package-lock.json b/package-lock.json index 06daa94..d6589eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -206,19 +206,20 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "discord.js": { - "version": "github:hydrabolt/discord.js#ba9a93b0bf4c3611cfc069de29800626e3f682aa", + "version": "github:hydrabolt/discord.js#2694c0d442a008a1e40c17df147a22bc9534049a", "requires": { + "form-data": "2.3.2", + "node-fetch": "2.1.2", "pako": "1.0.6", - "prism-media": "0.2.1", - "snekfetch": "3.6.4", + "prism-media": "0.3.1", "tweetnacl": "1.0.0", "ws": "4.1.0" }, "dependencies": { - "snekfetch": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.6.4.tgz", - "integrity": "sha512-NjxjITIj04Ffqid5lqr7XdgwM7X61c/Dns073Ly170bPQHLm6jkmelye/eglS++1nfTWktpP6Y2bFXjdPlQqdw==" + "prism-media": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-0.3.1.tgz", + "integrity": "sha512-ZAzpXm6n7IaMDrcm7gB6wEkhF796cFLBZPY91rse5DKsASrZZgo36y9QC4+FnlbWt14aQSZUnKMHnkg6pEDfiQ==" } } }, @@ -602,6 +603,11 @@ "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=" }, + "node-fetch": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz", + "integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=" + }, "node-opus": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/node-opus/-/node-opus-0.2.7.tgz", @@ -671,11 +677,6 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, - "prism-media": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-0.2.1.tgz", - "integrity": "sha512-Kfp1+6gzjY6X8mqKHa6D3brX+BtMUPFwzAkz4zgtVPgbkA2XxhITROdfQXVurU4fuJsylFRwqo7ciQlQCm9hAw==" - }, "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", @@ -1564,11 +1565,6 @@ } } }, - "steamapi": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/steamapi/-/steamapi-1.3.5.tgz", - "integrity": "sha512-m6GpOPB27OaiMTg1YgbeQudFxLNWlcBtDg8zwAvwN9m2+vSbtIG3LSBNi06FySCSQxYLZxBtTobHJNddVU4Myw==" - }, "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", diff --git a/package.json b/package.json index 9980f0e..a766c06 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "request": "^2.87.0", "snekfetch": "^3.5.8", "sqlite3": "^3.1.13", - "steamapi": "^1.3.5", "ytdl-core": "^0.20.4" }, "devDependencies": {}, From 50983d4b2259079fa0227b0935a8e01603c69779 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Sat, 7 Jul 2018 04:33:28 -0400 Subject: [PATCH 04/38] Improved Speech Improved the way Margarine's speech works. Now, it called a function in the client for easier reading and debugging! --- README.md | 2 +- assets/speech.json | 43 ++++++++++++++++++++++++------- commands/Economy/Cooking/craft.js | 7 +++-- commands/Economy/Cooking/fish.js | 3 +-- commands/Economy/Cooking/sell.js | 2 +- commands/Fun/say.js | 4 +-- commands/General/mal.js | 3 +-- index.js | 38 ++++++++++++++++++++------- monitors/prefixHelp.js | 2 +- 9 files changed, 73 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 4229900..ff38853 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A Discord bot coded in Node.js using the Discord.js Library and the Komada frame Introduction: Created through part-desire, part-what can I do in Discord, part-I'm going to learn Javascript, and part-it's only 12 am thoughts, Margarine has been my personal project for almost 6 months now. I am quite proud of the functionality and the time I have spend into Margarine. I have received plenty of support over the months of developing him and I can't thank those people enough as without that support, Margarine would have never been as big as he is today. I hope that you enjoy either looking at/learning/using Margarine as much as I do. -*Name Origin:* My typical nickname is Butter. As in the stuff that you put on toast. His name comes from the artificial butter (I tends to call it 'Fake Butter') you can buy in stores called, Margarine. +*Name Origin:* My typical nickname is Butter, as in the stuff that you put on toast. His name comes from the artificial butter (I tends to call it 'Fake Butter') you can buy in stores called, Margarine. Features: diff --git a/assets/speech.json b/assets/speech.json index bb82cfa..fa74722 100644 --- a/assets/speech.json +++ b/assets/speech.json @@ -6,7 +6,8 @@ "Credits? Hello? I need an amount of credits!" ], "craft": [ - "You can't craft nothing, baka!" + "You can't craft nothing, baka!", + "Wow. Crafting nothing, I see. Got nothing else to do?" ], "default": [ "You didn't include a value here, baka!", @@ -17,7 +18,8 @@ "negative": { "credit": [ "You can't bet a negative amount of credits!", - "What are you trying to do? Steal someone's credits? That's illegal, you know." + "What are you trying to do? Steal someone's credits? That's illegal, you know.", + "Robbing a bank would reel you in more credits than gambling negative credits." ], "craft": [ "You can't craft a negative number, baka!", @@ -25,7 +27,7 @@ ], "default": [ "No negative values in this established command, baka!", - "Negatives? Here? Lmao. You're really funny!" + "Negatives? Here? HA! You're really funny!" ] }, "zero": { @@ -53,7 +55,8 @@ ], "default": [ "Decimals? That's like giving me fraction work. No thanks!", - "Decimals: fun to look at, not possible with what you are trying to do." + "Decimals: fun to look at, not possible with what you are trying to do.", + "The only decimals I like to look at is in human currency. My credits are not that so keep them away!" ] } }, @@ -61,7 +64,10 @@ "You haven't redeemed your first daily yet! :cry:", "You haven't signed up and received your credits yet! D:", "You need some credits to do this, baka! Get some with the daily command!", - "Credits speak a whole lot of value in these parts. Set yourself up with a daily command first!" + "Credits speak a whole lot of value in these parts. Set yourself up with a daily command first!", + "Get yourself some credits first!", + "Where are your credits?! Oh. You haven't redeemed your first daily yet...", + "Oh... you didn't redeem your first daily yet..." ], "lessCredit": [ "You don't have that many credits, baka!", @@ -82,11 +88,13 @@ ], "rep": [ "You can't give rep to a bot user. However, as long as you keep interacting with them, I'm sure they will be happy! :smile:", - "Bots can't have rep, baka!" + "Bots can't have rep, baka!", + "A bot's reputation is on how well you like it. It doesn't need points to show it." ], "exchange": [ "You can't give your credits to a bot user!", - "Exchanging to a bot user is just not possible. They are known to do foul things with money from time to time." + "Exchanging to a bot user is just not possible. They are known to do foul things with money from time to time.", + "Nope! No can do. Bots can't have credits." ], "award": [ "Awarding a non-existant user? Wow, I think we've hit a new low here.", @@ -126,7 +134,8 @@ "badDaily": [ "Nani?!?! You can't give other people credits if you haven't recieved your first daily yet!", "You have not gotten your first daily yet!", - "You aren't in my records. You should redeem your first daily before giving to others." + "You aren't in my records. You should redeem your first daily before giving to others.", + "Earn a bit yourself with the daily command before giving to others!" ], "multi": [ "You are trying to cheat my daily command! Rude!", @@ -134,5 +143,21 @@ "You have already redeemed your daily for today.", "No stealing! I already payed your daily worth of credits today, baka!" ] - } + }, + "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-." + ], + "fish": [ + "-user1-, you have caught -fish-.", + "Looks like -user1- just caught a -fish-.", + "Nice catch! You just caught yourself -fish-." + ], + "craft": [ + "You have crafted -num- -item-.", + "-num- -item- has been successfully crafted and added to your inventory.", + "-num- brand new -item- is now in your inventory." + ] } \ No newline at end of file diff --git a/commands/Economy/Cooking/craft.js b/commands/Economy/Cooking/craft.js index 95b69e9..49a22ff 100644 --- a/commands/Economy/Cooking/craft.js +++ b/commands/Economy/Cooking/craft.js @@ -35,7 +35,7 @@ exports.run = async (client, msg, [item, amount]) => { db.get(`SELECT ${names} FROM material WHERE userId = "${msg.author.id}"`, [], (err, row) => { if (err) { return console.log(err); } - if (!row) { return msg.reply("You haven't redeemed your first daily yet!"); } + if (!row) { return msg.reply(client.speech(["noRow"])); } let invAmount = Object.values(row); for (var x = 0; x < recipe.length; x++) { @@ -50,7 +50,7 @@ exports.run = async (client, msg, [item, amount]) => { db.run(`UPDATE product SET ${product.name} = ${Object.values(row)[0] + amount} WHERE userId = ${msg.author.id}`); }); - msg.channel.send("You have crafted " + amount + " " + product.emote); + msg.channel.send(client.speech(["craft"]).replace("-num-", amount).replace("-item-", product.emote)); }); db.close(); }); @@ -69,7 +69,6 @@ exports.conf = { exports.help = { name: "craft", description: "Make items!", - usage: "[item:str] [amount:str]", - usageDelim: " ", + usage: "[item:str] [amount:str]", usageDelim: " ", humanUse: "(item name)_(amount|help)" }; \ No newline at end of file diff --git a/commands/Economy/Cooking/fish.js b/commands/Economy/Cooking/fish.js index 8e1edb6..9c8af79 100644 --- a/commands/Economy/Cooking/fish.js +++ b/commands/Economy/Cooking/fish.js @@ -25,8 +25,7 @@ exports.run = async (client, msg) => { var result = (kind === "trash") ? "You have lost 10 credits" : "You have placed the fish in your inventory"; if (kind !== "trash") { db.run(`UPDATE material SET ${kind} = ${Number(Fisher[1][results]) + 1} WHERE userId = ${msg.author.id}`); } - - msg.channel.send(`${msg.author.username}, you have caught ${items[kind].emote}. ${result}.`); + msg.channel.send(client.speech(["fish"]).replace("-user1-", msg.author.username).replace("-fish-", items[kind].emote) + " " + result); }); db.close(); }); diff --git a/commands/Economy/Cooking/sell.js b/commands/Economy/Cooking/sell.js index f76e391..1da0d80 100644 --- a/commands/Economy/Cooking/sell.js +++ b/commands/Economy/Cooking/sell.js @@ -6,7 +6,7 @@ exports.run = async (client, msg, [item, amount]) => { db.get(`SELECT ${object.name} FROM ${object.category[0]} WHERE userId = "${msg.author.id}"`, [], (err, row) => { if (err) { return console.log(err); } - if (!row) { return msg.reply("You have not redeemed your first daily yet!"); } + if (!row) { return msg.reply(client.speech(["noRow"])); } amount = (amount === undefined) ? Object.values(row)[0] : amount; if (amount > row) { return msg.channel.send("You don't have that much " + object.name + ", baka!"); } diff --git a/commands/Fun/say.js b/commands/Fun/say.js index a7b0385..2d78852 100644 --- a/commands/Fun/say.js +++ b/commands/Fun/say.js @@ -11,11 +11,11 @@ exports.conf = { runIn: ["text"], aliases: ["echo", "talk"], permLevel: 0, - botPerms: [], + botPerms: [] }; exports.help = { name: "say", description: "Have Margarine echo what you said.", - usage: "[msg:str]", + usage: "[msg:str]" }; diff --git a/commands/General/mal.js b/commands/General/mal.js index 8ff810e..a5dcf72 100644 --- a/commands/General/mal.js +++ b/commands/General/mal.js @@ -6,8 +6,7 @@ exports.run = async (client, msg, [term]) => { request(url + term, function(err, res, body) { $ = cheerio.load(body); - var text = $.text().split(" "); var x = 0; var info = new Object(); - info.aStats = new Object(); info.mStats = new Object(); + var text = $.text().split(" "); var x = 0; 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() : ""; diff --git a/index.js b/index.js index a5ea66d..9674613 100644 --- a/index.js +++ b/index.js @@ -1,29 +1,49 @@ const Komada = require("komada"); +const Discord = require("discord.js"); const config = require("./assets/settings.json"); +const speech = require("./assets/speech.json"); const permStructure = new Komada.PermLevels() .addLevel(0, false, () => true) - .addLevel(2, false, (client,msg) => { + .addLevel(2, false, (client, msg) => { if (!msg.guild || !msg.guild.settings.modRole) { return false; } const modRole = msg.guild.roles.get(msg.guild.settings.modRole); return modRole && msg.member.roles.has(modRole.id); }) - .addLevel(3, false, (client,msg) => { + .addLevel(3, false, (client, msg) => { if (!msg.guild || !msg.guild.settings.adminRole) { return false; } const adminRole = msg.guild.roles.get(msg.guild.settings.adminRole); return adminRole && msg.member.roles.has(adminRole.id); }) - .addLevel(4, false, (client,msg) => msg.guild && msg.author.id === msg.guild.owner.id) - .addLevel(9, false, (client,msg) => msg.author.id === config.secondary) - .addLevel(10, false, (client,msg) => msg.author === client.owner); + .addLevel(4, false, (client, msg) => msg.guild && msg.author.id === msg.guild.owner.id) + .addLevel(9, false, (client, msg) => msg.author.id === config.secondary) + .addLevel(10, false, (client, msg) => msg.author === client.owner); const client = new Komada.Client({ ownerID: config.ownerID, prefix: config.prefix, - clientOptions: { - fetchAllMembers: false, - }, - cmdLogging: false, + clientOptions: { fetchAllMembers: false }, + cmdLogging: false }); +client.speech = function(keys) { + if (!keys) { throw new Error("Keys missing in function call!"); } + var t = speech; + for (var x = 0; x < keys.length; x++) { t = t[keys[x]]; } + return t[Math.floor(Math.random() * t.length)]; +}; + +client.ownerSetting = new Discord.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 "database": + client.ownerSetting.set("database", config.database); break; + } +}; + client.login(config.token); \ No newline at end of file diff --git a/monitors/prefixHelp.js b/monitors/prefixHelp.js index e2b92a7..ade1a8a 100644 --- a/monitors/prefixHelp.js +++ b/monitors/prefixHelp.js @@ -1,7 +1,7 @@ exports.conf = { enabled: true, ignoreBots: false, - ignoreSelf: false, + ignoreSelf: false }; exports.run = (client, msg) => { From 0a232f43b5ed9e733a25db8450c4b0a2ebfe0b56 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Sun, 8 Jul 2018 03:47:38 -0400 Subject: [PATCH 05/38] Redo + Fixes userSearch function now grabs speech from the function in the client. Fixed the report command not finding the report numbers. Fixed the info command in finding values and when using the mention instead of prefix. Added a couple more commands in terms of using speech. --- commands/Economy/Games/twoup.js | 5 +- commands/Economy/balance.js | 5 +- commands/Economy/daily.js | 2 +- commands/Economy/exchange.js | 21 ++++--- commands/Economy/rep.js | 4 +- commands/Fun/Interactions/baka.js | 2 +- commands/Fun/roll.js | 5 +- commands/Fun/rps.js | 4 +- commands/General/avatar.js | 10 ++-- commands/General/greet.js | 4 +- commands/General/info.js | 92 ++++++++++++++----------------- commands/General/report.js | 7 +-- commands/System/stats.js | 2 +- functions/userSearch.js | 48 +++++++--------- index.js | 2 +- 15 files changed, 98 insertions(+), 115 deletions(-) diff --git a/commands/Economy/Games/twoup.js b/commands/Economy/Games/twoup.js index 5ef9f94..20dc569 100644 --- a/commands/Economy/Games/twoup.js +++ b/commands/Economy/Games/twoup.js @@ -31,7 +31,6 @@ exports.conf = { exports.help = { name: "twoup", description: "Bet on coin flips. Get two heads in a row and win or hope for all five odds!", - usage: "[bet:int]", - 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, in part to mark a shared experience with Diggers through the ages.", - humanUse: "(Amount)" + usage: "[bet:int]", humanUse: "(Amount)", + 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, in part to mark a shared experience with Diggers through the ages." }; \ No newline at end of file diff --git a/commands/Economy/balance.js b/commands/Economy/balance.js index 349ec82..ae80868 100644 --- a/commands/Economy/balance.js +++ b/commands/Economy/balance.js @@ -2,7 +2,7 @@ exports.run = async (client, msg, [user]) => { const sqlite3 = require("sqlite3").verbose(); let db = new sqlite3.Database("./assets/data/score.sqlite"); - var data = await client.funcs.userSearch(msg, {user: [user], tags:["bot"], name: this.help.name}); + var data = await client.funcs.userSearch(client, msg, {user: [user], tags:["bot"], name: this.help.name}); if (data.valid === false) { return; } db.get(`SELECT * FROM scores WHERE userId = "${data.user[0].id}"`, [], (err, row) => { @@ -45,6 +45,5 @@ exports.conf = { exports.help = { name: "balance", description: "Check credit amount and the last time the user recieved their daily.", - usage: "[user:str]", - humanUse: "(user)" + usage: "[user:str]", humanUse: "(user)" }; \ No newline at end of file diff --git a/commands/Economy/daily.js b/commands/Economy/daily.js index f318c53..7f737f5 100644 --- a/commands/Economy/daily.js +++ b/commands/Economy/daily.js @@ -3,7 +3,7 @@ let db = new sqlite3.Database("./assets/data/score.sqlite"); let talk = require("../../assets/speech.json"); exports.run = async (client, msg, [user]) => { - var data = await client.funcs.userSearch(msg, {user: [user], tags:["bot"], name: this.help.name}); + var data = await client.funcs.userSearch(client, msg, {user: [user], tags:["bot"], name: this.help.name}); if (data.valid === false) { return; } user = data.user[0]; diff --git a/commands/Economy/exchange.js b/commands/Economy/exchange.js index 893ccb5..065b45f 100644 --- a/commands/Economy/exchange.js +++ b/commands/Economy/exchange.js @@ -2,17 +2,17 @@ exports.run = async (client, msg, [user, credit]) => { const sqlite3 = require("sqlite3").verbose(); let db = new sqlite3.Database("./assets/data/score.sqlite"); - var data = await client.funcs.userSearch(msg, {user: [user], tags:["bot"], name: this.help.name}); + var data = await client.funcs.userSearch(client, msg, {user: [null, user], tags:["bot"], name: this.help.name}); if (data.valid === false) { return; } - user = data.user[0]; + user = data.user[1]; if (user.id === msg.author.id) { return msg.channel.send("Why are you trying to exchange credits to yourself? I doubt you are that lonely in life."); } db.get(`SELECT credits FROM scores WHERE userId = "${msg.author.id}"`, [], (err, row) => { if (err) { return console.log(err); } - if (!row) { return msg.reply("You haven't signed up and received your credits yet! D: Use `m~daily` (Using default prefix) to earn your first amount of credits."); } - if (row.credits < credit) { return msg.reply("You don't have that many credits, baka!"); } - + if (!row) { return msg.reply(client.speech(["noRow"])); } + if (row.credits < credit) { return msg.reply(client.speech(["lessCredit"])); } + db.get(`SELECT credits FROM scores WHERE userId = "${user.id}"`, [], (err, row) => { if (!row) { return msg.reply("That user has not gotten their first daily yet!"); } db.run(`UPDATE scores SET credits = ${Number(row.credits) + credit} WHERE userId = ${user.id}`); @@ -22,7 +22,11 @@ exports.run = async (client, msg, [user, credit]) => { }); db.close(); - msg.reply(`You have given ${credit} credits to ${user.prefered}`); + msg.channel.send(client.speech(["exchange"]) + .replace("-user1-", data.user[0].ping) + .replace("-user2-", user.prefered) + .replace("-credit-", credit) + ); }; exports.conf = { @@ -32,13 +36,12 @@ exports.conf = { permLevel: 0, botPerms: [], requiredFuncs: ["userSearch"], - cooldown: 10, + cooldown: 10 }; exports.help = { name: "exchange", description: "Give someone some of your credits.", - usage: "[user:str] [credit:int]", - usageDelim: " ", + usage: "[user:str] [credit:int]", usageDelim: " ", humanUse: "(Required: User)_(Required: Credit)" }; \ No newline at end of file diff --git a/commands/Economy/rep.js b/commands/Economy/rep.js index ee5cf80..fcbfd25 100644 --- a/commands/Economy/rep.js +++ b/commands/Economy/rep.js @@ -2,7 +2,7 @@ const sqlite3 = require("sqlite3").verbose(); let db = new sqlite3.Database("./assets/data/score.sqlite"); exports.run = async (client, msg, [user, ...note]) => { - var data = await client.funcs.userSearch(msg, {user: [user], tags:["bot"], name: this.help.name}); + var data = await client.funcs.userSearch(client, msg, {user: [user], tags:["bot"], name: this.help.name}); if (data.valid == false) { return; } user = data.user[0]; @@ -11,7 +11,7 @@ exports.run = async (client, msg, [user, ...note]) => { db.get(`SELECT repDaily, rep FROM scores WHERE userId = "${msg.author.id}"`, [], (err, row) => { if (err) { return console.log(err); } - if (!row) { return msg.reply("You have not redeemed your first daily yet!"); } + if (!row) { return msg.reply(client.speech(["noRow"])); } if ((Number(row.repDaily) + 86400000) > Date.now()) { return msg.reply("You've already have given someone else rep today!"); } db.get(`SELECT rep FROM scores WHERE userId = "${user.id}"`, [], (err, row) => { diff --git a/commands/Fun/Interactions/baka.js b/commands/Fun/Interactions/baka.js index f0dde40..7c81dbf 100644 --- a/commands/Fun/Interactions/baka.js +++ b/commands/Fun/Interactions/baka.js @@ -1,5 +1,5 @@ exports.run = async (client, msg, [user]) => { - var data = await client.funcs.userSearch(msg, {user: [user], name: this.help.name}); + var data = await client.funcs.userSearch(client, msg, {user: [user], name: this.help.name}); if (data.valid !== false) { msg.channel.send("Baka " + data.user[0].prefered + "!"); } }; diff --git a/commands/Fun/roll.js b/commands/Fun/roll.js index a8c32cd..30cd599 100644 --- a/commands/Fun/roll.js +++ b/commands/Fun/roll.js @@ -15,12 +15,11 @@ exports.conf = { runIn: ["text"], aliases: [], permLevel: 0, - botPerms: [], + botPerms: [] }; exports.help = { name: "roll", description: "Roll a die!", - usage: "[sides:str]", - usageDelim: "", + usage: "[sides:str]" }; \ No newline at end of file diff --git a/commands/Fun/rps.js b/commands/Fun/rps.js index c9efaf2..fbd41d1 100644 --- a/commands/Fun/rps.js +++ b/commands/Fun/rps.js @@ -1,6 +1,6 @@ exports.run = async (client, msg, [choice, user]) => { if (!user) { user = client.user.id; } - var data = await client.funcs.userSearch(msg, {user: [null, user], name: this.help.name}); + var data = await client.funcs.userSearch(client, msg, {user: [null, user], name: this.help.name}); if (data.valid === false) { return; } if (data.user[1].id === msg.author.id) { msg.channel.send("Hey! You can't play rock, paper, scissors with yourself! Invite someone into the mix or play with me instead!"); } @@ -21,7 +21,7 @@ exports.conf = { aliases: [], permLevel: 0, botPerms: [], - requiredFuncs: ["userSearch"], + requiredFuncs: ["userSearch"] }; exports.help = { diff --git a/commands/General/avatar.js b/commands/General/avatar.js index 715fd75..6d1d84b 100644 --- a/commands/General/avatar.js +++ b/commands/General/avatar.js @@ -1,9 +1,9 @@ exports.run = async (client, msg, [user]) => { - var data = await client.funcs.userSearch(msg, {user: [user], name: this.help.name}); - - if (data.valid !== false) { - client.users.fetch(data.user[0].id).then(avatar => { msg.channel.send("", { files: [avatar.displayAvatarURL()]}); }); - } + client.funcs.userSearch(client, msg, {user: [user], name: this.help.name}).then(data => { + if (data.valid !== false) { + client.users.fetch(data.user[0].id).then(avatar => { msg.channel.send("", { files: [avatar.displayAvatarURL()]}); }); + } + }); }; exports.conf = { diff --git a/commands/General/greet.js b/commands/General/greet.js index 30c4bc5..75bd493 100644 --- a/commands/General/greet.js +++ b/commands/General/greet.js @@ -1,8 +1,6 @@ exports.run = async (client, msg, user) => { - var data = await client.funcs.userSearch(msg, {user: [user], name: this.help.name}); - + var data = await client.funcs.userSearch(client, msg, {user: [user], name: this.help.name}); if (data.valid === false) { return; } - if (data.user[0].id === client.user.id) { return msg.channel.send(`Why would you try and make me greet myself, ${msg.author.username}? I'm not that lonely!`); } msg.channel.send(`Hello ${data.user[0].prefered}! `); diff --git a/commands/General/info.js b/commands/General/info.js index 62c1e15..99a9efe 100644 --- a/commands/General/info.js +++ b/commands/General/info.js @@ -1,66 +1,59 @@ exports.run = async (client, message, [kind, search]) => { let guild = message.channel.guild; - let msg = message.content.slice(2).split(" "); + let msg = (message.content.startsWith("<")) ? message.content.slice(client.user.id.length + 4).split(" ") : message.content.slice(2).split(" "); var x = (msg[0] === "info") ? 1 : 0; - var kind = msg[x]; - var user = msg.slice(x + 1).join(" "); + var kind = msg[x]; var user = msg.slice(x + 1).join(" "); const embed = new client.methods.Embed() .setTimestamp() .setFooter(guild.name, guild.iconURL()); - if (kind === "user") { - var data = await client.funcs.userSearch(message, {user: [user], name: this.help.name}); - if (data.valid === false) { return; } - - user = client.users.find("username", data.user[0].username); + switch (kind) { + case "user": + var data = await client.funcs.userSearch(client, message, {user: [user], name: this.help.name}); + if (data.valid === false) { return; } + user = await Promise.resolve(client.users.fetch(data.user[0].id)); - const statusList = { - online: "Online", - idle: "Idle", - dnd: "Do not Disturb" - }; + const statusList = { + online: "Online", + idle: "Idle", + dnd: "Do not Disturb" + }; - var Status = statusList[user.presence.status] || "Offline"; - var botUser = user.bot ? "True": "False"; - var activity = user.presence.activity !== null ? " - " + user.presence.activity.name: " "; + var Status = statusList[user.presence.status] || "Offline"; + var botUser = user.bot ? "True": "False"; + var activity = user.presence.activity !== null ? " - " + user.presence.activity.name: " "; - embed.setThumbnail(user.displayAvatarURL()) - .setColor(0x04d5fd) - .setAuthor("User: " + user.tag) - .setDescription("ID: " + user.id) - .addField("Created:", user.createdAt.toLocaleString(), true) - .addField("Joined:", guild.members.get(user.id).joinedAt.toLocaleString(), true) - .addField("Bot user:", botUser, true) - .addField("Status:", Status + activity, true); - } - - else if (kind === "role") { - let role = guild.roles.find("name", user); - - if (!role) { return message.channel.send("Looks like I can't find the role. My searchs are case-sensitive so please check before retyping."); } + embed.setThumbnail(user.displayAvatarURL()) + .setAuthor("User: " + user.tag) + .setDescription("ID: " + user.id) + .addField("Created:", user.createdAt.toLocaleString(), true) + .addField("Joined:", guild.members.get(user.id).joinedAt.toLocaleString(), true) + .addField("Bot user:", botUser, true) + .addField("Status:", Status + activity, true); break; + case "role": + guild.roles.forEach(element => { if (element.name.toLowerCase() === user.toLowerCase()) { role = element; } }); + if (!role) { return message.channel.send("Looks like I can't find the role. Be sure it is spelled correctly."); } - embed.addField("Role:", `${role.name} - ${role.id}`) - .setColor(role.hexColor) - .addField("Position:", role.position, true) - .addField("Hex Colour:", role.hexColor, true) - .addField("Users:", role.members.size, true); - } + embed.addField("Role:", `${role.name} - ${role.id}`) + .addField("Position:", role.position, true) + .addField("Hex Colour:", role.hexColor, true) + .addField("Users:", role.members.size, true); break; + case "server": + if (user) { return message.reply("You can't ask information about a server with additional stuff!"); } - else if (kind === "server") { - if (!user) { embed.setThumbnail(guild.iconURL()) - .setColor(0x04d5fd) - .addField("Region:", guild.region, true) - .addField("Created:", guild.createdAt.toLocaleString(), true) - .addField("Owner:", `${guild.owner.user.tag} - ${guild.owner.id}`) - .addField("Members:", `${guild.memberCount - guild.members.filter(m => m.user.bot).size} (${guild.members.filter(m => m.user.bot).size} bots)`, true) - .addField("Roles:", guild.roles.size, true); - } - else { return message.reply("You can't ask information about a server with additional stuff!"); } - } + .addField("Region:", guild.region, true) + .addField("Created:", guild.createdAt.toLocaleString(), true) + .addField("Owner:", `${guild.owner.user.tag} - ${guild.owner.id}`) + .addField("Members:", `${guild.memberCount - guild.members.filter(m => m.user.bot).size} (${guild.members.filter(m => m.user.bot).size} bots)`, true) + .addField("Roles:", guild.roles.size, true); break; + default: return message.channel.send("You didn't give a correct search term. Do either server, user, or role."); + }; + var colour = (kind === "role") ? role.hexColor : 0x04d5fd; + embed.setColor(colour); message.channel.send({embed}); }; @@ -75,9 +68,8 @@ exports.conf = { exports.help = { name: "info", - description: "Get the server or user information.", - usage: "[server|user|role] [search:str]", - usageDelim: " ", + description: "Get the server, role, or user information.", + usage: "[server|user|role] [search:str]", usageDelim: " ", extendedHelp: "Need Discord info? I got you covered with this command!", humanUse: "([If not specified] server|user|role)_(search content)" }; \ No newline at end of file diff --git a/commands/General/report.js b/commands/General/report.js index 2c1275f..02d7e3a 100644 --- a/commands/General/report.js +++ b/commands/General/report.js @@ -1,6 +1,5 @@ const sqlite3 = require("sqlite3").verbose(); let db = new sqlite3.Database("./assets/data/score.sqlite"); -const reportChannel = require("../../assets/settings.json").owner.channels.report; exports.run = async (client, msg) => { const reports = []; @@ -35,7 +34,7 @@ exports.run = async (client, msg) => { msg.author.send(text[1]).then(() => { msg.author.dmChannel.awaitMessages(m => m.content, { max: 1, time: 130000, errors: ["time"], }).then((collected) => { reports.push(collected.first().content); - db.get("SELECT reportNumber FROM stats WHERE statName = 'general'", [], (err, row) => { + db.get("SELECT reportNumber FROM stats WHERE statName = 'report'", [], (err, row) => { if (err) { return console.log(err); } const embed = new client.methods.Embed() @@ -52,7 +51,7 @@ exports.run = async (client, msg) => { \nYour report has been sent! Any more questions, please ask Butterstroke#7150!`); db.run(`UPDATE stats SET reportNumber = ${row.reportNumber + 1} WHERE statName ="general"`); - client.channels.get(reportChannel).send({embed}); + client.channels.get(client.ownerSetting.get("channels").report).send({embed}); msg.author.send({embed: DMembed}); }); db.close(); @@ -67,7 +66,7 @@ exports.conf = { runIn: ["text"], aliases: [], permLevel: 0, - botPerms: [], + botPerms: [] }; exports.help = { diff --git a/commands/System/stats.js b/commands/System/stats.js index 48c5b1e..258d135 100644 --- a/commands/System/stats.js +++ b/commands/System/stats.js @@ -25,7 +25,7 @@ exports.run = async (client, message) => { exports.conf = { enabled: true, - runIn: ["text"], + runIn: ["text", "dm"], aliases: [], permLevel: 0, botPerms: [] diff --git a/functions/userSearch.js b/functions/userSearch.js index 9264728..4d0f172 100644 --- a/functions/userSearch.js +++ b/functions/userSearch.js @@ -1,40 +1,34 @@ -const speech = require("../assets/speech.json")["userSearch"]; - -module.exports = async (msg, args) => { +module.exports = async (client, msg, args) => { var users = args.user || [null]; var tags = args.tags || ["None"]; var amount = args.user.length; var x = 0; var data = []; do { - var user = users[x]; var valid = false; - - if (user == null) { user = msg.author; } - else if (msg.mentions.users.size > 0) { user = msg.mentions.users.first(); } - else if (/^(\d{17,21})$/.test(user)) { user = await Promise.resolve(msg.client.users.fetch(user)); } - else if (msg.client.users.find("username", user) !== null) { user = msg.client.users.find("username", user); } - + if (users[x] == null || users[x].length < 1) { var user = msg.author; } + else if (msg.mentions.users.size > 1 && msg.content.startsWith("<")) { + var item = Array.from(msg.mentions.users); + var user = item[1]; + } else if (msg.mentions.users.size > 0 && msg.content.startsWith("<") === false) { var user = msg.mentions.users.first(); } + else if (/^(\d{17,21})$/.test(users[x])) { var user = await Promise.resolve(msg.client.users.fetch(users[x])); } + else if (msg.client.users.get("username", users[x]) !== null) { var user = msg.client.users.get("username", users[x]); } + + if (!user) { var user = users[x]; } msg.channel.guild.members.forEach(element => { - if (valid === false) { - if (typeof user === "object") { - if (element.user.username.toLowerCase() === user.username.toLowerCase()) { - data.push(this.userObjects(element)); - valid === true; - } - } else { - if (element.nickname) { - if (element.nickname.toLowerCase() === user.toLowerCase()) { - data.push(this.userObjects(element)); - valid === true; - } - } + if (typeof user === "object") { + if (element.user.username.toLowerCase() === user.username.toLowerCase()) { + data.push(this.userObjects(element)); + } + } else if (element.nickname) { + if (element.nickname.toLowerCase() === user.toLowerCase()) { + data.push(this.userObjects(element)); } } - }); + }); x++; } while (x < amount); - if (data.length !== args.user.length) { var text = speech["default"][Math.floor(Math.random() * speech["default"].length)]; } - else if (tags.includes("bot") && user.bot === true) { var text = speech[args.name][Math.floor(Math.random() * speech[args.name].length)]; } + if (data.length !== args.user.length) { var text = client.speech(["userSearch", "default"]); } + else if (tags.includes("bot") && user.bot === true) { var text = client.speech(["userSearch", args.name]); } var valid = (text) ? false : true; if (valid === false) { msg.channel.send(text); data = text; } @@ -67,5 +61,5 @@ exports.userObjects = (element) => { joined: element.joinedTimestamp, roles: element._roles } - } + }; }; \ No newline at end of file diff --git a/index.js b/index.js index 9674613..94ff016 100644 --- a/index.js +++ b/index.js @@ -44,6 +44,6 @@ for (var x = 0; keys.length > x; x++) { case "database": client.ownerSetting.set("database", config.database); break; } -}; +} client.login(config.token); \ No newline at end of file From 6ae678e68eeda161326eabaaa93574b0a18a4dc0 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Mon, 20 Aug 2018 02:25:09 -0400 Subject: [PATCH 06/38] Patched Anilist Command Fixed the errors with the Anilist command Added more items into the client for future use. --- commands/General/anilist.js | 70 ++-- commands/General/mal.js | 10 +- index.js | 17 +- package-lock.json | 735 ++++++++++++------------------------ package.json | 2 +- 5 files changed, 285 insertions(+), 549 deletions(-) diff --git a/commands/General/anilist.js b/commands/General/anilist.js index 9e6b182..8fb1777 100644 --- a/commands/General/anilist.js +++ b/commands/General/anilist.js @@ -1,58 +1,36 @@ -const puppeteer = require("puppeteer"); +const fetch = require("node-fetch"); exports.run = async (client, msg, [term]) => { - const infoHelp = { - anime: ["šŸ’š Watching", "šŸ—“ Planned", "šŸ’™ Completed", "šŸ’” Dropped", "šŸ’› Paused"], - manga: ["šŸ“— Reading", "šŸ—“ Planned", "šŸ“˜ Completed", "šŸ“• Dropped", "šŸ“™ Paused"] + var options = { + method: 'POST', + headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, + body: JSON.stringify({ query: `query ($name: String) { User(name: $name) { avatar { medium } siteUrl + stats { watchedTime chaptersRead animeListScores { meanScore } mangaListScores { meanScore } + animeStatusDistribution { status amount } mangaStatusDistribution { status amount } } + } }`, variables: { name: term } }) }; + var response = await fetch('https://graphql.anilist.co', options); + var json = await response.json(); + if (!json.data.stats) { return msg.channel.send("Anilist profile by that user is not found!"); } + var data = json.data.User, + anime = data.stats.animeStatusDistribution, + manga = data.stats.mangaStatusDistribution; - const url = "https://anilist.co/user/" + term; - const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']}); - const page = await browser.newPage(); + var animeL = ["šŸ’š Watching " + anime[0].amount, "šŸ—“ Planned " + anime[1].amount, "šŸ’™ Completed " + anime[2].amount, "šŸ’” Dropped " + anime[3].amount, "šŸ’› Paused " + anime[4].amount]; + var mangaL = ["šŸ“— Reading " + manga[0].amount, "šŸ—“ Planned " + manga[1].amount, "šŸ“˜ Completed " + manga[2].amount, "šŸ“• Dropped " + manga[3].amount, "šŸ“™ Paused " + manga[4].amount]; - await page.goto(url + "/stats"); - await page.waitFor(2000); - if (page.target()._targetInfo.url === "https://anilist.co/404") { return msg.channel.send("Whoops! Looks like a user by that name does not exist."); } - - var lists = await page.evaluate(() => { - var aList = document.querySelector("#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-a").innerHTML; - var mList = document.querySelector("#app > div.page-content > div > div.content.container > div > div.stats-wrap > div:nth-child(1) > div > div.chart > svg > g:nth-child(2) > g.ct-series.ct-series-b").innerHTML; - return [aList.split(""), mList.split("")]; - }); - - await page.goto(url); - - var stats = await page.evaluate(() => { - var ava = document.querySelector("#app > div.page-content > div > div.header-wrap > div.banner > div.container > div > img").getAttribute("src"); - var num = document.querySelector("#app > div.page-content > div > div.content.container > div > div:nth-child(2) > div.stats-wrap > div:nth-child(1) > div.stats-wrap").innerText.split(" "); - var ber = document.querySelector("#app > div.page-content > div > div.content.container > div > div:nth-child(2) > div.stats-wrap > div:nth-child(2) > div.stats-wrap").innerText.split(" "); - return [num[0].slice(0, -5), num[2].slice(6, -5), ber[0].slice(0, -9), ber[2].slice(6, -5), ava]; - }); - - await browser.close(); - - var aDisplay = []; var mDisplay = []; - var y = 0; for (var x = 0; x < lists[0].length; x++) { - if (!lists[0][x].endsWith(">") && lists[0][x].length > 1) { aDisplay.push(infoHelp.anime[y] + ": " + lists[0][x].slice(lists[0][x].search("text\">") + 6)); y++; } - else if (lists[0][x].endsWith(">")) { aDisplay.push(infoHelp.anime[y] + ": 0"); y++; } - } - var y = 0; for (var x = 0; x < lists[1].length; x++) { - if (!lists[1][x].endsWith(">") && lists[1][x].length > 1) { mDisplay.push(infoHelp.manga[y] + ": " + lists[1][x].slice(lists[1][x].search("text\">") + 6)); y++; } - else if (lists[1][x].endsWith(">")) { mDisplay.push(infoHelp.manga[y] + ": 0"); y++; } - } - const embed = new client.methods.Embed() .setTitle(term + "'s AniList Profile") - .setURL(url + "/") - .setDescription("šŸ•“ Watch Days: " + stats[0] + "\nšŸ”– Manga Chapters: " + stats[2]) - .addField("__Anime:__", "šŸ“Š Mean Score: " + stats[1] + "\n" + aDisplay.join("\n"), true) - .addField("__Manga:__", "šŸ“Š Mean Score: " + stats[3] + "\n" + mDisplay.join("\n"), true) + .setURL(data.siteUrl) + .setDescription("šŸ•“ Watch Days: " + data.stats.watchedTime + "\nšŸ”– Manga Chapters: " + data.stats.chaptersRead) + .addField("__Anime:__", "šŸ“Š Mean Score: " + data.stats.animeListScores.meanScore + "\n" + animeL.join("\n"), true) + .addField("__Manga:__", "šŸ“Š Mean Score: " + data.stats.mangaListScores.meanScore + "\n" + mangaL.join("\n"), true) .setTimestamp() .setColor(0x2E51A2) - .setThumbnail(stats[4]) + .setThumbnail(data.avatar.medium) .setFooter("Requested by: " + msg.author.tag); - - msg.channel.send({embed}); + + msg.channel.send({embed}); }; exports.conf = { @@ -66,7 +44,7 @@ exports.conf = { exports.help = { name: "anilist", - description: "Fetch a user's profile on AniList", + description: "Fetch a data's profile on AniList", usage: "[term:str]", humanUse: "(AniList profile name)", extendedHelp: "There is a 60 second cooldown for each profile search to not spam the site." }; \ No newline at end of file diff --git a/commands/General/mal.js b/commands/General/mal.js index a5dcf72..648013b 100644 --- a/commands/General/mal.js +++ b/commands/General/mal.js @@ -21,13 +21,9 @@ exports.run = async (client, msg, [term]) => { } else if (isNaN(zed) === false) { info.status = z.slice(6) + " " + y + " " + zed; } } if (z.includes("Birthday") && !info.birthday) { - if (y.includes("Location")) { - var num = (z.length - z.search("Birthday")) * (-1); - var baka = y.slice(0, y.search("Location")); - } else { - var num = (z.length - z.search("Birthday")) * (-1); - var baka = y.slice(-1) === "," ? y + " " + zed.slice(0, 4) : y; - } + var num = (z.length - z.search("Birthday")) * (-1); + if (y.includes("Location")) { var baka = y.slice(0, y.search("Location")); } + else { var baka = y.slice(-1) === "," ? y + " " + zed.slice(0, 4) : y; } info.birthday = z.slice(num + 8) + " " + baka; } if (z.includes("Gender")) { var amount = (z.search("Birthday")) ? z.search("Birthday") : null; diff --git a/index.js b/index.js index 94ff016..9eb3f65 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,9 @@ const Komada = require("komada"); const Discord = require("discord.js"); const config = require("./assets/settings.json"); const speech = require("./assets/speech.json"); +const localization = require("./assets/localization.json"); +const items = require("./assets/values/items.json"); +const recipes = require("./assets/values/recipes.json"); const permStructure = new Komada.PermLevels() .addLevel(0, false, () => true) @@ -26,11 +29,12 @@ const client = new Komada.Client({ cmdLogging: false }); -client.speech = function(keys) { +client.speech = function(keys, msg) { if (!keys) { throw new Error("Keys missing in function call!"); } var t = speech; for (var x = 0; x < keys.length; x++) { t = t[keys[x]]; } - return t[Math.floor(Math.random() * t.length)]; + var text = t[Math.floor(Math.random() * t.length)]; var prefix = msg.guildSettings.prefix || config.prefix; + return text.replace("-prefix-", prefix); }; client.ownerSetting = new Discord.Collection(); @@ -39,11 +43,12 @@ 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 "database": - client.ownerSetting.set("database", config.database); break; + for (var y = 0; key.length > y; y++) { client.ownerSetting.set(key[y], config.owner[key[y]]); } break; + case "database": client.database = config.database; break; } } +client.ownerSetting.set("permLevel", localization.permLevels); +client.database.items = items; +client.database.recipes = recipes; client.login(config.token); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d6589eb..74526f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,23 +9,15 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.88.tgz", "integrity": "sha512-bYDPZTX0/s1aihdjLuAgogUAT5M+TpoWChEMea2p0yOcfn5bu3k6cJb9cp6nw268XeSNIGGr+4+/8V5K6BGzLQ==" }, - "agent-base": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.0.tgz", - "integrity": "sha512-c+R/U5X+2zz2+UCrCFv6odQzJdoqI+YecuhnAJLa1zYaMc13zPfwMwZrr91Pd1DYNo/yPRbiM4WVf9whgwFsIg==", - "requires": { - "es6-promisify": "5.0.0" - } - }, "ajv": { "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.1.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" } }, "asn1": { @@ -58,18 +50,13 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, "bcrypt-pbkdf": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" }, "dependencies": { "tweetnacl": { @@ -90,20 +77,6 @@ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } - }, - "buffer-from": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz", - "integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==" - }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -114,12 +87,12 @@ "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz", "integrity": "sha1-S59TqBsn5NXawxwP/Qz6A8xoMNs=", "requires": { - "css-select": "1.2.0", - "dom-serializer": "0.1.0", - "entities": "1.1.1", - "htmlparser2": "3.9.2", - "lodash": "4.17.4", - "parse5": "3.0.2" + "css-select": "~1.2.0", + "dom-serializer": "~0.1.0", + "entities": "~1.1.1", + "htmlparser2": "^3.9.1", + "lodash": "^4.15.0", + "parse5": "^3.0.1" } }, "co": { @@ -132,7 +105,7 @@ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "commander": { @@ -140,22 +113,6 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==" }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "requires": { - "buffer-from": "1.1.0", - "inherits": "2.0.3", - "readable-stream": "2.3.3", - "typedarray": "0.0.6" - } - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -166,10 +123,10 @@ "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", "requires": { - "boolbase": "1.0.0", - "css-what": "2.1.0", + "boolbase": "~1.0.0", + "css-what": "2.1", "domutils": "1.5.1", - "nth-check": "1.0.1" + "nth-check": "~1.0.1" } }, "css-what": { @@ -182,7 +139,7 @@ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "debug": { @@ -207,13 +164,14 @@ }, "discord.js": { "version": "github:hydrabolt/discord.js#2694c0d442a008a1e40c17df147a22bc9534049a", + "from": "github:hydrabolt/discord.js", "requires": { - "form-data": "2.3.2", - "node-fetch": "2.1.2", - "pako": "1.0.6", - "prism-media": "0.3.1", - "tweetnacl": "1.0.0", - "ws": "4.1.0" + "form-data": "^2.3.2", + "node-fetch": "^2.1.2", + "pako": "^1.0.0", + "prism-media": "^0.3.0", + "tweetnacl": "^1.0.0", + "ws": "^4.0.0" }, "dependencies": { "prism-media": { @@ -228,8 +186,8 @@ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", "requires": { - "domelementtype": "1.1.3", - "entities": "1.1.1" + "domelementtype": "~1.1.1", + "entities": "~1.1.1" }, "dependencies": { "domelementtype": { @@ -249,7 +207,7 @@ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.1.tgz", "integrity": "sha1-iS5HAAqZvlW783dP/qBWHYh5wlk=", "requires": { - "domelementtype": "1.3.0" + "domelementtype": "1" } }, "domutils": { @@ -257,8 +215,8 @@ "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", "requires": { - "dom-serializer": "0.1.0", - "domelementtype": "1.3.0" + "dom-serializer": "0", + "domelementtype": "1" } }, "ecc-jsbn": { @@ -267,7 +225,7 @@ "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "entities": { @@ -275,35 +233,11 @@ "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=" }, - "es6-promise": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==" - }, - "es6-promisify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", - "requires": { - "es6-promise": "4.2.4" - } - }, "extend": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" }, - "extract-zip": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", - "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", - "requires": { - "concat-stream": "1.6.2", - "debug": "2.6.9", - "mkdirp": "0.5.1", - "yauzl": "2.4.1" - } - }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -319,20 +253,12 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, - "fd-slicer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", - "requires": { - "pend": "1.2.0" - } - }, "ffmpeg": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/ffmpeg/-/ffmpeg-0.0.4.tgz", "integrity": "sha1-HEYN+OfaUSf2LO70v6BsWciWMMs=", "requires": { - "when": "3.7.8" + "when": ">= 0.0.1" } }, "forever-agent": { @@ -345,9 +271,9 @@ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "requires": { - "asynckit": "0.4.0", + "asynckit": "^0.4.0", "combined-stream": "1.0.6", - "mime-types": "2.1.18" + "mime-types": "^2.1.12" } }, "fs-nextra": { @@ -355,30 +281,12 @@ "resolved": "https://registry.npmjs.org/fs-nextra/-/fs-nextra-0.3.2.tgz", "integrity": "sha512-ktFNusOmRFt1sWPaRRS3USAb4sFlZvERdG+rZ+VDzPBciC+0K0BhFBs5vMkJZZhhUMi6/gzGAvb7UePP/DLnzA==" }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "requires": { - "assert-plus": "1.0.0" - } - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "assert-plus": "^1.0.0" } }, "har-schema": { @@ -391,8 +299,8 @@ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "requires": { - "ajv": "5.5.2", - "har-schema": "2.0.0" + "ajv": "^5.1.0", + "har-schema": "^2.0.0" } }, "html-entities": { @@ -405,12 +313,12 @@ "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.9.2.tgz", "integrity": "sha1-G9+HrMoPP55T+k/M6w9LTLsAszg=", "requires": { - "domelementtype": "1.3.0", - "domhandler": "2.4.1", - "domutils": "1.5.1", - "entities": "1.1.1", - "inherits": "2.0.3", - "readable-stream": "2.3.3" + "domelementtype": "^1.3.0", + "domhandler": "^2.3.0", + "domutils": "^1.5.1", + "entities": "^1.1.1", + "inherits": "^2.0.1", + "readable-stream": "^2.0.2" } }, "http-signature": { @@ -418,42 +326,9 @@ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.14.1" - } - }, - "https-proxy-agent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", - "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", - "requires": { - "agent-base": "4.2.0", - "debug": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "inherits": { @@ -513,10 +388,10 @@ "resolved": "https://registry.npmjs.org/komada/-/komada-0.21.1.tgz", "integrity": "sha512-Gbl2OiO1CYvjXrlzQ/rjS3MMvgPtZt0uCassh61QlLGRserdPjIvgRNPIduK1RgzNao1sbwDuIaItNGNO/A8FQ==", "requires": { - "fs-nextra": "0.3.2", - "moment": "2.22.2", - "moment-duration-format": "1.3.0", - "performance-now": "2.1.0" + "fs-nextra": "^0.3.0", + "moment": "^2.18.1", + "moment-duration-format": "^1.3.0", + "performance-now": "^2.1.0" }, "dependencies": { "performance-now": { @@ -536,14 +411,9 @@ "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.2.2.tgz", "integrity": "sha512-R/xWLXBtVr0m9sPruRL4p9uO01JyHxhcQ4nhqQhVgyT802OZyVW+dn+fWHvTnbfE6YMLc65TksZZut+Mh2OVMQ==", "requires": { - "miniget": "1.2.0" + "miniget": "^1.1.0" } }, - "mime": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.3.1.tgz", - "integrity": "sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg==" - }, "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", @@ -554,7 +424,7 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "requires": { - "mime-db": "1.33.0" + "mime-db": "~1.33.0" } }, "miniget": { @@ -562,27 +432,6 @@ "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.2.0.tgz", "integrity": "sha1-ADY3Oia71S2+aUX85sjAOR6eEkE=" }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { - "brace-expansion": "1.1.11" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { - "minimist": "0.0.8" - } - }, "moment": { "version": "2.22.2", "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", @@ -604,19 +453,19 @@ "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=" }, "node-fetch": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz", - "integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=" + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz", + "integrity": "sha512-OayFWziIxiHY8bCUyLX6sTpDH8Jsbp4FfYd1j1f7vZyfgkcOnAyM4oQR16f8a0s7Gl/viMGRey8eScYk4V4EZA==" }, "node-opus": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/node-opus/-/node-opus-0.2.7.tgz", "integrity": "sha1-W3JuKXlbCxJ7TIfmYtTegWhAV5w=", "requires": { - "bindings": "1.2.1", - "commander": "2.11.0", - "nan": "2.7.0", - "ogg-packet": "1.0.0" + "bindings": "~1.2.1", + "commander": "^2.9.0", + "nan": "^2.3.2", + "ogg-packet": "^1.0.0" } }, "nth-check": { @@ -624,7 +473,7 @@ "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.1.tgz", "integrity": "sha1-mSms32KPwsQQmN6rgqxYDPFJquQ=", "requires": { - "boolbase": "1.0.0" + "boolbase": "~1.0.0" } }, "oauth-sign": { @@ -638,15 +487,7 @@ "integrity": "sha1-RbiFchrI991c8iOR1CEGrlM6xng=", "optional": true, "requires": { - "ref-struct": "1.1.0" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1.0.2" + "ref-struct": "*" } }, "pako": { @@ -659,19 +500,9 @@ "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.2.tgz", "integrity": "sha1-Be/1fw70V3+xRKefi5qWemzERRA=", "requires": { - "@types/node": "6.0.88" + "@types/node": "^6.0.46" } }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" - }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -682,59 +513,11 @@ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" }, - "progress": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", - "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=" - }, - "proxy-from-env": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", - "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=" - }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" }, - "puppeteer": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.5.0.tgz", - "integrity": "sha512-eELwFtFxL+uhmg4jPZOZXzSrPEYy4CaYQNbcchBbfxY+KjMpnv6XGf/aYWaQG49OTpfi2/DMziXtDM8XuJgoUA==", - "requires": { - "debug": "3.1.0", - "extract-zip": "1.6.7", - "https-proxy-agent": "2.2.1", - "mime": "2.3.1", - "progress": "2.0.0", - "proxy-from-env": "1.0.0", - "rimraf": "2.6.2", - "ws": "5.2.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "ws": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.0.tgz", - "integrity": "sha512-c18dMeW+PEQdDFzkhDsnBAlS4Z8KGStBQQUcQ5mf7Nf689jyGk0594L+i9RaQuf4gog6SvWLJorz2NfSaqxZ7w==", - "requires": { - "async-limiter": "1.0.0" - } - } - } - }, "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", @@ -750,13 +533,13 @@ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.0.3", + "util-deprecate": "~1.0.1" } }, "ref": { @@ -765,9 +548,9 @@ "integrity": "sha512-2cBCniTtxcGUjDpvFfVpw323a83/0RLSGJJY5l5lcomZWhYpU2cuLdsvYqMixvsdLJ9+sTdzEkju8J8ZHDM2nA==", "optional": true, "requires": { - "bindings": "1.2.1", - "debug": "2.6.9", - "nan": "2.7.0" + "bindings": "1", + "debug": "2", + "nan": "2" } }, "ref-struct": { @@ -776,8 +559,8 @@ "integrity": "sha1-XV7mWtQc78Olxf60BYcmHkee3BM=", "optional": true, "requires": { - "debug": "2.6.9", - "ref": "1.3.5" + "debug": "2", + "ref": "1" } }, "request": { @@ -785,34 +568,26 @@ "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.6", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.2", - "har-validator": "5.0.3", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.18", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", - "tough-cookie": "2.3.4", - "tunnel-agent": "0.6.0", - "uuid": "3.2.1" - } - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "requires": { - "glob": "7.1.2" + "aws-sign2": "~0.7.0", + "aws4": "^1.6.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.1", + "forever-agent": "~0.6.1", + "form-data": "~2.3.1", + "har-validator": "~5.0.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.17", + "oauth-sign": "~0.8.2", + "performance-now": "^2.1.0", + "qs": "~6.5.1", + "safe-buffer": "^5.1.1", + "tough-cookie": "~2.3.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.1.0" } }, "safe-buffer": { @@ -835,8 +610,8 @@ "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-3.1.13.tgz", "integrity": "sha512-JxXKPJnkZ6NuHRojq+g2WXWBt3M1G9sjZaYiHEWSTGijDM3cwju/0T2XbWqMXFmPqDgw+iB7zKQvnns4bvzXlw==", "requires": { - "nan": "2.7.0", - "node-pre-gyp": "0.6.38" + "nan": "~2.7.0", + "node-pre-gyp": "~0.6.38" }, "dependencies": { "abbrev": { @@ -847,8 +622,8 @@ "version": "4.11.8", "bundled": true, "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" + "co": "^4.6.0", + "json-stable-stringify": "^1.0.1" } }, "ansi-regex": { @@ -863,8 +638,8 @@ "version": "1.1.4", "bundled": true, "requires": { - "delegates": "1.0.0", - "readable-stream": "2.3.3" + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, "asn1": { @@ -896,28 +671,28 @@ "bundled": true, "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" } }, "block-stream": { "version": "0.0.9", "bundled": true, "requires": { - "inherits": "2.0.3" + "inherits": "~2.0.0" } }, "boom": { "version": "2.10.1", "bundled": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "brace-expansion": { "version": "1.1.8", "bundled": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -937,7 +712,7 @@ "version": "1.0.5", "bundled": true, "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "concat-map": { @@ -956,14 +731,14 @@ "version": "2.0.5", "bundled": true, "requires": { - "boom": "2.10.1" + "boom": "2.x.x" } }, "dashdash": { "version": "1.14.1", "bundled": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -996,7 +771,7 @@ "bundled": true, "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "extend": { @@ -1015,9 +790,9 @@ "version": "2.1.4", "bundled": true, "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" + "asynckit": "^0.4.0", + "combined-stream": "^1.0.5", + "mime-types": "^2.1.12" } }, "fs.realpath": { @@ -1028,40 +803,40 @@ "version": "1.0.11", "bundled": true, "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.2" + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" } }, "fstream-ignore": { "version": "1.0.5", "bundled": true, "requires": { - "fstream": "1.0.11", - "inherits": "2.0.3", - "minimatch": "3.0.4" + "fstream": "^1.0.0", + "inherits": "2", + "minimatch": "^3.0.0" } }, "gauge": { "version": "2.7.4", "bundled": true, "requires": { - "aproba": "1.2.0", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" } }, "getpass": { "version": "0.1.7", "bundled": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -1074,12 +849,12 @@ "version": "7.1.2", "bundled": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "graceful-fs": { @@ -1094,8 +869,8 @@ "version": "4.2.1", "bundled": true, "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" + "ajv": "^4.9.1", + "har-schema": "^1.0.5" } }, "has-unicode": { @@ -1106,10 +881,10 @@ "version": "3.1.3", "bundled": true, "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" + "boom": "2.x.x", + "cryptiles": "2.x.x", + "hoek": "2.x.x", + "sntp": "1.x.x" } }, "hoek": { @@ -1120,17 +895,17 @@ "version": "1.1.1", "bundled": true, "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" + "assert-plus": "^0.2.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "inflight": { "version": "1.0.6", "bundled": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -1145,7 +920,7 @@ "version": "1.0.0", "bundled": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-typedarray": { @@ -1173,7 +948,7 @@ "version": "1.0.1", "bundled": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "json-stringify-safe": { @@ -1208,14 +983,14 @@ "version": "2.1.17", "bundled": true, "requires": { - "mime-db": "1.30.0" + "mime-db": "~1.30.0" } }, "minimatch": { "version": "3.0.4", "bundled": true, "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -1238,33 +1013,33 @@ "bundled": true, "requires": { "hawk": "3.1.3", - "mkdirp": "0.5.1", - "nopt": "4.0.1", - "npmlog": "4.1.2", - "rc": "1.2.1", + "mkdirp": "^0.5.1", + "nopt": "^4.0.1", + "npmlog": "^4.0.2", + "rc": "^1.1.7", "request": "2.81.0", - "rimraf": "2.6.2", - "semver": "5.4.1", - "tar": "2.2.1", - "tar-pack": "3.4.0" + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^2.2.1", + "tar-pack": "^3.4.0" } }, "nopt": { "version": "4.0.1", "bundled": true, "requires": { - "abbrev": "1.1.1", - "osenv": "0.1.4" + "abbrev": "1", + "osenv": "^0.1.4" } }, "npmlog": { "version": "4.1.2", "bundled": true, "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" } }, "number-is-nan": { @@ -1283,7 +1058,7 @@ "version": "1.4.0", "bundled": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "os-homedir": { @@ -1298,8 +1073,8 @@ "version": "0.1.4", "bundled": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" } }, "path-is-absolute": { @@ -1326,10 +1101,10 @@ "version": "1.2.1", "bundled": true, "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.4", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" + "deep-extend": "~0.4.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" }, "dependencies": { "minimist": { @@ -1342,48 +1117,48 @@ "version": "2.3.3", "bundled": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.0.3", + "util-deprecate": "~1.0.1" } }, "request": { "version": "2.81.0", "bundled": true, "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.1.0" + "aws-sign2": "~0.6.0", + "aws4": "^1.2.1", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.0", + "forever-agent": "~0.6.1", + "form-data": "~2.1.1", + "har-validator": "~4.2.1", + "hawk": "~3.1.3", + "http-signature": "~1.1.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.7", + "oauth-sign": "~0.8.1", + "performance-now": "^0.2.0", + "qs": "~6.4.0", + "safe-buffer": "^5.0.1", + "stringstream": "~0.0.4", + "tough-cookie": "~2.3.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.0.0" } }, "rimraf": { "version": "2.6.2", "bundled": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "safe-buffer": { @@ -1406,21 +1181,21 @@ "version": "1.0.9", "bundled": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "sshpk": { "version": "1.13.1", "bundled": true, "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" }, "dependencies": { "assert-plus": { @@ -1433,16 +1208,16 @@ "version": "1.0.2", "bundled": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { "version": "1.0.3", "bundled": true, "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "~5.1.0" } }, "stringstream": { @@ -1453,7 +1228,7 @@ "version": "3.0.1", "bundled": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-json-comments": { @@ -1464,37 +1239,37 @@ "version": "2.2.1", "bundled": true, "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" + "block-stream": "*", + "fstream": "^1.0.2", + "inherits": "2" } }, "tar-pack": { "version": "3.4.0", "bundled": true, "requires": { - "debug": "2.6.9", - "fstream": "1.0.11", - "fstream-ignore": "1.0.5", - "once": "1.4.0", - "readable-stream": "2.3.3", - "rimraf": "2.6.2", - "tar": "2.2.1", - "uid-number": "0.0.6" + "debug": "^2.2.0", + "fstream": "^1.0.10", + "fstream-ignore": "^1.0.5", + "once": "^1.3.3", + "readable-stream": "^2.1.4", + "rimraf": "^2.5.1", + "tar": "^2.2.1", + "uid-number": "^0.0.6" } }, "tough-cookie": { "version": "2.3.3", "bundled": true, "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" } }, "tunnel-agent": { "version": "0.6.0", "bundled": true, "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -1518,9 +1293,9 @@ "version": "1.10.0", "bundled": true, "requires": { - "assert-plus": "1.0.0", + "assert-plus": "^1.0.0", "core-util-is": "1.0.2", - "extsprintf": "1.3.0" + "extsprintf": "^1.2.0" }, "dependencies": { "assert-plus": { @@ -1533,7 +1308,7 @@ "version": "1.1.2", "bundled": true, "requires": { - "string-width": "1.0.2" + "string-width": "^1.0.2" } }, "wrappy": { @@ -1547,14 +1322,14 @@ "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz", "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=", "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" }, "dependencies": { "tweetnacl": { @@ -1570,7 +1345,7 @@ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "~5.1.0" } }, "tough-cookie": { @@ -1578,7 +1353,7 @@ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" } }, "tunnel-agent": { @@ -1586,7 +1361,7 @@ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -1594,11 +1369,6 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz", "integrity": "sha1-cT2LgY2kIGh0C/aDhtBHnmb8ins=" }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -1614,9 +1384,9 @@ "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "requires": { - "assert-plus": "1.0.0", + "assert-plus": "^1.0.0", "core-util-is": "1.0.2", - "extsprintf": "1.3.0" + "extsprintf": "^1.2.0" } }, "when": { @@ -1624,26 +1394,13 @@ "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=" }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, "ws": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz", "integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==", "requires": { - "async-limiter": "1.0.0", - "safe-buffer": "5.1.1" - } - }, - "yauzl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", - "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", - "requires": { - "fd-slicer": "1.0.1" + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0" } }, "ytdl-core": { @@ -1651,10 +1408,10 @@ "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.20.4.tgz", "integrity": "sha512-d+jthiJxSQ6yqCeCwwMggXYOjFSOJsD7ahvAAE1sFW9nVNnsA/roz91SFH1FzaMGS7/y7AnJfhVgpE9i8uYjJQ==", "requires": { - "html-entities": "1.2.1", - "m3u8stream": "0.2.2", - "miniget": "1.2.0", - "sax": "1.2.4" + "html-entities": "^1.1.3", + "m3u8stream": "^0.2.1", + "miniget": "^1.1.0", + "sax": "^1.1.3" } } } diff --git a/package.json b/package.json index a766c06..1b7b701 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "moment": "^2.22.2", "moment-duration-format": "^1.3.0", "ms": "^2.0.0", + "node-fetch": "^2.2.0", "node-opus": "^0.2.7", - "puppeteer": "^1.5.0", "querystring": "^0.2.0", "request": "^2.87.0", "snekfetch": "^3.5.8", From 1c1b86a05f72f6d4a561956e4f19fd47b703f19d Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Sat, 25 Aug 2018 21:28:38 -0400 Subject: [PATCH 07/38] Patches and Fixes Cleaned up the economy commands quite a bit and implemented the changable database locations. Also fixed the anilist command so that avatars, colons, and watch times are displayed at all/properly. --- commands/Economy/Cooking/craft.js | 11 +++-- commands/Economy/Cooking/fish.js | 6 +-- commands/Economy/Cooking/harvest.js | 17 ++++---- commands/Economy/Cooking/inventory.js | 59 +++++++++++++++------------ commands/Economy/Cooking/sell.js | 9 ++-- commands/Economy/balance.js | 9 ++-- commands/General/anilist.js | 12 +++--- commands/General/help.js | 7 +--- commands/General/mal.js | 3 +- commands/General/report.js | 6 +-- commands/System/permlevel.js | 6 +-- functions/validator.js | 2 +- 12 files changed, 71 insertions(+), 76 deletions(-) diff --git a/commands/Economy/Cooking/craft.js b/commands/Economy/Cooking/craft.js index 49a22ff..e35506f 100644 --- a/commands/Economy/Cooking/craft.js +++ b/commands/Economy/Cooking/craft.js @@ -1,8 +1,8 @@ exports.run = async (client, msg, [item, amount]) => { const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/inventory.sqlite"); - let items = require("../../../assets/values/items.json"); - let recipe = require("../../../assets/values/recipes.json"); + let db = new sqlite3.Database(client.database.inv); + let items = client.database.items, + recipe = client.database.recipes; if (!item) { return msg.channel.send("You need to define an item to craft, baka!"); } var product = items[item.toLowerCase()]; @@ -12,7 +12,6 @@ exports.run = async (client, msg, [item, amount]) => { if (amount === "help") { var recipeList = []; - recipe.forEach(element => { recipeList.push(element[1] + " " + items[element[0]].emote); }); const embed = new client.methods.Embed() @@ -35,7 +34,7 @@ exports.run = async (client, msg, [item, amount]) => { db.get(`SELECT ${names} FROM material WHERE userId = "${msg.author.id}"`, [], (err, row) => { if (err) { return console.log(err); } - if (!row) { return msg.reply(client.speech(["noRow"])); } + if (!row) { return msg.reply(client.speech(["noRow"], msg)); } let invAmount = Object.values(row); for (var x = 0; x < recipe.length; x++) { @@ -50,7 +49,7 @@ exports.run = async (client, msg, [item, amount]) => { db.run(`UPDATE product SET ${product.name} = ${Object.values(row)[0] + amount} WHERE userId = ${msg.author.id}`); }); - msg.channel.send(client.speech(["craft"]).replace("-num-", amount).replace("-item-", product.emote)); + msg.channel.send(client.speech(["craft"], msg).replace("-num-", amount).replace("-item-", product.emote)); }); db.close(); }); diff --git a/commands/Economy/Cooking/fish.js b/commands/Economy/Cooking/fish.js index 9c8af79..0503bf5 100644 --- a/commands/Economy/Cooking/fish.js +++ b/commands/Economy/Cooking/fish.js @@ -1,7 +1,7 @@ exports.run = async (client, msg) => { const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/inventory.sqlite"); - const items = require("../../../assets/values/items.json"); + let db = new sqlite3.Database(client.database.inv); + const items = client.database.items; client.funcs.transactions(msg, {credit: [1, "-", 11]}, function(data) { if (data.valid === false) { return; } @@ -25,7 +25,7 @@ exports.run = async (client, msg) => { var result = (kind === "trash") ? "You have lost 10 credits" : "You have placed the fish in your inventory"; if (kind !== "trash") { db.run(`UPDATE material SET ${kind} = ${Number(Fisher[1][results]) + 1} WHERE userId = ${msg.author.id}`); } - msg.channel.send(client.speech(["fish"]).replace("-user1-", msg.author.username).replace("-fish-", items[kind].emote) + " " + result); + msg.channel.send(client.speech(["fish"], msg).replace("-user1-", msg.author.username).replace("-fish-", items[kind].emote) + " " + result); }); db.close(); }); diff --git a/commands/Economy/Cooking/harvest.js b/commands/Economy/Cooking/harvest.js index 577ddb5..35e2b3d 100644 --- a/commands/Economy/Cooking/harvest.js +++ b/commands/Economy/Cooking/harvest.js @@ -1,9 +1,9 @@ exports.run = async (client, msg) => { const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/inventory.sqlite"); - const items = require("../../../assets/values/items.json"); + let db = new sqlite3.Database(client.database.inv); + const items = client.database.items; - client.funcs.transactions(msg, {credit: [1, "-", 11]}, function(data) { + client.funcs.transactions(msg, {credit: [1, "-", 11]}, function(data) { if (data.valid === false) { return; } }); @@ -25,13 +25,11 @@ exports.run = async (client, msg) => { else { var results = 7; } var item = items[itemName[0][results]]; - var amount = Number(itemName[1][results]) + 1; - var name = (item.name === "green apple") ? "greenapple" : item.name; - db.run(`UPDATE material SET ${name} = ${amount} WHERE userId = ${msg.author.id}`); + db.run(`UPDATE material SET ${name} = ${Number(itemName[1][results]) + 1} WHERE userId = ${msg.author.id}`); - return msg.channel.send(`${msg.author.username}, you have found ${item.emote}. The item has been placed in your inventory.`); + msg.channel.send(`${msg.author.username}, you have found ${item.emote}. The item has been placed in your inventory.`); }); db.close(); }; @@ -42,11 +40,10 @@ exports.conf = { aliases: [], permLevel: 0, botPerms: [], - cooldown: 30, + cooldown: 30 }; exports.help = { name: "harvest", - description: "Harvest fruits and other foods for cooking!", - usage: "", + description: "Harvest fruits and other foods for cooking!", usage: "" }; \ No newline at end of file diff --git a/commands/Economy/Cooking/inventory.js b/commands/Economy/Cooking/inventory.js index f1a5258..b849e43 100644 --- a/commands/Economy/Cooking/inventory.js +++ b/commands/Economy/Cooking/inventory.js @@ -1,7 +1,7 @@ exports.run = async (client, msg) => { const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/inventory.sqlite"); - const items = require("../../../assets/values/items.json"); + let db = new sqlite3.Database(client.database.inv); + const items = client.database.items; const embed = new client.methods.Embed() .setTimestamp() @@ -10,37 +10,43 @@ exports.run = async (client, msg) => { db.get(`SELECT * FROM material WHERE userId = "${msg.author.id}"`, [], (err, row) => { if (err) { return console.log(err); } - if (!row) { return msg.channel.send("You haven't signed up with `m~daily` yet! D:"); } + if (!row) { return msg.channel.send(client.speech(["noRow"], msg)); } var amounts = Object.values(row); - var fishing = []; var harvest = []; var x = 2; var y; - do { - y = x - 1; - var z = items.info.material_names[x]; - if (amounts[y] !== null && amounts[y] > 0) { - if (items[z].category[1] === "fishing") { fishing.push(amounts[y] + items[z].emote); } - else if (items[z].category[1] === "harvest") { harvest.push(amounts[y] + items[z].emote); } - } - x++; - } while (x < items.info.material_names.length); - if (fishing.length === 0) { fishing.push("You do not have any fish."); } - if (harvest.length === 0) { harvest.push("You do not have any harvest materials."); } + var material = [[], [], []]; - embed.addField("Materials:", `__Fishing__\n${fishing.join(", ")}\n__Harvest__\n${harvest.join(", ")}`); + for (var x = 1; x < items.info.material_names.length; x++) { + var y = items.info.material_names[x]; + if (amounts[x] !== null && amounts[x] > 0) { + switch (items[y].category[1]) { + case "fishing": material[0].push(amounts[x] + items[y].emote); break; + case "harvest": material[1].push(amounts[x] + items[y].emote); break; + case "misc": material[2].push(amounts[x] + items[y].emote); break; + } + } + } + if (material[0].length === 0) { material[0].push("You do not have any fish."); } + if (material[1].length === 0) { material[1].push("You do not have any harvest materials."); } + if (material[2].length === 0) { material[2].push("You do not have any misc materials."); } + embed.addField("Materials:", `__Fishing__\n${material[0].join(", ")}\n__Harvest__\n${material[1].join(", ")}\n__Misc__\n${material[2].join(", ")}`); db.get(`SELECT * FROM product WHERE userId = "${msg.author.id}"`, [], (err, row) => { var amount = Object.values(row); - var food = []; var x = 1 + items.info.material_names.length; var y = 1; - do { - var z = items.info.product_names[y - 1]; - if (amount[y] !== null && amount[y] > 0) { - if (items[z].category[1] === "food") { food.push(amount[y] + items[z].emote); } + var product = [[], []]; + + for (var x = 1; x < items.info.product_names.length; x++) { + var y = items.info.product_names[x]; + if (amount[x] !== null && amount[x] > 0) { + switch (items[y].category[1]) { + case "food": product[0].push(amount[x] + items[y].emote); break; + case "material[2]": product[1].push(amount[x] + items[y].emote); break; + } } - x++; y++; - } while (y - 1 < items.info.product_names.length); + } + if (product[0].length === 0) { product[0].push("You do not have any food items."); } + if (product[1].length === 0) { product[1].push("You do not have any material[2] materials."); } + embed.addField("**Products:**", `__Food__\n${product[0].join(", ")}\n__material[2]__\n${product[1].join(", ")}`); - if (food.length === 0) { food.push("You do not have any food items."); } - embed.addField("**Products:**", `__Food__\n${food.join(", ")}`); msg.channel.send({embed}); }); }); @@ -57,6 +63,5 @@ exports.conf = { exports.help = { name: "inventory", - description: "Check your inventory for materials, produced goods, and more!", - usage: "", + description: "Check your inventory for materials, produced goods, and more!", usage: "" }; \ No newline at end of file diff --git a/commands/Economy/Cooking/sell.js b/commands/Economy/Cooking/sell.js index 1da0d80..8c75340 100644 --- a/commands/Economy/Cooking/sell.js +++ b/commands/Economy/Cooking/sell.js @@ -1,12 +1,12 @@ exports.run = async (client, msg, [item, amount]) => { const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/inventory.sqlite"); - let object = require("../../../assets/values/items.json")[item.toLowerCase()]; + let db = new sqlite3.Database(client.database.inv); + let object = client.database.items[item.toLowerCase()]; if (!object) { return msg.channel.send("That item does not exist."); } db.get(`SELECT ${object.name} FROM ${object.category[0]} WHERE userId = "${msg.author.id}"`, [], (err, row) => { if (err) { return console.log(err); } - if (!row) { return msg.reply(client.speech(["noRow"])); } + if (!row) { return msg.reply(client.speech(["noRow"], msg)); } amount = (amount === undefined) ? Object.values(row)[0] : amount; if (amount > row) { return msg.channel.send("You don't have that much " + object.name + ", baka!"); } @@ -31,6 +31,5 @@ exports.conf = { exports.help = { name: "sell", description: "Sell your items!", - usage: " [amount:int]", - usageDelim: " " + usage: " [amount:int]", usageDelim: " " }; \ No newline at end of file diff --git a/commands/Economy/balance.js b/commands/Economy/balance.js index ae80868..08213c3 100644 --- a/commands/Economy/balance.js +++ b/commands/Economy/balance.js @@ -1,15 +1,16 @@ exports.run = async (client, msg, [user]) => { const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/score.sqlite"); + let db = new sqlite3.Database(client.database.general); var data = await client.funcs.userSearch(client, msg, {user: [user], tags:["bot"], name: this.help.name}); if (data.valid === false) { return; } - db.get(`SELECT * FROM scores WHERE userId = "${data.user[0].id}"`, [], (err, row) => { + db.get(`SELECT credits, dailies, rep FROM users WHERE userID = "${data.user[0].id}"`, [], (err, row) => { if (err) { return console.log(err); } - if (!row) { return msg.reply("That person hasn't signed up with `m~daily` yet! D:"); } + if (!row) { return msg.reply(client.speech(["noRow"], msg)); } + var cooldown = JSON.parse(row.dailies); - let time = [((Date.now() - row.daily) / 86400000), ((Date.now() - row.repDaily) / 86400000)]; + let time = [((Date.now() - cooldown.credit) / 86400000), ((Date.now() - cooldown.rep) / 86400000)]; for (var x = 0; x < 2; x++) { if (time[x] >= 14) { time.push((time[x]/7).toFixed(2) + " weeks"); } else if (time[x] >= 1) { time.push(time[x].toFixed(2) + " days"); } diff --git a/commands/General/anilist.js b/commands/General/anilist.js index 8fb1777..969e51a 100644 --- a/commands/General/anilist.js +++ b/commands/General/anilist.js @@ -4,30 +4,30 @@ exports.run = async (client, msg, [term]) => { var options = { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, - body: JSON.stringify({ query: `query ($name: String) { User(name: $name) { avatar { medium } siteUrl + body: JSON.stringify({ query: `query ($name: String) { User(name: $name) { avatar { large } siteUrl stats { watchedTime chaptersRead animeListScores { meanScore } mangaListScores { meanScore } animeStatusDistribution { status amount } mangaStatusDistribution { status amount } } } }`, variables: { name: term } }) }; var response = await fetch('https://graphql.anilist.co', options); var json = await response.json(); - if (!json.data.stats) { return msg.channel.send("Anilist profile by that user is not found!"); } + if (!json.data.User.stats) { return msg.channel.send("Anilist profile by that user is not found!"); } var data = json.data.User, anime = data.stats.animeStatusDistribution, manga = data.stats.mangaStatusDistribution; - var animeL = ["šŸ’š Watching " + anime[0].amount, "šŸ—“ Planned " + anime[1].amount, "šŸ’™ Completed " + anime[2].amount, "šŸ’” Dropped " + anime[3].amount, "šŸ’› Paused " + anime[4].amount]; - var mangaL = ["šŸ“— Reading " + manga[0].amount, "šŸ—“ Planned " + manga[1].amount, "šŸ“˜ Completed " + manga[2].amount, "šŸ“• Dropped " + manga[3].amount, "šŸ“™ Paused " + manga[4].amount]; + var animeL = ["šŸ’š Watching: " + anime[0].amount, "šŸ—“ Planned: " + anime[1].amount, "šŸ’™ Completed: " + anime[2].amount, "šŸ’” Dropped: " + anime[3].amount, "šŸ’› Paused: " + anime[4].amount]; + var mangaL = ["šŸ“— Reading: " + manga[0].amount, "šŸ—“ Planned: " + manga[1].amount, "šŸ“˜ Completed: " + manga[2].amount, "šŸ“• Dropped: " + manga[3].amount, "šŸ“™ Paused: " + manga[4].amount]; const embed = new client.methods.Embed() .setTitle(term + "'s AniList Profile") .setURL(data.siteUrl) - .setDescription("šŸ•“ Watch Days: " + data.stats.watchedTime + "\nšŸ”– Manga Chapters: " + data.stats.chaptersRead) + .setDescription("šŸ•“ Watch Days: " + Number(data.stats.watchedTime / 60 / 24).toFixed(1) + "\nšŸ”– Manga Chapters: " + data.stats.chaptersRead) .addField("__Anime:__", "šŸ“Š Mean Score: " + data.stats.animeListScores.meanScore + "\n" + animeL.join("\n"), true) .addField("__Manga:__", "šŸ“Š Mean Score: " + data.stats.mangaListScores.meanScore + "\n" + mangaL.join("\n"), true) .setTimestamp() .setColor(0x2E51A2) - .setThumbnail(data.avatar.medium) + .setThumbnail(data.avatar.large) .setFooter("Requested by: " + msg.author.tag); msg.channel.send({embed}); diff --git a/commands/General/help.js b/commands/General/help.js index 74384ef..ecbddc7 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -1,6 +1,4 @@ /* Base command is from the default Komada help command. This has been modified a bit */ -const local = require("../../assets/localization.json")["permLevels"]["general"]; - exports.run = async (client, msg, [cmd, mod]) => { const method = client.user.bot ? "author" : "channel"; const help = this.buildHelp(client, msg); @@ -49,7 +47,7 @@ exports.run = async (client, msg, [cmd, mod]) => { .setTitle(cmd.help.name + alias) .setDescription(cmd.help.description) .addField("Usage:", `\`${prefix + cmd.help.name + " " + usageAct}\``) - .addField("Permission level:", local[cmd.conf.permLevel]); + .addField("Permission level:", client.ownerSettings.get("permLevel").general[cmd.conf.permLevel]); if (cmd.help.extendedHelp) { embed.addField("Extended Help:", cmd.help.extendedHelp); } msg.send({embed}); } @@ -67,8 +65,7 @@ exports.conf = { exports.help = { name: "help", description: "Display help for a command.", - usage: "[command:str] [mod:str]", - usageDelim: " ", + usage: "[command:str] [mod:str]", usageDelim: " ", humanUse: "(command|module)_ ([If module] command)" }; diff --git a/commands/General/mal.js b/commands/General/mal.js index 648013b..1083e22 100644 --- a/commands/General/mal.js +++ b/commands/General/mal.js @@ -45,8 +45,7 @@ exports.run = async (client, msg, [term]) => { if (butter === "aStats") { info.aStats.watch = z.slice(8, num[0]); info.aStats.plan = zed.slice(5, -5); - } - else { + } else { info.mStats.read = z.slice(7, num[0]); info.mStats.plan = zed.slice(4, -5); } diff --git a/commands/General/report.js b/commands/General/report.js index 02d7e3a..a8815aa 100644 --- a/commands/General/report.js +++ b/commands/General/report.js @@ -1,7 +1,7 @@ -const sqlite3 = require("sqlite3").verbose(); -let db = new sqlite3.Database("./assets/data/score.sqlite"); - exports.run = async (client, msg) => { + const sqlite3 = require("sqlite3").verbose(); + let db = new sqlite3.Database(client.database.general); + const reports = []; const reportTypes = { diff --git a/commands/System/permlevel.js b/commands/System/permlevel.js index f7e65d6..5bb7966 100644 --- a/commands/System/permlevel.js +++ b/commands/System/permlevel.js @@ -1,5 +1,3 @@ -const local = require("../../assets/localization.json")["permLevels"]; - exports.run = async (client, msg) => { for (let i = 0; i < 10; i++) { if (msg.author.id === client.owner.id) { @@ -12,9 +10,9 @@ exports.run = async (client, msg) => { else if (client.permStructure[i].check(client, msg)) { var permLevel = i; } } - var info = addPerms ? local["general"][permLevel] + " " + local["addPerms"][addPerms] : local["general"][permLevel]; + var info = addPerms ? client.ownerSetting.get("permLevel").addPerms[addPerms] : ""; - msg.channel.send(`Your permission level is ${info}`); + msg.channel.send(`Your permission level is ${client.ownerSetting.get("permLevel").general[permLevel]} ${info}`); }; exports.conf = { diff --git a/functions/validator.js b/functions/validator.js index cf0d2d0..0a2c5e7 100644 --- a/functions/validator.js +++ b/functions/validator.js @@ -25,5 +25,5 @@ exports.conf = { requiredModules: [] }; exports.help = { name: "validator", type: "functions", - description: "Validates any credit amount.", + description: "Validates any credit amount." }; \ No newline at end of file From adfd4200d3f083fe98142c9236415a37c0f27234 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Tue, 2 Oct 2018 15:18:30 -0300 Subject: [PATCH 08/38] Bug fix Fixed an issue with getting the version. --- commands/General/about.js | 10 ++++------ commands/General/choose.js | 9 +++------ commands/System/stats.js | 3 +-- index.js | 1 + 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/commands/General/about.js b/commands/General/about.js index e8c005c..d1d9b21 100644 --- a/commands/General/about.js +++ b/commands/General/about.js @@ -1,14 +1,13 @@ exports.run = async (client, msg) => { - const config = require("../../assets/settings.json"); - const prefix = msg.guildSettings.prefix || config.prefix; + const prefix = msg.guildSettings.prefix || client.config.prefix; const embed = new client.methods.Embed() .setColor(0x37FDFC) .setTimestamp() .setTitle("About Margarine") - .setDescription(`I am a very helpful (*Sometimes.*) and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written in Komada, a Discord.js framework. + .setDescription(`I am a very helpful and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written in Komada, a Discord.js framework. \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 *(Butterstroke#7150 tends to call it 'Fake Butter')* you can buy in stores called, Margarine. - \n**Creation:** I was created on ${client.user.createdAt.toLocaleString()} by ${client.owner.tag}. My current version is ${config.build.version} as of ${config.build.releaseDate}. + \n**Creation:** I was created on ${client.user.createdAt.toLocaleString()} by ${client.owner.tag}. My current version is ${client.ownerSetting.get("build").version} as of ${client.ownerSetting.get("build").releaseDate}. \n**More Information:** I have a Github repo which contains my current update tracker and the source code with [this link](https://github.com/Butterstroke/MargarineBot). For people looking for my TOS, please refer [here](https://github.com/Butterstroke/MargarineBot/blob/master/TermsAndService.md)`) .setThumbnail(client.user.displayAvatarURL()); msg.channel.send({embed}); @@ -24,6 +23,5 @@ exports.conf = { exports.help = { name: "about", - description: "General information.", - usage: "" + description: "General information.", usage: "" }; \ No newline at end of file diff --git a/commands/General/choose.js b/commands/General/choose.js index 904769e..930a286 100644 --- a/commands/General/choose.js +++ b/commands/General/choose.js @@ -1,7 +1,5 @@ exports.run = async (client, message, [...choice]) => { - var results = Math.ceil(Math.random() * choice.length); - results = choice[(results - 1)]; - + var results = choice[(Math.ceil(Math.random() * choice.length) - 1)]; message.channel.send(`${message.author.username}, I think **${results}** would be the best choice!`); }; @@ -10,13 +8,12 @@ exports.conf = { runIn: ["text"], aliases: [], permLevel: 0, - botPerms: [], + botPerms: [] }; exports.help = { name: "choose", description: "The one stop picker for hard choices!", - usage: "[choice:str] [...]", - usageDelim: " | ", + usage: "[choice:str] [...]", usageDelim: " | ", humanUse: "(choice)_(another one)_(etc...)" }; \ No newline at end of file diff --git a/commands/System/stats.js b/commands/System/stats.js index 258d135..6979b55 100644 --- a/commands/System/stats.js +++ b/commands/System/stats.js @@ -5,10 +5,9 @@ const moment = require("moment"); require("moment-duration-format"); exports.run = async (client, message) => { - const config = require("../../assets/settings.json"); const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]"); message.channel.send(`= GENERAL = -ā€¢ Margarine :: ${config.version} +ā€¢ Margarine :: ${client.ownerSetting.get("build").version} ā€¢ Mem Usage :: ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB ā€¢ Uptime :: ${duration} diff --git a/index.js b/index.js index 9eb3f65..f45ad93 100644 --- a/index.js +++ b/index.js @@ -45,6 +45,7 @@ for (var x = 0; keys.length > x; x++) { 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 "database": client.database = config.database; break; + case "build": client.ownerSetting.set("build", config.build); break; } } client.ownerSetting.set("permLevel", localization.permLevels); From 45407d98b63f6e0c2550df2d3dab14ea0d25d5a8 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Fri, 9 Nov 2018 14:22:06 -0400 Subject: [PATCH 09/38] Remove badges and add remove function Removed the badge function since it wasn't used at all. It may come back later but not for Release-1.0. For the index file, there is now a function that goes into the komada directory and removes any default commands that would cause duplication issues. --- assets/settingsExample.json | 6 +++++- assets/values/items.json | 10 +++++++-- assets/values/recipes.json | 3 ++- commandRemover.js | 11 ++++++++++ commands/Fun/poll.js | 7 +++--- commands/General/emoji.js | 5 ++--- commands/Music/nowplaying.js | 3 +-- commands/Owner/badge.js | 42 ------------------------------------ index.js | 9 ++++---- 9 files changed, 37 insertions(+), 59 deletions(-) create mode 100644 commandRemover.js delete mode 100644 commands/Owner/badge.js diff --git a/assets/settingsExample.json b/assets/settingsExample.json index e03983e..6b6ea80 100644 --- a/assets/settingsExample.json +++ b/assets/settingsExample.json @@ -3,7 +3,7 @@ "ownerID": "", "prefix": "", "build": { - "version": "Beta 0.9", + "version": "Release 1.0", "releaseDate": "TBD" }, "owner": { @@ -17,5 +17,9 @@ "minor": 600, "major": 2000 } + }, + "database": { + "general": "./assets/data/general.sqlite", + "inv": "./assets/data/inventory.sqlite" } } diff --git a/assets/values/items.json b/assets/values/items.json index 1861b7d..d0bbad4 100644 --- a/assets/values/items.json +++ b/assets/values/items.json @@ -7,13 +7,13 @@ "category": ["item_major", "item_minor"] }, "material_names": ["info", "trash", "fish", "crab", "squid", "shark", "potato", "egg", "bread", "chocolate", "greenapple", "apple", "lemon", "sake", "rice"], - "product_names": ["fishcake", "cookie", "oden", "sushi"] + "product_names": ["fishcake", "cookie", "oden", "sushi", "recycle"] }, "trash": { "price": ["N/A", 0], "name": "trash", "emote": "šŸ—‘", - "category": ["material", "N/A"] + "category": ["material", "misc"] }, "fish": { "price": ["N/A", 5], @@ -116,5 +116,11 @@ "name": "sushi", "emote": "šŸ£", "category": ["product", "food"] + }, + "recycle": { + "price": ["N/A", 44], + "name": "recycle", + "emote": "ā™»", + "category": ["product", "misc"] } } \ No newline at end of file diff --git a/assets/values/recipes.json b/assets/values/recipes.json index 6be71d9..05cef97 100644 --- a/assets/values/recipes.json +++ b/assets/values/recipes.json @@ -20,5 +20,6 @@ ["fish", 1], ["squid", 1], ["rice", 2] - ] + ], + "recycle": [ ["trash", 10] ] } \ No newline at end of file diff --git a/commandRemover.js b/commandRemover.js new file mode 100644 index 0000000..bc1b259 --- /dev/null +++ b/commandRemover.js @@ -0,0 +1,11 @@ +const fs = require("fs"); + +module.exports = function() { + var files = ["stats", "download", "info", "ping", "invite", "reboot", "help"]; + + for(var x = 0; x < files.length; x++) { + if (fs.existsSync("./node_modules/komada/src/commands/System/" + files[x] + ".js")) { + fs.unlinkSync("./node_modules/komada/src/commands/System/" + files[x] + ".js"); + } + } +}; \ No newline at end of file diff --git a/commands/Fun/poll.js b/commands/Fun/poll.js index 4d9316d..f28931c 100644 --- a/commands/Fun/poll.js +++ b/commands/Fun/poll.js @@ -1,7 +1,7 @@ exports.run = async (client, msg, [question, ...option]) => { if (!question) { return msg.reply("You need to provide a question."); } else if (option.length < 2) { return msg.reply("You need to provide at least two options!"); } - else if (option.length > 25) { return msg.reply("Whoa! You have a giant list of options! Not even I can handle all of these!"); } + else if (option.length > emote.length) { return msg.reply("Whoa! You have a giant list of options! Not even I can handle all of these!"); } var emote = ["āœ…", "āŽ", "ā˜‘", "āœ”", "āŒ", "āœ–", "ā­•", "šŸ”˜"]; @@ -23,13 +23,12 @@ exports.conf = { runIn: ["text"], aliases: [], permLevel: 0, - botPerms: [], + botPerms: [] }; exports.help = { name: "poll", description: "Poll users", - usage: "[question:str] [option:str][...]", - usageDelim: " | ", + usage: "[question:str] [option:str][...]", usageDelim: " | ", humanUse: "(question)_(option1)_(option2)_(etc...->option5)" }; \ No newline at end of file diff --git a/commands/General/emoji.js b/commands/General/emoji.js index 3cb8da0..cd2f361 100644 --- a/commands/General/emoji.js +++ b/commands/General/emoji.js @@ -2,7 +2,7 @@ exports.run = async (client, msg, [Name, ID]) => { const prefix = msg.guild.settings.prefix || client.config.prefix; msg.delete(); - if (!Name) { return msg.channel.send("You need a name of an emote to search with, baka!"); } + if (!Name) { return msg.channel.send("You need a name of an emote to search with, baka!").then(msg => { setTimeout(() => { msg.delete(); }, 4000); }); } if (msg.content.slice(prefix.length).startsWith("react") && (!ID)) { return msg.channel.send("You need to specify a message's ID so that I can find it!").then(msg => { setTimeout(() => { msg.delete(); }, 4000); }); } @@ -29,8 +29,7 @@ exports.conf = { exports.help = { name: "emoji", description: "Displays an enlargened emoji.", - usage: "[Name:str] [messageID:str]", - usageDelim: " ", + usage: "[Name:str] [messageID:str]", usageDelim: " ", extendedHelp: "Bring in your pool of emotes from other servers! Either use the big image or use the alias of react and add a message ID to react to a message instead!", humanUse: "(name)_([If reacting] messageID)" }; \ No newline at end of file diff --git a/commands/Music/nowplaying.js b/commands/Music/nowplaying.js index caf5695..9061c6d 100644 --- a/commands/Music/nowplaying.js +++ b/commands/Music/nowplaying.js @@ -31,6 +31,5 @@ exports.conf = { exports.help = { name: "nowplaying", - description: "See what's currently playing in VC.", - usage: "" + description: "See what's currently playing in VC.", usage: "" }; diff --git a/commands/Owner/badge.js b/commands/Owner/badge.js deleted file mode 100644 index 355f0f2..0000000 --- a/commands/Owner/badge.js +++ /dev/null @@ -1,42 +0,0 @@ -exports.run = async (client, message, [member, option, amount]) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./bwd/data/score.sqlite"); - - if (member != null) { - var user = client.funcs.userSearch(client, message, member); - if (user.username === null) { return; } - if (user.bot === true) { return message.reply("You can't change or add data about a bot user!"); } - } else { return message.reply("You didn't provide me with a user!"); } - - if (!option) { return message.reply("I can't just give a person nothing!"); } - - db.get(`SELECT * FROM badges WHERE userId = "${user.id}"`, [], (err, row) => { - if (err) { return console.log(err); } - if (!row) { - if (option.toLowerCase() === "add") { - db.run("INSERT INTO badges (userId, betaTester, bugSmasher) VALUES (?, ?, ?)", [user.id, "no", "no"]); - return message.reply("User has been added into the table. You may now reward the person."); - } - else { return message.reply("That user does not have any data within the database. Please try again like this `m~badge add`"); } - } else { - db.run(`UPDATE badges SET ${option} = "${amount}" WHERE userId = "${user.id}"`); - return message.reply(`Table updated. I have updated the table so that ${user.username} has earned the ${option} award!`); - } - }); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 10, - botPerms: [], - requiredFuncs: [], -}; - -exports.help = { - name: "badge", - description: "Gives a user an award based on their efforts towards Margarine.", - usage: "[member:str] [option:str] [yes|no]", - usageDelim: " ", -}; \ No newline at end of file diff --git a/index.js b/index.js index f45ad93..fec0bd0 100644 --- a/index.js +++ b/index.js @@ -3,8 +3,9 @@ const Discord = require("discord.js"); const config = require("./assets/settings.json"); const speech = require("./assets/speech.json"); const localization = require("./assets/localization.json"); -const items = require("./assets/values/items.json"); -const recipes = require("./assets/values/recipes.json"); +const remove = require("./commandRemover.js"); + +remove(); //Removes most default commands from the Komada directory so that there is absolutly no conflicts. const permStructure = new Komada.PermLevels() .addLevel(0, false, () => true) @@ -49,7 +50,7 @@ for (var x = 0; keys.length > x; x++) { } } client.ownerSetting.set("permLevel", localization.permLevels); -client.database.items = items; -client.database.recipes = recipes; +client.database.items = require("./assets/values/items.json"); +client.database.recipes = require("./assets/values/recipes.json"); client.login(config.token); \ No newline at end of file From fd7a12db43d48bf36c467f614d802344d8386db5 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Mon, 12 Nov 2018 02:52:11 -0400 Subject: [PATCH 10/38] Presence Changer and SQL Rebuild Added a feature that changes the status every 15 minutes since startup. Also began to make the database location more customizable. NOTE: leave the databases at the default setting for now as it will break! This commit just sets the foundation for it. --- assets/data/dummy.txt | 1 - assets/localization.json | 17 ++++++++++++++++- commands/Owner/presence.js | 19 ++----------------- events/ready.js | 19 +++++++++++++------ functions/presenceHelper.js | 28 ++++++++++++++++++++++++++++ functions/sqlTables.js | 32 +++++++++++++++----------------- 6 files changed, 74 insertions(+), 42 deletions(-) delete mode 100644 assets/data/dummy.txt create mode 100644 functions/presenceHelper.js diff --git a/assets/data/dummy.txt b/assets/data/dummy.txt deleted file mode 100644 index 00fbcbb..0000000 --- a/assets/data/dummy.txt +++ /dev/null @@ -1 +0,0 @@ -I'm a placeholder file for the database~! \ No newline at end of file diff --git a/assets/localization.json b/assets/localization.json index 1d28b35..e4dc85d 100644 --- a/assets/localization.json +++ b/assets/localization.json @@ -17,5 +17,20 @@ "with guild admin permissions", "with guild owner permissions" ] - } + }, + "games": [ + ["Playing around with Butterstroke", "play"], + ["Hacking to the gate", "listen"], + ["Rewatching Occultic;Nine.", "watch"], + ["Harvesting wild fruits", "play"], + ["Partying to weeb tunes", "listen"], + ["Breaking all of the code", "play"], + ["Spying on Butterstroke", "watch"], + ["Chilling out with friends", "play"], + ["Conquering all those who oppose me! Oh wait, this isn't a video game", "play"], + ["Writing for Kiri Kiri Basara", "play"], + ["Playing around with wires", "play"], + ["Cooking up a fantastic meal!", "play"], + ["Crafting a brand new world", "play"] + ] } \ No newline at end of file diff --git a/commands/Owner/presence.js b/commands/Owner/presence.js index 49dfff1..a19ff87 100644 --- a/commands/Owner/presence.js +++ b/commands/Owner/presence.js @@ -1,26 +1,11 @@ -exports.run = async (client, message, [status, game, type]) => { - client.user.setStatus(status); - - const list = { - play: "PLAYING", - stream: "STREAMING", - listen: "LISTENING", - watch: "WATCHING" - }; - - if (!game) { game = `Playing around with ${client.owner.username}`; } - if (game.toLowerCase() === "null") { game = null; } - else { game = `m~help | ${game}`; } - - client.user.setPresence({ activity: { name: game, type: list[type] } }); -}; +exports.run = async (client, msg, [status, game, type]) => { client.funcs.presenceHelper(client, game, type, status); }; exports.conf = { enabled: true, runIn: ["text", "dm"], aliases: [], permLevel: 9, - botPerms: [], + botPerms: [] }; exports.help = { diff --git a/events/ready.js b/events/ready.js index 563f5c2..980469c 100644 --- a/events/ready.js +++ b/events/ready.js @@ -1,15 +1,22 @@ const moment = require("moment"); +const fs = require("fs"); exports.run = async client => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/score.sqlite"); - let sql = new sqlite3.Database("./assets/data/inventory.sqlite"); + //Init storage areas. + if (!fs.existsSync("./assets/data")) { fs.mkdirSync("./assets/data"); } - await db.get("SELECT * FROM scores WHERE userId = 1", [], (err, row) => { if (err) { return client.funcs.sqlTables("", "init"); } else { return; } }); + //Inits the databases + const sqlite3 = require("sqlite3").verbose(); + let db = new sqlite3.Database(client.database.general); + let sql = new sqlite3.Database(client.database.inv); + + await db.get("SELECT * FROM users WHERE userId = 1", [], (err, row) => { if (err) { return client.funcs.sqlTables("-init"); } else { return; } }); await db.close(); await sql.get("SELECT * FROM material WHERE userId = 1", [], (err, row) => { if (err) { return; } else { return; }}); await sql.close(); - await client.user.setPresence({ activity: { name: ` ${client.config.prefix}help | Playing around with ${client.owner.username}`, type: 0 } }); + await console.log(`[${moment().format("YYYY-MM-DD HH:mm")}] This is ${client.user.username} speaking! Online and awaiting orders!`); await console.log(`[${moment().format("YYYY-MM-DD HH:mm")}] Current status: Serving ${client.guilds.size} guilds and ${client.users.size} people.`); -}; + + await client.funcs.presenceHelper(client, "-start"); //Inits the presence timer. +}; \ No newline at end of file diff --git a/functions/presenceHelper.js b/functions/presenceHelper.js new file mode 100644 index 0000000..108d28b --- /dev/null +++ b/functions/presenceHelper.js @@ -0,0 +1,28 @@ +let games = require("../assets/localization.json")["games"]; + +module.exports = (client, name, type, status) => { + if (status == null) { status == "online"; } + if (type == null) { type == 0; } //A.K.A => play + + if (name == "-start" || name == "-reset") { + Presence(client, "play", "Playing around with " + client.owner.username, "online"); + client.timer = setInterval(function() { + do { //No duplicate statuses, Margarine. K thx. + var items = games[Math.floor(Math.random() * games.length)]; + } while (client.user.presence.activity.name != null && items[0] == client.user.presence.activity.name.slice(9)); + + Presence(client, items[1], items[0], status); + }, 900000); + } else { + Presence(client, type, name, status); + clearInterval(client.timer); + } +}; + +function Presence(client, type, name, status) { + const tList = { "play": "PLAYING", "stream": "STREAMING", "listen": "LISTENING", "watch": "WATCHING" }; + type = tList[type]; + name = (name != "-null") ? "m~help | " + name : null; + + client.user.setPresence({ activity: { name: name, type: type }, status: status }); +}; \ No newline at end of file diff --git a/functions/sqlTables.js b/functions/sqlTables.js index 437d6ef..cecaafe 100644 --- a/functions/sqlTables.js +++ b/functions/sqlTables.js @@ -1,30 +1,28 @@ -module.exports = (user, type) => { +module.exports = (user, client) => { const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/score.sqlite"); - let sql = new sqlite3.Database("./assets/data/inventory.sqlite"); + let sql = new sqlite3.Database(client.database.inv); + let db = new sqlite3.Database(client.database.general); - if (type === "init") { - db.run("CREATE TABLE IF NOT EXISTS scores (userId TEXT, credits INTEGER, level INTEGER, daily TEXT, rep INTEGER, repDaily TEXT)"); - db.run("CREATE TABLE IF NOT EXISTS badges (userId TEXT, bugTester TEXT, betaTester TEXT)"); - db.run("CREATE TABLE IF NOT EXISTS awards (userId TEXT, suggest INTEGER, bugs INTEGER, minor INTEGER, major INTEGER)", [], (err, row) => { + if (user == "-init") { + db.run("CREATE TABLE IF NOT EXISTS users (userID TEXT, credits INTEGER, level INTEGER, profiles TEXT, dailies TEXT, rep INTEGER)"); + db.run("CREATE TABLE IF NOT EXISTS awards (userID TEXT, suggest INTEGER, bugs INTEGER, minor INTEGER, major INTEGER)", [], (err, row) => { if (err) { return console.log(err); } - db.run("INSERT INTO awards (userId, suggest, bugs, minor, major) VALUES (?, ?, ?, ?, ?)", ["Overall", 0, 0, 0, 0]); + db.run("INSERT INTO awards (userID, suggest, bugs, minor, major) VALUES (?, ?, ?, ?, ?)", ["Overall", 0, 0, 0, 0]); }); db.run("CREATE TABLE IF NOT EXISTS stats (statName TEXT, reportNumber INTEGER)", [], (row) => { - db.run("INSERT INTO stats (statName, reportNumber) VALUES (?, ?)", ["report", 0]); + db.run("INSERT INTO stats (statName, count) VALUES (?, ?)", ["report", 0]); }); db.close(); - sql.run("CREATE TABLE IF NOT EXISTS material (userId TEXT, trash INTEGER, fish INTEGER, crab INTEGER, squid INTEGER, shark INTERGER, potato INTERGER, egg INTERGER, bread INTERGER, chocolate INTERGER, greenapple INTERGER, apple INTERGER, lemon INTERGER, sake INTERGER, rice INTERGER)"); - sql.run("CREATE TABLE IF NOT EXISTS product (userId TEXT, fishcake INTEGER, cookie INTEGER, oden INTEGER, sushi INTEGER)"); + sql.run("CREATE TABLE IF NOT EXISTS material (userID TEXT, trash INTEGER, fish INTEGER, crab INTEGER, squid INTEGER, shark INTERGER, potato INTERGER, egg INTERGER, bread INTERGER, chocolate INTERGER, greenapple INTERGER, apple INTERGER, lemon INTERGER, sake INTERGER, rice INTERGER)"); + sql.run("CREATE TABLE IF NOT EXISTS product (userID TEXT, fishcake INTEGER, cookie INTEGER, oden INTEGER, sushi INTEGER, recycle INTEGER)"); sql.close(); - } if (type === "add") { - db.run("INSERT INTO scores (userId, credits, level, daily, rep, repDaily) VALUES (?, ?, ?, ?, ?, ?)", [user.id, 100, 0, Date.now(), 0, 0]); - db.run("INSERT INTO badges (userId) VALUES (?)", [user.id]); - db.run("INSERT INTO awards (userId) VALUES (?)", [user.id]); + } else { + db.run("INSERT INTO users (userID, credits, level, dailies, rep) VALUES (?, ?, ?, ?, ?)", [user.id, 100, 0, JSON.stringify({ credit: Date.now(), rep: null }), 0]); + db.run("INSERT INTO awards (userID) VALUES (?)", [user.id]); db.close(); - sql.run("INSERT INTO material (userId) VALUES (?)", [user.id]); + sql.run("INSERT INTO material (userID) VALUES (?)", [user.id]); sql.run("INSERT INTO product (userID) VALUES (?)", [user.id]); sql.close(); } @@ -35,5 +33,5 @@ module.exports.conf = { requiredModules: [] }; module.exports.help = { name: "sqlTables", type: "functions", - description: "Creates a table if there is no table to store data on.", + description: "Creates a table if there is no table to store data on." }; \ No newline at end of file From ff0631d23749afe84ce4fd731c57995bada9a45d Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Mon, 12 Nov 2018 17:33:49 -0400 Subject: [PATCH 11/38] Updated dependancies --- package-lock.json | 1353 +++++++++++++++++++-------------------------- package.json | 10 +- 2 files changed, 559 insertions(+), 804 deletions(-) diff --git a/package-lock.json b/package-lock.json index 74526f4..be9fbaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,21 +9,48 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.88.tgz", "integrity": "sha512-bYDPZTX0/s1aihdjLuAgogUAT5M+TpoWChEMea2p0yOcfn5bu3k6cJb9cp6nw268XeSNIGGr+4+/8V5K6BGzLQ==" }, + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "version": "6.5.5", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.5.tgz", + "integrity": "sha512-7q7gtRQDJSyuEHjuVgHoUa2VuemFiCMrfQc9Tc08XTAc4Zj/5U1buQJ0HU6i7fKjXU09SVgSmxa4sLvuvS8Iyg==", "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", + "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" + }, + "are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } }, "assert-plus": { "version": "1.0.0", @@ -46,15 +73,19 @@ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" }, "aws4": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "bcrypt-pbkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", - "optional": true, + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", "requires": { "tweetnacl": "^0.14.3" }, @@ -62,8 +93,7 @@ "tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "optional": true + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" } } }, @@ -77,6 +107,15 @@ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -95,10 +134,15 @@ "parse5": "^3.0.1" } }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + "chownr": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "combined-stream": { "version": "1.0.6", @@ -113,6 +157,16 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==" }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -157,11 +211,26 @@ } } }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" + }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" + }, "discord.js": { "version": "github:hydrabolt/discord.js#2694c0d442a008a1e40c17df147a22bc9534049a", "from": "github:hydrabolt/discord.js", @@ -220,12 +289,12 @@ } }, "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "optional": true, + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", "requires": { - "jsbn": "~0.1.0" + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" } }, "entities": { @@ -234,9 +303,9 @@ "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=" }, "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" }, "extsprintf": { "version": "1.3.0", @@ -244,9 +313,9 @@ "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" }, "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, "fast-json-stable-stringify": { "version": "2.0.0", @@ -276,11 +345,39 @@ "mime-types": "^2.1.12" } }, + "fs-minipass": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", + "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", + "requires": { + "minipass": "^2.2.1" + } + }, "fs-nextra": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/fs-nextra/-/fs-nextra-0.3.2.tgz", "integrity": "sha512-ktFNusOmRFt1sWPaRRS3USAb4sFlZvERdG+rZ+VDzPBciC+0K0BhFBs5vMkJZZhhUMi6/gzGAvb7UePP/DLnzA==" }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -289,20 +386,38 @@ "assert-plus": "^1.0.0" } }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" }, "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", "requires": { - "ajv": "^5.1.0", + "ajv": "^6.5.5", "har-schema": "^2.0.0" } }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" + }, "html-entities": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", @@ -331,11 +446,49 @@ "sshpk": "^1.7.0" } }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + }, + "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", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -354,8 +507,7 @@ "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "optional": true + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" }, "json-schema": { "version": "0.2.3", @@ -363,9 +515,9 @@ "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" }, "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "json-stringify-safe": { "version": "5.0.1", @@ -407,11 +559,12 @@ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" }, "m3u8stream": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.2.2.tgz", - "integrity": "sha512-R/xWLXBtVr0m9sPruRL4p9uO01JyHxhcQ4nhqQhVgyT802OZyVW+dn+fWHvTnbfE6YMLc65TksZZut+Mh2OVMQ==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.6.0.tgz", + "integrity": "sha512-h78ollIa7zeq0nzx1+wI/EH0soUpe9A7sC6zw/+/tuRwYdIXedOytvI69+6eP/FU4Ph0cT6kQsw73j5tKXIbgg==", "requires": { - "miniget": "^1.1.0" + "miniget": "^1.4.0", + "sax": "^1.2.4" } }, "mime-db": { @@ -428,9 +581,54 @@ } }, "miniget": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.2.0.tgz", - "integrity": "sha1-ADY3Oia71S2+aUX85sjAOR6eEkE=" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.5.0.tgz", + "integrity": "sha512-RbRCj2m8Q/arS1nExuMB8qO4QavCpvfetQR+HVCeHGiFJGOryPn8u0z4WrIx9AAIDYFDVcFhQsRYvSY+UA5HJQ==" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minipass": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "minizlib": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.1.tgz", + "integrity": "sha512-TrfjCjk4jLhcJyGMYymBH6oTXcWjYbUAXTHDbtnWHjZC25h0cdajHuPE1zxb4DVmu8crfh+HwH/WMuyLG0nHBg==", + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } }, "moment": { "version": "2.22.2", @@ -452,10 +650,20 @@ "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=" }, + "needle": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", + "integrity": "sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==", + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, "node-fetch": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz", - "integrity": "sha512-OayFWziIxiHY8bCUyLX6sTpDH8Jsbp4FfYd1j1f7vZyfgkcOnAyM4oQR16f8a0s7Gl/viMGRey8eScYk4V4EZA==" + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.1.tgz", + "integrity": "sha512-ObXBpNCD3A/vYQiQtEWl7DuqjAXjfptYFuGHLdPl5U19/6kJuZV+8uMHLrkj3wJrJoyfg4nhgyFixZdaZoAiEQ==" }, "node-opus": { "version": "0.2.7", @@ -468,6 +676,57 @@ "ogg-packet": "^1.0.0" } }, + "node-pre-gyp": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz", + "integrity": "sha512-d1xFs+C/IPS8Id0qPTZ4bUT8wWryfR/OzzAFxweG+uLN85oPzyo2Iw6bVlLQ/JOdgNonXLCoRyqDzDWq4iw72A==", + "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" + } + }, + "nopt": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.5.tgz", + "integrity": "sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==" + }, + "npm-packlist": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.12.tgz", + "integrity": "sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g==", + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, "nth-check": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.1.tgz", @@ -476,10 +735,20 @@ "boolbase": "~1.0.0" } }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "ogg-packet": { "version": "1.0.0", @@ -490,6 +759,33 @@ "ref-struct": "*" } }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, "pako": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", @@ -503,6 +799,11 @@ "@types/node": "^6.0.46" } }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -513,21 +814,44 @@ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" }, + "psl": { + "version": "1.1.29", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", + "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==" + }, "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" }, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, "readable-stream": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", @@ -564,30 +888,58 @@ } }, "request": { - "version": "2.87.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", - "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", "requires": { "aws-sign2": "~0.7.0", - "aws4": "^1.6.0", + "aws4": "^1.8.0", "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.1", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", "forever-agent": "~0.6.1", - "form-data": "~2.3.1", - "har-validator": "~5.0.3", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.17", - "oauth-sign": "~0.8.2", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", "performance-now": "^2.1.0", - "qs": "~6.5.1", - "safe-buffer": "^5.1.1", - "tough-cookie": "~2.3.3", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", "tunnel-agent": "^0.6.0", - "uuid": "^3.1.0" + "uuid": "^3.3.2" + }, + "dependencies": { + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "requires": { + "mime-db": "~1.37.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "^7.0.5" } }, "safe-buffer": { @@ -595,732 +947,57 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, "snekfetch": { - "version": "3.5.8", - "resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.5.8.tgz", - "integrity": "sha512-osq7soqKBObV4u/WE9tGQT/m5JdqTU1PWVPcT0We3sKZ99h9QA7wSj7ZWrwEwgRbELeO5BrVCanYjDYtVYcwrQ==" + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-4.0.4.tgz", + "integrity": "sha512-dyycG9fvwtSJqKPfMVOpXt+60qvMGe7vWLwOJDiSJaiAx+hs2EnFChG2bXCWn7ulz+zGzrHdN9/yeEb0YqEPww==" }, "sqlite3": { - "version": "3.1.13", - "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-3.1.13.tgz", - "integrity": "sha512-JxXKPJnkZ6NuHRojq+g2WXWBt3M1G9sjZaYiHEWSTGijDM3cwju/0T2XbWqMXFmPqDgw+iB7zKQvnns4bvzXlw==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-4.0.4.tgz", + "integrity": "sha512-CO8vZMyUXBPC+E3iXOCc7Tz2pAdq5BWfLcQmOokCOZW5S5sZ/paijiPOCdvzpdP83RroWHYa5xYlVqCxSqpnQg==", "requires": { - "nan": "~2.7.0", - "node-pre-gyp": "~0.6.38" + "nan": "~2.10.0", + "node-pre-gyp": "^0.10.3", + "request": "^2.87.0" }, "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true - }, - "ajv": { - "version": "4.11.8", - "bundled": true, - "requires": { - "co": "^4.6.0", - "json-stable-stringify": "^1.0.1" - } - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "bundled": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "asn1": { - "version": "0.2.3", - "bundled": true - }, - "assert-plus": { - "version": "0.2.0", - "bundled": true - }, - "asynckit": { - "version": "0.4.0", - "bundled": true - }, - "aws-sign2": { - "version": "0.6.0", - "bundled": true - }, - "aws4": { - "version": "1.6.0", - "bundled": true - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "bundled": true, - "optional": true, - "requires": { - "tweetnacl": "^0.14.3" - } - }, - "block-stream": { - "version": "0.0.9", - "bundled": true, - "requires": { - "inherits": "~2.0.0" - } - }, - "boom": { - "version": "2.10.1", - "bundled": true, - "requires": { - "hoek": "2.x.x" - } - }, - "brace-expansion": { - "version": "1.1.8", - "bundled": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "caseless": { - "version": "0.12.0", - "bundled": true - }, - "co": { - "version": "4.6.0", - "bundled": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true - }, - "combined-stream": { - "version": "1.0.5", - "bundled": true, - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "concat-map": { - "version": "0.0.1", - "bundled": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true - }, - "cryptiles": { - "version": "2.0.5", - "bundled": true, - "requires": { - "boom": "2.x.x" - } - }, - "dashdash": { - "version": "1.14.1", - "bundled": true, - "requires": { - "assert-plus": "^1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "debug": { - "version": "2.6.9", - "bundled": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.4.2", - "bundled": true - }, - "delayed-stream": { - "version": "1.0.0", - "bundled": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true - }, - "ecc-jsbn": { - "version": "0.1.1", - "bundled": true, - "optional": true, - "requires": { - "jsbn": "~0.1.0" - } - }, - "extend": { - "version": "3.0.1", - "bundled": true - }, - "extsprintf": { - "version": "1.3.0", - "bundled": true - }, - "forever-agent": { - "version": "0.6.1", - "bundled": true - }, - "form-data": { - "version": "2.1.4", - "bundled": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.5", - "mime-types": "^2.1.12" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true - }, - "fstream": { - "version": "1.0.11", - "bundled": true, - "requires": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" - } - }, - "fstream-ignore": { - "version": "1.0.5", - "bundled": true, - "requires": { - "fstream": "^1.0.0", - "inherits": "2", - "minimatch": "^3.0.0" - } - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "getpass": { - "version": "0.1.7", - "bundled": true, - "requires": { - "assert-plus": "^1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true - }, - "har-schema": { - "version": "1.0.5", - "bundled": true - }, - "har-validator": { - "version": "4.2.1", - "bundled": true, - "requires": { - "ajv": "^4.9.1", - "har-schema": "^1.0.5" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true - }, - "hawk": { - "version": "3.1.3", - "bundled": true, - "requires": { - "boom": "2.x.x", - "cryptiles": "2.x.x", - "hoek": "2.x.x", - "sntp": "1.x.x" - } - }, - "hoek": { - "version": "2.16.3", - "bundled": true - }, - "http-signature": { - "version": "1.1.1", - "bundled": true, - "requires": { - "assert-plus": "^0.2.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true - }, - "ini": { - "version": "1.3.4", - "bundled": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-typedarray": { - "version": "1.0.0", - "bundled": true - }, - "isarray": { - "version": "1.0.0", - "bundled": true - }, - "isstream": { - "version": "0.1.2", - "bundled": true - }, - "jsbn": { - "version": "0.1.1", - "bundled": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "bundled": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "bundled": true, - "requires": { - "jsonify": "~0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "bundled": true - }, - "jsonify": { - "version": "0.0.0", - "bundled": true - }, - "jsprim": { - "version": "1.4.1", - "bundled": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "mime-db": { - "version": "1.30.0", - "bundled": true - }, - "mime-types": { - "version": "2.1.17", - "bundled": true, - "requires": { - "mime-db": "~1.30.0" - } - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true - }, - "node-pre-gyp": { - "version": "0.6.38", - "bundled": true, - "requires": { - "hawk": "3.1.3", - "mkdirp": "^0.5.1", - "nopt": "^4.0.1", - "npmlog": "^4.0.2", - "rc": "^1.1.7", - "request": "2.81.0", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^2.2.1", - "tar-pack": "^3.4.0" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true - }, - "oauth-sign": { - "version": "0.8.2", - "bundled": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true - }, - "osenv": { - "version": "0.1.4", - "bundled": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true - }, - "performance-now": { - "version": "0.2.0", - "bundled": true - }, - "process-nextick-args": { - "version": "1.0.7", - "bundled": true - }, - "punycode": { - "version": "1.4.1", - "bundled": true - }, - "qs": { - "version": "6.4.0", - "bundled": true - }, - "rc": { - "version": "1.2.1", - "bundled": true, - "requires": { - "deep-extend": "~0.4.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true - } - } - }, - "readable-stream": { - "version": "2.3.3", - "bundled": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.0.3", - "util-deprecate": "~1.0.1" - } - }, - "request": { - "version": "2.81.0", - "bundled": true, - "requires": { - "aws-sign2": "~0.6.0", - "aws4": "^1.2.1", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.0", - "forever-agent": "~0.6.1", - "form-data": "~2.1.1", - "har-validator": "~4.2.1", - "hawk": "~3.1.3", - "http-signature": "~1.1.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.7", - "oauth-sign": "~0.8.1", - "performance-now": "^0.2.0", - "qs": "~6.4.0", - "safe-buffer": "^5.0.1", - "stringstream": "~0.0.4", - "tough-cookie": "~2.3.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.0.0" - } - }, - "rimraf": { - "version": "2.6.2", - "bundled": true, - "requires": { - "glob": "^7.0.5" - } - }, - "safe-buffer": { - "version": "5.1.1", - "bundled": true - }, - "semver": { - "version": "5.4.1", - "bundled": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true - }, - "sntp": { - "version": "1.0.9", - "bundled": true, - "requires": { - "hoek": "2.x.x" - } - }, - "sshpk": { - "version": "1.13.1", - "bundled": true, - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "tweetnacl": "~0.14.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.0.3", - "bundled": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "stringstream": { - "version": "0.0.5", - "bundled": true - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true - }, - "tar": { - "version": "2.2.1", - "bundled": true, - "requires": { - "block-stream": "*", - "fstream": "^1.0.2", - "inherits": "2" - } - }, - "tar-pack": { - "version": "3.4.0", - "bundled": true, - "requires": { - "debug": "^2.2.0", - "fstream": "^1.0.10", - "fstream-ignore": "^1.0.5", - "once": "^1.3.3", - "readable-stream": "^2.1.4", - "rimraf": "^2.5.1", - "tar": "^2.2.1", - "uid-number": "^0.0.6" - } - }, - "tough-cookie": { - "version": "2.3.3", - "bundled": true, - "requires": { - "punycode": "^1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "bundled": true, - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "bundled": true, - "optional": true - }, - "uid-number": { - "version": "0.0.6", - "bundled": true - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true - }, - "uuid": { - "version": "3.1.0", - "bundled": true - }, - "verror": { - "version": "1.10.0", - "bundled": true, - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true - } - } - }, - "wide-align": { - "version": "1.1.2", - "bundled": true, - "requires": { - "string-width": "^1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true + "nan": { + "version": "2.10.0", + "resolved": "http://registry.npmjs.org/nan/-/nan-2.10.0.tgz", + "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" } } }, "sshpk": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz", - "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz", + "integrity": "sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA==", "requires": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", @@ -1329,17 +1006,27 @@ "ecc-jsbn": "~0.1.1", "getpass": "^0.1.1", "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" }, "dependencies": { "tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "optional": true + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" } } }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", @@ -1348,12 +1035,54 @@ "safe-buffer": "~5.1.0" } }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "tar": { + "version": "4.4.8", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", + "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, "tough-cookie": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", "requires": { + "psl": "^1.1.24", "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + } } }, "tunnel-agent": { @@ -1369,15 +1098,23 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz", "integrity": "sha1-cT2LgY2kIGh0C/aDhtBHnmb8ins=" }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "requires": { + "punycode": "^2.1.0" + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, "verror": { "version": "1.10.0", @@ -1394,6 +1131,19 @@ "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=" }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, "ws": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz", @@ -1403,14 +1153,19 @@ "safe-buffer": "~5.1.0" } }, + "yallist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", + "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=" + }, "ytdl-core": { - "version": "0.20.4", - "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.20.4.tgz", - "integrity": "sha512-d+jthiJxSQ6yqCeCwwMggXYOjFSOJsD7ahvAAE1sFW9nVNnsA/roz91SFH1FzaMGS7/y7AnJfhVgpE9i8uYjJQ==", + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.28.0.tgz", + "integrity": "sha512-pk1nd0MPZLyMOENUOCFLBJ/m59XFqSWPzSY2UhdG7PHBwYtROAY5QRLoYEG0V21h7i3KUeHbnFq8czio5gPKYA==", "requires": { "html-entities": "^1.1.3", - "m3u8stream": "^0.2.1", - "miniget": "^1.1.0", + "m3u8stream": "^0.6.0", + "miniget": "^1.4.0", "sax": "^1.1.3" } } diff --git a/package.json b/package.json index 1b7b701..4ca958a 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ "moment": "^2.22.2", "moment-duration-format": "^1.3.0", "ms": "^2.0.0", - "node-fetch": "^2.2.0", + "node-fetch": "^2.2.1", "node-opus": "^0.2.7", "querystring": "^0.2.0", - "request": "^2.87.0", - "snekfetch": "^3.5.8", - "sqlite3": "^3.1.13", - "ytdl-core": "^0.20.4" + "request": "^2.88.0", + "snekfetch": "^4.0.4", + "sqlite3": "^4.0.4", + "ytdl-core": "^0.28.0" }, "devDependencies": {}, "repository": { From 20abafa091d58c9ab797fd3afb50058dc48937f9 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Wed, 14 Nov 2018 04:45:13 -0400 Subject: [PATCH 12/38] defaultChannel function fixed Fixed the defaultChannel search and updated the node-opus package. --- functions/defaultChannel.js | 51 +++++++++++++++++++++++------------- package-lock.json | 52 +++++++++++++++++++------------------ package.json | 2 +- 3 files changed, 61 insertions(+), 44 deletions(-) diff --git a/functions/defaultChannel.js b/functions/defaultChannel.js index 0685294..73f8cd1 100644 --- a/functions/defaultChannel.js +++ b/functions/defaultChannel.js @@ -1,22 +1,37 @@ -module.exports = (client, guildID, args) => { - var guild = client.guilds.find("id", guildID); - if (!client.settings.guilds.schema.defaultChannel || !client.settings.guilds.schema.modlog) { client.funcs.confAdd(client); } - - if (args[0] === "mod") { - if (client.settings.guilds.schema.modlog !== null) { - return guild.channels.find("id", guild.settings.modlog); - } else { return guild.channels.find("id", args[1].channel.id); } +module.exports = (client, guild, args) => { + if (!args) { args == "default"; } + var channelID = schemaCheck(client, args); + + if (channelID == false) { + channelID = locate(Array.from(guild.channels), ["general", "general-chat", "off-topic"]); + if (channelID == false) { + var channels = Array.from(guild.channels.sort((e1, e2) => e1.rawPosition - e2.rawPosition)); + for (var x = 0; x < channels.length; x++) { + var currChannel = channels[x][1]; + if (currChannel.type == "text" && currChannel.permissionsFor(guild.members.get(client.user.id)).has("SEND_MESSAGES")) { + channelID = currChannel.id; + x = channels.length; + } + } + } } - if (client.settings.guilds.schema.defaultChannel.default !== null) { return guild.channels.find("id", guild.settings.defaultChannel); } - else if (guild.channels.find("name", "general")) { return guild.channels.find("name", "general"); } - else if (guild.channels.find("id", guild.id)) { return guild.channels.find("id", guild.id); } - else { return guild.channels.find(c => c.permissionsFor(guild.me).has("SEND_MESSAGES")); } + + return guild.channels.get(channelID); }; -module.exports.conf = { requiredModules: [] }; - -module.exports.help = { - name: "defaultChannel", - type: "functions", - description: "Searchs for the 'default' channel of the server." +function schemaCheck(client, schema, args) { + var schema = client.settings.guilds.schema; + if(!schema.defaultChannel || !schema.modlog) { client.funcs.confAdd(client); } + + if(schema.defaultChannel != null && args == "default") { return schema.defaultChannel; } + else if(schema.modlog != null && args == "mod") { return schema.modlog; } + else { return false; } +}; + +function locate(cList, name) { + var channelList = Array.from(cList); + for (var x = 0; x < channelList.length; x++) { + if (name.includes(channelList[x][1].name)) { x = channelList.length; return channelList[x][1].id; } + if (x + 1 == channelList.length) { return false; } + } }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index be9fbaa..0fe701c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -153,9 +153,9 @@ } }, "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==" + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" }, "concat-map": { "version": "0.0.1", @@ -232,22 +232,16 @@ "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" }, "discord.js": { - "version": "github:hydrabolt/discord.js#2694c0d442a008a1e40c17df147a22bc9534049a", + "version": "github:hydrabolt/discord.js#3418b5a1a2e2e424369da42f0a04dc3523f3d933", "from": "github:hydrabolt/discord.js", "requires": { "form-data": "^2.3.2", "node-fetch": "^2.1.2", "pako": "^1.0.0", - "prism-media": "^0.3.0", + "prism-media": "github:amishshah/prism-media#1e336c9a20dd0928ef3bdc2075ab58d1521fb323", + "setimmediate": "^1.0.5", "tweetnacl": "^1.0.0", - "ws": "^4.0.0" - }, - "dependencies": { - "prism-media": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-0.3.1.tgz", - "integrity": "sha512-ZAzpXm6n7IaMDrcm7gB6wEkhF796cFLBZPY91rse5DKsASrZZgo36y9QC4+FnlbWt14aQSZUnKMHnkg6pEDfiQ==" - } + "ws": "^6.0.0" } }, "dom-serializer": { @@ -646,9 +640,9 @@ "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, "nan": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", - "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=" + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", + "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==" }, "needle": { "version": "2.2.4", @@ -666,13 +660,13 @@ "integrity": "sha512-ObXBpNCD3A/vYQiQtEWl7DuqjAXjfptYFuGHLdPl5U19/6kJuZV+8uMHLrkj3wJrJoyfg4nhgyFixZdaZoAiEQ==" }, "node-opus": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/node-opus/-/node-opus-0.2.7.tgz", - "integrity": "sha1-W3JuKXlbCxJ7TIfmYtTegWhAV5w=", + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/node-opus/-/node-opus-0.2.9.tgz", + "integrity": "sha512-+IIOdav5D7vHsuLDNk55t17kK2s6c1w4DbfKw8UQxZ635n+AO/SqDE3RpuO3PZKqpWjPtL/chzYZNVxz8/4TUQ==", "requires": { "bindings": "~1.2.1", "commander": "^2.9.0", - "nan": "^2.3.2", + "nan": "^2.10.0", "ogg-packet": "^1.0.0" } }, @@ -809,6 +803,10 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, + "prism-media": { + "version": "github:amishshah/prism-media#1e336c9a20dd0928ef3bdc2075ab58d1521fb323", + "from": "github:amishshah/prism-media" + }, "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", @@ -967,6 +965,11 @@ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -1145,12 +1148,11 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz", - "integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.0.tgz", + "integrity": "sha512-H3dGVdGvW2H8bnYpIDc3u3LH8Wue3Qh+Zto6aXXFzvESkTVT6rAfKR6tR/+coaUvxs8yHtmNV0uioBF62ZGSTg==", "requires": { - "async-limiter": "~1.0.0", - "safe-buffer": "~5.1.0" + "async-limiter": "~1.0.0" } }, "yallist": { diff --git a/package.json b/package.json index 4ca958a..e2799e1 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "moment-duration-format": "^1.3.0", "ms": "^2.0.0", "node-fetch": "^2.2.1", - "node-opus": "^0.2.7", + "node-opus": "^0.2.9", "querystring": "^0.2.0", "request": "^2.88.0", "snekfetch": "^4.0.4", From 269662d0c8b0320e6b0719134452a5dbbc3e614c Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Mon, 19 Nov 2018 00:54:37 -0400 Subject: [PATCH 13/38] Merged stats and about Merged the stats and about command and moved the new command into the system category. --- commands/General/about.js | 27 --------------------- commands/System/about.js | 49 +++++++++++++++++++++++++++++++++++++++ commands/System/stats.js | 37 ----------------------------- 3 files changed, 49 insertions(+), 64 deletions(-) delete mode 100644 commands/General/about.js create mode 100644 commands/System/about.js delete mode 100644 commands/System/stats.js diff --git a/commands/General/about.js b/commands/General/about.js deleted file mode 100644 index d1d9b21..0000000 --- a/commands/General/about.js +++ /dev/null @@ -1,27 +0,0 @@ -exports.run = async (client, msg) => { - const prefix = msg.guildSettings.prefix || client.config.prefix; - - const embed = new client.methods.Embed() - .setColor(0x37FDFC) - .setTimestamp() - .setTitle("About Margarine") - .setDescription(`I am a very helpful and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written in Komada, a Discord.js framework. - \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 *(Butterstroke#7150 tends to call it 'Fake Butter')* you can buy in stores called, Margarine. - \n**Creation:** I was created on ${client.user.createdAt.toLocaleString()} by ${client.owner.tag}. My current version is ${client.ownerSetting.get("build").version} as of ${client.ownerSetting.get("build").releaseDate}. - \n**More Information:** I have a Github repo which contains my current update tracker and the source code with [this link](https://github.com/Butterstroke/MargarineBot). For people looking for my TOS, please refer [here](https://github.com/Butterstroke/MargarineBot/blob/master/TermsAndService.md)`) - .setThumbnail(client.user.displayAvatarURL()); - msg.channel.send({embed}); -}; - -exports.conf = { - enabled: true, - runIn: ["text", "dm"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "about", - description: "General information.", usage: "" -}; \ No newline at end of file diff --git a/commands/System/about.js b/commands/System/about.js new file mode 100644 index 0000000..3db481b --- /dev/null +++ b/commands/System/about.js @@ -0,0 +1,49 @@ +const moment = require("moment"); +require("moment-duration-format"); + +exports.run = async (client, msg) => { + const prefix = msg.guildSettings.prefix || client.config.prefix; + const duration = moment.duration(client.uptime).format(" D [days], H [hours], m [minutes and] s [seconds]"); + const birthday = dateMaker(client.user.createdAt); + + const embed = new client.methods.Embed() + .setColor(0x37FDFC) + .setTitle("About Margarine") + .setDescription(`[Github](https://github.com/Butterstroke/MargarineBot) | [Terms Of Service](https://github.com/Butterstroke/MargarineBot/blob/master/TermsOfService.md) + \nI am a very helpful and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written in Komada, a Discord.js framework. + \n**Stats:** I have been online, helping out, for ${duration} using ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB of memory. ${client.users.size} users across ${client.guilds.size} guilds with ${client.channels.size.toLocaleString()} channels depend on my functions to be as reliable as possible! + \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 the ${birthday} by Butterstroke#7150.`) + .setThumbnail(client.user.displayAvatarURL()) + .setFooter("Running on Margarine " + client.ownerSetting.get("build").version + " | Released on: " + client.ownerSetting.get("build").releaseDate); + msg.channel.send({embed}); +}; + +exports.conf = { + enabled: true, + runIn: ["text", "dm"], + aliases: ["stats", "whoami"], + permLevel: 0, + botPerms: [] +}; + +exports.help = { + name: "about", + description: "General information.", usage: "" +}; + +function dateMaker(date) { + var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; + var ed = ["st", "nd", "rd", "th"]; + + var d = date.toLocaleString().split(" ")[0].split("-"); + + if (d[2][d[2].length - 1] === "1") { d[2] += ed[0]; } + else if (d[2][d[2].length - 1] === "2") { d[2] += ed[1]; } + else if (d[2][d[2].length - 1] === "3") { d[2] += ed[2]; } + else { d[2] += ed[3]; } + + d = d[2] + " " + months[d[1]] + ", " + d[0]; + + return d; +}; \ No newline at end of file diff --git a/commands/System/stats.js b/commands/System/stats.js deleted file mode 100644 index 6979b55..0000000 --- a/commands/System/stats.js +++ /dev/null @@ -1,37 +0,0 @@ -/* Base command taken from Komada. Modified slightly*/ -const { version: discordVersion } = require("discord.js"); -const { version: komadaVersion } = require("komada"); -const moment = require("moment"); -require("moment-duration-format"); - -exports.run = async (client, message) => { - const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]"); - message.channel.send(`= GENERAL = -ā€¢ Margarine :: ${client.ownerSetting.get("build").version} -ā€¢ Mem Usage :: ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB -ā€¢ Uptime :: ${duration} - -= USERS = -ā€¢ Users :: ${client.users.size} -ā€¢ Servers :: ${client.guilds.size} -ā€¢ Channels :: ${client.channels.size.toLocaleString()} - -= DEPENDENCIES = -ā€¢ Komada :: v${komadaVersion} -ā€¢ Discord.js :: v${discordVersion} -ā€¢ Node.js :: ${process.version}`, { code: "asciidoc" }); -}; - -exports.conf = { - enabled: true, - runIn: ["text", "dm"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "stats", - description: "Provides some details about the bot and stats.", - usage: "" -}; \ No newline at end of file From 6c522c70163f7967ab4518ccb873d9f9799f55ee Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Mon, 19 Nov 2018 01:01:18 -0400 Subject: [PATCH 14/38] Update package-lock.json Updated the discord.js package --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0fe701c..3fe5473 100644 --- a/package-lock.json +++ b/package-lock.json @@ -232,7 +232,7 @@ "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" }, "discord.js": { - "version": "github:hydrabolt/discord.js#3418b5a1a2e2e424369da42f0a04dc3523f3d933", + "version": "github:hydrabolt/discord.js#d92ee2ff999954899c891c093f5f107dd686b64f", "from": "github:hydrabolt/discord.js", "requires": { "form-data": "^2.3.2", @@ -1148,9 +1148,9 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.0.tgz", - "integrity": "sha512-H3dGVdGvW2H8bnYpIDc3u3LH8Wue3Qh+Zto6aXXFzvESkTVT6rAfKR6tR/+coaUvxs8yHtmNV0uioBF62ZGSTg==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.2.tgz", + "integrity": "sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw==", "requires": { "async-limiter": "~1.0.0" } From cc0cfbc7d49f6c1929d5b5b2a531e932a33b1f29 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Wed, 19 Dec 2018 01:31:07 -0500 Subject: [PATCH 15/38] Startup Functions Added the start to the functions that will run before Margarine connects to Discord. Also changed the README file to match version and updated packages. --- README.md | 22 +++---- commands/General/anilist.js | 6 +- functions/defaultChannel.js | 2 +- package-lock.json | 125 +++++++++++++++++++++++++++++++----- package.json | 10 +-- utilities/commandRemover.js | 11 ++++ utilities/envCheck.js | 18 ++++++ utilities/utilExport.js | 3 + 8 files changed, 159 insertions(+), 38 deletions(-) create mode 100644 utilities/commandRemover.js create mode 100644 utilities/envCheck.js create mode 100644 utilities/utilExport.js diff --git a/README.md b/README.md index ff38853..97cac53 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,25 @@ -# MargarineBot - Version: Beta 0.9 +# MargarineBot - Version: Release 1.0 [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f0cfd83063a4469b8e40bcc824c2600d)](https://www.codacy.com/app/Butterstroke/MargarineBot?utm_source=github.com&utm_medium=referral&utm_content=Butterstroke/MargarineBot&utm_campaign=Badge_Grade) A Discord bot coded in Node.js using the Discord.js Library and the Komada framework. Introduction: -Created through part-desire, part-what can I do in Discord, part-I'm going to learn Javascript, and part-it's only 12 am thoughts, Margarine has been my personal project for almost 6 months now. I am quite proud of the functionality and the time I have spend into Margarine. I have received plenty of support over the months of developing him and I can't thank those people enough as without that support, Margarine would have never been as big as he is today. I hope that you enjoy either looking at/learning/using 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 12 am thoughts, Margarine has been my personal project for several months now. For the amount of time and effort I've spent on developing him, I'm quite proud of the functionality and features that I've put into him. I have received plenty of support over the months of developing him and I can't thank those people enough as without that support, Margarine would have never been as big or as good as he is today. I hope that you enjoy either looking at/learning/using Margarine as much as I do. *Name Origin:* My typical nickname is Butter, as in the stuff that you put on toast. His name comes from the artificial butter (I tends to call it 'Fake Butter') you can buy in stores called, Margarine. - + +Requirements: +- Discord.js v12.0.0-dev (Install the master branch) +- Komada v0.21.1 +- Node.js version v8.0.0+ Features: - Moderation commands - Permission levels - Fun, small games like Rock, Paper, Scissors - Server/User/role info commands -- Economy system (No SQL or any other server needed! All data is local to the folder.) +- Economy system using a SQLite database - Music commands (Play your favourite tunes through Youtube!) -Updates: -- 02 June 2018: Beta 0.9 Release -- 30 November 2017: Beta 0.8 Released -- 31 October 2017: Beta 0.7 Released -- 30 September 2017: Beta 0.6 Released -- 15 August 2017: Beta 0.5 Released -- 14 July 2017: Beta 0.4 Released -- 6 June 2017: Beta 0.3 Released -- 30 May 2017: Beta 0.2 Released - Invite me! Not available at the current moment as the bot is in development. diff --git a/commands/General/anilist.js b/commands/General/anilist.js index 969e51a..adf3e11 100644 --- a/commands/General/anilist.js +++ b/commands/General/anilist.js @@ -2,14 +2,14 @@ const fetch = require("node-fetch"); exports.run = async (client, msg, [term]) => { var options = { - method: 'POST', - headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, + method: "POST", + headers: { "Content-Type": "application/json", "Accept": "application/json" }, body: JSON.stringify({ query: `query ($name: String) { User(name: $name) { avatar { large } siteUrl stats { watchedTime chaptersRead animeListScores { meanScore } mangaListScores { meanScore } animeStatusDistribution { status amount } mangaStatusDistribution { status amount } } } }`, variables: { name: term } }) }; - var response = await fetch('https://graphql.anilist.co', options); + var response = await fetch("https://graphql.anilist.co", options); var json = await response.json(); if (!json.data.User.stats) { return msg.channel.send("Anilist profile by that user is not found!"); } var data = json.data.User, diff --git a/functions/defaultChannel.js b/functions/defaultChannel.js index 73f8cd1..3435aa2 100644 --- a/functions/defaultChannel.js +++ b/functions/defaultChannel.js @@ -31,7 +31,7 @@ function schemaCheck(client, schema, args) { function locate(cList, name) { var channelList = Array.from(cList); for (var x = 0; x < channelList.length; x++) { - if (name.includes(channelList[x][1].name)) { x = channelList.length; return channelList[x][1].id; } + if (name.includes(channelList[x][1].name) && channelList[x][1].type == "text") { x = channelList.length; return channelList[x][1].id; } if (x + 1 == channelList.length) { return false; } } }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3fe5473..636fc79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -116,6 +116,11 @@ "concat-map": "0.0.1" } }, + "capture-stack-trace": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz", + "integrity": "sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw==" + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -172,6 +177,14 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "create-error-class": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", + "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", + "requires": { + "capture-stack-trace": "^1.0.0" + } + }, "css-select": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", @@ -282,6 +295,11 @@ "domelementtype": "1" } }, + "duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -372,6 +390,11 @@ "wide-align": "^1.1.0" } }, + "get-stream": { + "version": "3.0.0", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -393,6 +416,24 @@ "path-is-absolute": "^1.0.0" } }, + "got": { + "version": "6.7.1", + "resolved": "http://registry.npmjs.org/got/-/got-6.7.1.tgz", + "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", + "requires": { + "create-error-class": "^3.0.0", + "duplexer3": "^0.1.4", + "get-stream": "^3.0.0", + "is-redirect": "^1.0.0", + "is-retry-allowed": "^1.0.0", + "is-stream": "^1.0.0", + "lowercase-keys": "^1.0.0", + "safe-buffer": "^5.0.1", + "timed-out": "^4.0.0", + "unzip-response": "^2.0.1", + "url-parse-lax": "^1.0.0" + } + }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -483,6 +524,21 @@ "number-is-nan": "^1.0.0" } }, + "is-redirect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", + "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=" + }, + "is-retry-allowed": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", + "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=" + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -552,10 +608,15 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" }, + "lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" + }, "m3u8stream": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.6.0.tgz", - "integrity": "sha512-h78ollIa7zeq0nzx1+wI/EH0soUpe9A7sC6zw/+/tuRwYdIXedOytvI69+6eP/FU4Ph0cT6kQsw73j5tKXIbgg==", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.6.2.tgz", + "integrity": "sha512-WsuM2bd5pPN80xvfrB+1DZqr4M7+kJl8byi6+ZCy6cmVjEiHhmr/desN53Ngsa6Hs13kYumeVgT4wL0oIJ+v6g==", "requires": { "miniget": "^1.4.0", "sax": "^1.2.4" @@ -575,9 +636,9 @@ } }, "miniget": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.5.0.tgz", - "integrity": "sha512-RbRCj2m8Q/arS1nExuMB8qO4QavCpvfetQR+HVCeHGiFJGOryPn8u0z4WrIx9AAIDYFDVcFhQsRYvSY+UA5HJQ==" + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.5.1.tgz", + "integrity": "sha512-KJ3AyIVZ76QuWAq43BWjkK+jLdhxhy3s4tsdg9Je91+cIFkeOSW2VEj2lSeKw50CPu1eCCkSbiQEBKL36mpA5w==" }, "minimatch": { "version": "3.0.4", @@ -655,14 +716,14 @@ } }, "node-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.1.tgz", - "integrity": "sha512-ObXBpNCD3A/vYQiQtEWl7DuqjAXjfptYFuGHLdPl5U19/6kJuZV+8uMHLrkj3wJrJoyfg4nhgyFixZdaZoAiEQ==" + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", + "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" }, "node-opus": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/node-opus/-/node-opus-0.2.9.tgz", - "integrity": "sha512-+IIOdav5D7vHsuLDNk55t17kK2s6c1w4DbfKw8UQxZ635n+AO/SqDE3RpuO3PZKqpWjPtL/chzYZNVxz8/4TUQ==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/node-opus/-/node-opus-0.3.1.tgz", + "integrity": "sha512-1Cb8OvHhdDspVfeKMjEgbedJabyE1Ib6OcN2BMEsRCU7FIsciuBpOErcie3y0qTf83nclPAY+kBU3Oj+U+oRlQ==", "requires": { "bindings": "~1.2.1", "commander": "^2.9.0", @@ -803,6 +864,11 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=" + }, "prism-media": { "version": "github:amishshah/prism-media#1e336c9a20dd0928ef3bdc2075ab58d1521fb323", "from": "github:amishshah/prism-media" @@ -1072,6 +1138,11 @@ } } }, + "timed-out": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", + "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -1101,6 +1172,11 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz", "integrity": "sha1-cT2LgY2kIGh0C/aDhtBHnmb8ins=" }, + "unzip-response": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", + "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=" + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -1109,6 +1185,14 @@ "punycode": "^2.1.0" } }, + "url-parse-lax": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "requires": { + "prepend-http": "^1.0.1" + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -1160,13 +1244,22 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=" }, + "youtube-playlist": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/youtube-playlist/-/youtube-playlist-1.0.2.tgz", + "integrity": "sha512-2NpfFqBGUYBl085kcGNctiEd6vRMXRPGHwzcFTsaEap63zUiEmmHpP6StNFu4DGnuEOfn46gt3yNXm0r8K6xvg==", + "requires": { + "cheerio": "^1.0.0-rc.2", + "got": "^6.3.0" + } + }, "ytdl-core": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.28.0.tgz", - "integrity": "sha512-pk1nd0MPZLyMOENUOCFLBJ/m59XFqSWPzSY2UhdG7PHBwYtROAY5QRLoYEG0V21h7i3KUeHbnFq8czio5gPKYA==", + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.28.2.tgz", + "integrity": "sha512-D9cjjE3qajIMqB/noJ05/PVPbzDxMoILq34Pe8QaCIgFpMBcBx88fEZWxXTZPDGlyUcbPGQ1pxQKKzV5QHhmgw==", "requires": { "html-entities": "^1.1.3", - "m3u8stream": "^0.6.0", + "m3u8stream": "^0.6.2", "miniget": "^1.4.0", "sax": "^1.1.3" } diff --git a/package.json b/package.json index e2799e1..366aec4 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,14 @@ "moment": "^2.22.2", "moment-duration-format": "^1.3.0", "ms": "^2.0.0", - "node-fetch": "^2.2.1", - "node-opus": "^0.2.9", + "node-fetch": "^2.3.0", + "node-opus": "^0.3.1", "querystring": "^0.2.0", "request": "^2.88.0", "snekfetch": "^4.0.4", "sqlite3": "^4.0.4", - "ytdl-core": "^0.28.0" + "youtube-playlist": "^1.0.2", + "ytdl-core": "^0.28.2" }, "devDependencies": {}, "repository": { @@ -25,7 +26,8 @@ "url": "git+https://github.com/butterstroke/MargarineBot" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node index.js" }, "author": "Butterstroke", "license": "Apache-2.0" diff --git a/utilities/commandRemover.js b/utilities/commandRemover.js new file mode 100644 index 0000000..317b113 --- /dev/null +++ b/utilities/commandRemover.js @@ -0,0 +1,11 @@ +const fs = require("fs"); + +module.exports = function(client) { + var files = ["stats", "download", "info", "ping", "invite", "reboot", "help"]; + + for(var x = 0; x < files.length; x++) { + if (fs.existsSync(client.clientBaseDir + "\\node_modules\\komada\\src\\commands\\System\\" + files[x] + ".js")) { + fs.unlinkSync(client.clientBaseDir + "\\node_modules\\komada\\src\\commands\\System\\" + files[x] + ".js"); + } + } +}; \ No newline at end of file diff --git a/utilities/envCheck.js b/utilities/envCheck.js new file mode 100644 index 0000000..2a53402 --- /dev/null +++ b/utilities/envCheck.js @@ -0,0 +1,18 @@ +module.exports = () => { + const { version: djsVersion } = require("discord.js"); + const { version: kVersion } = require("komada"); + + var missingDep = []; + + var nVersion = process.version.split("v")[1].split("."); + nVersion = Number(nVersion[0] + "." + nVersion[1]); + + if (djsVersion != "12.0.0-dev") { missingDep.push("You are not using the right discord.js package! Required version: v12.0.0-dev"); } + if (kVersion != "0.21.1") { missingDep.push("You are not using the right Komada version! Required version: v0.21.1"); } + if (nVersion < 8.0) { missingDep.push("You are not using the right node.js version! Required version: v8.5.0+"); } + + var correctEnv = (missingDep.length > 0) ? false : true; + + if (correctEnv === false) { console.log(missingDep.join("\n")); process.exit(); } + else { return; } +}; \ No newline at end of file diff --git a/utilities/utilExport.js b/utilities/utilExport.js new file mode 100644 index 0000000..9d580db --- /dev/null +++ b/utilities/utilExport.js @@ -0,0 +1,3 @@ +//exports.speech = require("./speechHelper.js"); +exports.remove = require("./commandRemover.js"); +exports.envCheck = require("./envCheck.js"); \ No newline at end of file From e89f2af8460c79c7e183ad8268bbe3a889e6c9e0 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Fri, 21 Dec 2018 00:01:25 -0500 Subject: [PATCH 16/38] Updated userSearch Updated TOS for self-hosting. Updated the userSearch function. Added the musicCheck function for later updates. --- TermsOfService.md | 7 +++- functions/musicCheck.js | 19 +++++++++ functions/userSearch.js | 93 +++++++++++++++++------------------------ 3 files changed, 63 insertions(+), 56 deletions(-) create mode 100644 functions/musicCheck.js diff --git a/TermsOfService.md b/TermsOfService.md index 1301f39..f676327 100644 --- a/TermsOfService.md +++ b/TermsOfService.md @@ -1,7 +1,7 @@

Margarine's Terms of Service

The agreements for the users of Margarine due to Discord's Developer Terms of Service (Defined as Discord TOS). -**Last Updated:** 24 May, 2018 +**Last Updated:** 20 December, 2018 **Usage:** By using Margarine, users agree to have their information usable and manipulated for improving and general use of Margarine. Any data collected will be collected anonymously and, in most cases, not stored. @@ -20,7 +20,10 @@ For users of the developer version of Margarine, a command may be reload with `c **Data Requests and Removal:** Users may contact the developer for the current user profile on Margarine at any time using the contact information defined in the contact section. The user's information will be sent to them in the most convenient way for both parties and decrypted for general viewing. After the profile has been received, the developer will delete the sent file 48-72 hours later and any leak from that file will be up to the user's responsibility and discretion. -If the user wants for their user profile to be deleted for whatever reason, they may message the people in the contact section below. However, once deleted, there is no way to recover the lost data. +If the user wants for their user profile to be deleted for whatever reason, they may message the people in the contact section below. However, once deleted, there is no way to recover the lost data. The exception to this rule is in cases of self-hosting, in which the user must send their request to the person responsible for the hosted instance. + +**Self-Hosting** +For any issues relating to a self-hosted instance of Margarine, the user must send their requests to the person responsible for the self-hosting. The developer is not responsible for any misuse conducted by the self-hosted instances of the program. However, if general questions about Margarine do arise, please see the Contact section of the terms for information on how to get in touch with the developer. **Disclaimer:** If for any reason Margarine needs to store more data, these terms will change with notice in future releases. If users are using the developer version of Margarine, these terms may change overnight. The developer(s) will try to pass the news on quickly, however, cannot guarantee that the news will be current before the changes happen. Any questions based on recent changes, please refer to the Contact section of this file. diff --git a/functions/musicCheck.js b/functions/musicCheck.js new file mode 100644 index 0000000..7984769 --- /dev/null +++ b/functions/musicCheck.js @@ -0,0 +1,19 @@ +module.exports = (msg, tag) => { + var result, speech; + var client = msg.client; + if (!msg.member.voice.channelID) { + result = false; + speech = client.speech(msg, ["func-music", "general", "userVC"]); + } else if (tag != "join") { + if (!client.music.get(msg.guild.id)) { + result = false; + speech = client.speech(msg, ["func-music", "general", "noQueue"]); + } else if (msg.member.voice.channelID !== client.music.get(msg.guild.id).channel.id) { + result = false; + speech = client.speech(msg, ["func-music", "general", "mismatch"]); + } else { result = client.music.get(msg.guild.id); } + } else { result = true; } + + if(speech) { msg.channel.send(speech); } + return result; +}; \ No newline at end of file diff --git a/functions/userSearch.js b/functions/userSearch.js index 4d0f172..901d2c0 100644 --- a/functions/userSearch.js +++ b/functions/userSearch.js @@ -1,38 +1,44 @@ -module.exports = async (client, msg, args) => { - var users = args.user || [null]; - var tags = args.tags || ["None"]; - var amount = args.user.length; var x = 0; var data = []; +module.exports = async (client, msg, user, tags) => { + if (!user || user.length < 1) { user = [null]; } + if (!tags || tags.length < 1) { tags = ["None"]; } - do { - if (users[x] == null || users[x].length < 1) { var user = msg.author; } - else if (msg.mentions.users.size > 1 && msg.content.startsWith("<")) { - var item = Array.from(msg.mentions.users); - var user = item[1]; - } else if (msg.mentions.users.size > 0 && msg.content.startsWith("<") === false) { var user = msg.mentions.users.first(); } - else if (/^(\d{17,21})$/.test(users[x])) { var user = await Promise.resolve(msg.client.users.fetch(users[x])); } - else if (msg.client.users.get("username", users[x]) !== null) { var user = msg.client.users.get("username", users[x]); } - - if (!user) { var user = users[x]; } - msg.channel.guild.members.forEach(element => { - if (typeof user === "object") { - if (element.user.username.toLowerCase() === user.username.toLowerCase()) { - data.push(this.userObjects(element)); - } - } else if (element.nickname) { - if (element.nickname.toLowerCase() === user.toLowerCase()) { - data.push(this.userObjects(element)); - } - } - }); - x++; - } while (x < amount); + if (typeof user === "object") { user = user[0]; } + + if (user === null) { user = msg.author.id; } + else if (msg.mentions.users.size > 1 && msg.content.startsWith("<")) { + var item = Array.from(msg.mentions.users); + user = item[0][1].toString().slice(2, -1); + } else if (msg.mentions.users.size > 0) { + if (msg.content.startsWith("<") === false) { user = msg.mentions.users.first().id; } + else if (msg.content.indexOf("<") != msg.content.lastIndexOf("<")) { user = Array.from(msg.mentions.users)[0][1].toString().slice(2, -1); } + } + else if (/^(\d{17,21})$/.test(user)) { + user = await Promise.resolve(client.users.fetch(user)); + user = user.id; + } - if (data.length !== args.user.length) { var text = client.speech(["userSearch", "default"]); } - else if (tags.includes("bot") && user.bot === true) { var text = client.speech(["userSearch", args.name]); } + var members = Array.from(msg.guild.members); + if (/^(\d{17,21})$/.test(user) === false) { + for (var x = 0; x < members.length; x++) { + if (user.toLowerCase() === members[x][1].user.username.toLowerCase()) { + user = msg.guild.members.get(members[x][0]); + x = members.length; + } + else if (members[x][1].nickname && user.toLowerCase() === members[x][1].nickname.toLowerCase()) { + user = msg.guild.members.get(members[x][0]); + x = members.length; + } + else if (x + 1 === members.length) { user == null; } + } + } else { user = msg.guild.members.get(user); } - var valid = (text) ? false : true; - if (valid === false) { msg.channel.send(text); data = text; } - return { valid: valid, user: data }; + if (user === null) { + msg.channel.send(client.speech(msg, ["func-userSearch", "default"])); + return false; + } else if (user.user.bot == true && tags.includes("bot")) { + msg.channel.send(client.speech(msg, ["func-userSearch", tags[0]])); + return false; + } else { return user; } }; module.exports.conf = { requiredModules: [] }; @@ -40,26 +46,5 @@ module.exports.conf = { requiredModules: [] }; module.exports.help = { name: "userSearch", type: "functions", - description: "Searchs for a user with a mention, username, or a guild nickname. Search is case-sensitive.", -}; - -exports.userObjects = (element) => { - let name = element.nickname ? element.nickname : element.user.username; - - return { - id: element.user.id, - username: element.user.username, - bot: element.user.bot, - discriminator: element.user.discriminator, - tag: element.user.username + "#" + element.user.discriminator, - ping: "<@" + element.user.id + ">", - speaking: element.speaking, - nickname: element.nickname, - prefered: name, - info: { - avatar: element.user.avatar, - joined: element.joinedTimestamp, - roles: element._roles - } - }; + description: "Searchs for a user with a mention, username, or a guild nickname.", }; \ No newline at end of file From 4b5df93386f4313211ee93ae19af713d931b08b1 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Sat, 22 Dec 2018 22:40:17 -0500 Subject: [PATCH 17/38] Rewrite push! Go! Go! Go! Complete overhaul of the music module Complete overhaul of the speech module Complete overhaul of the index file Part 1 of many more to come! --- README.md | 11 ++- assets/speech/en/music.js | 142 ++++++++++++++++++++++++++++++++ assets/speech/en/transaction.js | 41 +++++++++ assets/speech/en/userSearch.js | 43 ++++++++++ commandRemover.js | 11 --- commands/General/greet.js | 9 +- commands/General/help.js | 2 +- commands/General/info.js | 43 +++++----- commands/Music/join.js | 37 ++++++--- commands/Music/leave.js | 40 +++++---- commands/Music/nowplaying.js | 20 ++--- commands/Music/pause.js | 18 ++-- commands/Music/play.js | 56 +++++++------ commands/Music/queue.js | 39 ++++----- commands/Music/queueadd.js | 62 ++++++++------ commands/Music/remove.js | 23 ++---- commands/Music/resume.js | 13 +-- commands/Music/skip.js | 11 ++- commands/Music/volume.js | 23 +++--- commands/System/about.js | 14 +--- commands/System/exit.js | 3 +- commands/System/ping.js | 3 +- functions/musicCheck.js | 2 +- functions/transaction.js | 37 +++++++++ functions/transactions.js | 53 ------------ functions/userSearch.js | 4 +- functions/validator.js | 29 ------- index.js | 48 +++++------ utilities/speechHelper.js | 26 ++++++ utilities/utilExport.js | 2 +- 30 files changed, 528 insertions(+), 337 deletions(-) create mode 100644 assets/speech/en/music.js create mode 100644 assets/speech/en/transaction.js create mode 100644 assets/speech/en/userSearch.js delete mode 100644 commandRemover.js create mode 100644 functions/transaction.js delete mode 100644 functions/transactions.js delete mode 100644 functions/validator.js create mode 100644 utilities/speechHelper.js diff --git a/README.md b/README.md index 97cac53..8cce68d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # MargarineBot - Version: Release 1.0 -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f0cfd83063a4469b8e40bcc824c2600d)](https://www.codacy.com/app/Butterstroke/MargarineBot?utm_source=github.com&utm_medium=referral&utm_content=Butterstroke/MargarineBot&utm_campaign=Badge_Grade) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f0cfd83063a4469b8e40bcc824c2600d)](https://www.codacy.com/app/Butterstroke/MargarineBot?utm_source=github.com&utm_medium=referral&utm_content=Butterstroke/MargarineBot&utm_campaign=Badge_Grade) ![License](https://img.shields.io/github/license/Butterstroke/MargarineBot.svg?style=flat-square) + +Dependencies + +![discord.js](https://img.shields.io/badge/discord.js-v12.0.0--dev-brightgreen.svg) ![komada](https://img.shields.io/badge/Komada-v0.21.1-brightgreen.svg) ![node](https://img.shields.io/badge/Node-v8.0.0+-brightgreen.svg) A Discord bot coded in Node.js using the Discord.js Library and the Komada framework. @@ -8,11 +12,6 @@ Created through part-desire, part-what can I do in Discord, part-I'm going to le *Name Origin:* My typical nickname is Butter, as in the stuff that you put on toast. His name comes from the artificial butter (I tends to call it 'Fake Butter') you can buy in stores called, Margarine. -Requirements: -- Discord.js v12.0.0-dev (Install the master branch) -- Komada v0.21.1 -- Node.js version v8.0.0+ - Features: - Moderation commands - Permission levels diff --git a/assets/speech/en/music.js b/assets/speech/en/music.js new file mode 100644 index 0000000..994858e --- /dev/null +++ b/assets/speech/en/music.js @@ -0,0 +1,142 @@ +exports.join = { + "noConnect": [ + ":x: I do not have enough permissions to connect to your voice channel. I am missing the connect permission. (You may want to check if I can speak in that channel too :wink:)" + ], + "noSpeak": [ + "Wow. Invite me to play music for you, yet I can't speak in the channel. You are more heartless than my owner. Give me the channel permission to speak and then try again." + ], + "success": [ + "Now tuned into: -channel. Ready and awaiting orders!", + "Preparing the DJ station in -channel. Now ready for your requested songs!" + ] +}; + +exports.leave = [ + "I have left -channel.", + "The party is now over in -channel." +]; + +exports.nowplaying = { + "noQueue": [ + "I don't have any songs to play, baka! Add some using -prefixqueueadd `Youtube URL`", + "The queue is as existant as your waifu right now. You should add some songs." + ], + "notPlay": [ + "Hmm... good question. None of the above. I am not playing anything right now!" + ], + "success": [/*Placeholder as this is not needed currently*/] +}; + +exports.pause = { + "paused": [ + "BAKA! Your stream is already paused!", + "The stream is already paused, baka!" + ], + "success": [ + "āø The mix is now paused." + ] +}; + +exports.play = { + "alreadyPlay": [ + "I'm already playing in your channel, baka!", + "Can't you tell I'm playing music for you..." + ], //Already playing + "noQueue": [ + "Add some songs to the mix first with -prefixqueueadd [Youtube URL]", + "Whoops! You forgot to add some songs to the queue!", + "BAKA! There is no music in your queue!" + ], //Nothing to play + "allDone": [ + "Looks like my job is done. Add more songs or kick me out of the channel. It doesn't matter to me, baka." + ], //No more to play + "nextSong": [ + "šŸ“» Playing -request's request: **-title**" + ] //Next song playing +}; + +exports.queue = [ + "I can't show you that page for its page number is greater than my queue pages. There are currently -pgs", + "Your number is higher than -pgs. So, there is nothing to see there." +]; + +exports.queueadd = { + "noURL": [ + "You must provide me with a valid Youtube URL, BAKA!", + "What is this? This is not a URL I requested!" + ], + "listDetect": [ + "Looks like you want a playlist. Hold tight, this may take awhile." + ], + "success": [ + "šŸŽµ Added **-title** to the queue šŸŽ¶", + "šŸŽ§ **-title** has been added to the queue" + ], + "multi": [ + "šŸŽµ Added **-number** songs to the queue šŸŽ¶", + "I've finished adding **-number** songs to the queue. Time for a break." + ] +}; + +exports.remove = { + "noInt": [ + "I only have songs queued in integers. Come back with a whole number, will you?" + ], + "success": [ + "**-title** has been removed from the queue." + ] +}; + +exports.resume = { + "noPause": [ + "The stream isn't paused at the moment." + ], + "success": [ + "ā–¶ Now resuming your tunes. Keep partying!" + ] +}; + +exports.skip = [ + "ā­ Skipped the current song.", + "On to the next song! ā­" +]; + +exports.volume = { + "noArgs": [ + "šŸ“¢ Volume: -vol%", + "Currently playing at -vol%" + ], + "zero": [ + "You might as well mute me if you don't want any noise." + ], + "overHun": [ + "100% is the max. You just can't have 110%.." + ], + "notPlay": [ + "Kind of hard to adjust the volume if I am not playing music." + ], + "success": [ + "-action the volume! Volume: -vol%", + "-action the volume to -vol% as requested!" + ] +}; + +exports.general = { + "userVC": [ + "You need to be in a voice channel first, BAKA!", + "You aren't even in a voice channel! Don't leave me all alone in a voice channel!", + "BAKA! You aren't even in a voice channel to begin with! Enter in my voice channel and tell me face to face!" + ], //User not in VC + "noQueue": [ + "I'm not even in a voice channel, baka!", + "I need to be playing music before we do any of that!", + "It looks like I'm not in a voice channel to begin with...", + "How can I be playing music when I am not in a voice channel, baka!" + ], //Margarine not in a VC + "mismatch": [ + "You are not connected in my voice channel, baka!", + "BAKA! You aren't even in my voice channel to begin with!", + "You are not in my voice channel! Come in and tell me face to face!", + "I'm already playing in another VC. You should join in on the fun instead!" + ] //Margarine not in the same VC +}; \ No newline at end of file diff --git a/assets/speech/en/transaction.js b/assets/speech/en/transaction.js new file mode 100644 index 0000000..d9b85ba --- /dev/null +++ b/assets/speech/en/transaction.js @@ -0,0 +1,41 @@ +exports.validate = { + "none": [ + "You didn't supply me with an amount of credits, baka!", + "Credits? Hello? I need an amount of credits!", + "A man once said you always have value in life. Apparently, you can't spread some of that wealth into your command." + ], + "zero": [ + "You can't use zero credits here! Use some *actual* credits and then we'll talk.", + "...wow, I didn't know you were that oblivious to credits. You don't bet **nothing**, baka!", + "We've divided by zero. It didn't go so well...", + "Zero is an evil number. Don't give me these evils to work with." + ], + "noInt": [ + "There is no decimal work in credits! Whole credits only.", + "You can't split a credit! Give me a whole number, baka!", + "Decimals? That's like giving me fraction work. No thanks!", + "Decimals: fun to look at, not possible with what you are trying to do.", + "The only decimals I like to look at is in human currency. My credits are not that so keep them away!" + ] +}; + +exports.dbCheck = { + "err": [ + "Hmm... it seems like I've encountered an error. Please try again later." + ], + "noRow": [ + "You haven't redeemed your first daily yet! :cry:", + "You haven't signed up and received your credits yet! D:", + "You need some credits to do this, baka! Get some with the daily command!", + "Credits speak a whole lot of value in these parts. Set yourself up with a daily command first!", + "Get yourself some credits first!", + "Where are your credits?! Oh. You haven't redeemed your first daily yet...", + "Oh... you didn't redeem your first daily yet..." + ], + "lessCredit": [ + "You don't have that many credits, baka!", + "A poor person like yourself could never afford that bet.", + "Try paying in dirt. It's worth more than your bank right now.", + "Try to pull a fast one on me? Too bad you can't afford it, baka!" + ] +}; \ No newline at end of file diff --git a/assets/speech/en/userSearch.js b/assets/speech/en/userSearch.js new file mode 100644 index 0000000..78dfc60 --- /dev/null +++ b/assets/speech/en/userSearch.js @@ -0,0 +1,43 @@ +exports.daily = [ + "You can't give your credits to a bot user, baka!", + "Bots don't have records within our bank to take dailies!", + "What is the bot going to do with all of these credits? It's more useful not to take a daily at this point." +]; + +exports.balance = [ + "Bots can't have any records!", + "Bots aren't allowed to have bank accounts. They could hack them easily at this point.", + "You are lucky I don't have one because then I'd show you the true power of business!" +]; + +exports.rep = [ + "You can't give rep to a bot user. However, as long as you keep interacting with them, I'm sure they will be happy! :smile:", + "Bots can't have rep, baka!", + "A bot's reputation is on how well you like it. It doesn't need points to show it." +]; + +exports.exchange = [ + "You can't give your credits to a bot user!", + "Exchanging to a bot user is just not possible. They are known to do foul things with money from time to time.", + "Nope! No can do. Bots can't have credits." +]; + +exports.award = [ + "Awarding a non-existant user? Wow, I think we've hit a new low here.", + "Fake users don't get awards, baka!", + "Are you trying to funnel some extra credits through a false user again?" +]; + +exports.ecoedit = [ + "Trying to edit some credits on a fake account? Not on my watch, baka!", + "A fake account is a fake account. There is nothing else to do here." +]; + +exports.default = [ + "Whatever you are trying to find, it's not typed right or it doesn't exist.", + "Where is the user? I don't know but not any location where I can find it!", + "I couldn't find the user! Give me a better thing to search with, baka!", + "Another non-existant user? Really?", + "... There isn't a user here, baka!", + "You say user, I say doesn't exist. Baka!" +]; \ No newline at end of file diff --git a/commandRemover.js b/commandRemover.js deleted file mode 100644 index bc1b259..0000000 --- a/commandRemover.js +++ /dev/null @@ -1,11 +0,0 @@ -const fs = require("fs"); - -module.exports = function() { - var files = ["stats", "download", "info", "ping", "invite", "reboot", "help"]; - - for(var x = 0; x < files.length; x++) { - if (fs.existsSync("./node_modules/komada/src/commands/System/" + files[x] + ".js")) { - fs.unlinkSync("./node_modules/komada/src/commands/System/" + files[x] + ".js"); - } - } -}; \ No newline at end of file diff --git a/commands/General/greet.js b/commands/General/greet.js index 75bd493..c5cf1c0 100644 --- a/commands/General/greet.js +++ b/commands/General/greet.js @@ -1,9 +1,10 @@ exports.run = async (client, msg, user) => { - var data = await client.funcs.userSearch(client, msg, {user: [user], name: this.help.name}); - if (data.valid === false) { return; } - if (data.user[0].id === client.user.id) { return msg.channel.send(`Why would you try and make me greet myself, ${msg.author.username}? I'm not that lonely!`); } + var data = await client.funcs.userSearch(client, msg, user); + if (data === false) { return; } + if (data.id === client.user.id) { return msg.channel.send(client.speech(msg, ["greet", "me"]).replace("-user", msg.author.username)); } - msg.channel.send(`Hello ${data.user[0].prefered}! `); + var name = data.nickname || data.user.username; + msg.channel.send(client.speech(msg, ["greet", "success"]).replace("-user", name)); }; exports.conf = { diff --git a/commands/General/help.js b/commands/General/help.js index ecbddc7..0866266 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -47,7 +47,7 @@ exports.run = async (client, msg, [cmd, mod]) => { .setTitle(cmd.help.name + alias) .setDescription(cmd.help.description) .addField("Usage:", `\`${prefix + cmd.help.name + " " + usageAct}\``) - .addField("Permission level:", client.ownerSettings.get("permLevel").general[cmd.conf.permLevel]); + .addField("Permission level:", client.ownerSetting.get("permLevel").general[cmd.conf.permLevel]); if (cmd.help.extendedHelp) { embed.addField("Extended Help:", cmd.help.extendedHelp); } msg.send({embed}); } diff --git a/commands/General/info.js b/commands/General/info.js index 99a9efe..6f9d282 100644 --- a/commands/General/info.js +++ b/commands/General/info.js @@ -1,5 +1,5 @@ exports.run = async (client, message, [kind, search]) => { - let guild = message.channel.guild; + let guild = message.guild; let msg = (message.content.startsWith("<")) ? message.content.slice(client.user.id.length + 4).split(" ") : message.content.slice(2).split(" "); var x = (msg[0] === "info") ? 1 : 0; @@ -11,37 +11,37 @@ exports.run = async (client, message, [kind, search]) => { switch (kind) { case "user": - var data = await client.funcs.userSearch(client, message, {user: [user], name: this.help.name}); - if (data.valid === false) { return; } - user = await Promise.resolve(client.users.fetch(data.user[0].id)); + user = await client.funcs.userSearch(client, message, user); + if (user === false) { return; } + + var userC = client.users.get(user.id); const statusList = { - online: "Online", - idle: "Idle", - dnd: "Do not Disturb" + online: "online", + idle: "idle", + dnd: "on do not disturb mode" }; - var Status = statusList[user.presence.status] || "Offline"; - var botUser = user.bot ? "True": "False"; - var activity = user.presence.activity !== null ? " - " + user.presence.activity.name: " "; + var Status = statusList[user.presence.status] || "offline"; + var activity = user.presence.activity !== null ? " while playing " + user.presence.activity.name: " "; - embed.setThumbnail(user.displayAvatarURL()) - .setAuthor("User: " + user.tag) - .setDescription("ID: " + user.id) - .addField("Created:", user.createdAt.toLocaleString(), true) - .addField("Joined:", guild.members.get(user.id).joinedAt.toLocaleString(), true) - .addField("Bot user:", botUser, true) - .addField("Status:", Status + activity, true); break; + embed.setThumbnail(userC.displayAvatarURL()) + .setAuthor("User: " + user.user.tag + " | ID: " + user.id) + .setDescription("Currently " + Status + activity) + .addField("Created:", userC.createdAt.toLocaleString(), true) + .addField("Joined:", user.joinedAt.toLocaleString(), true) + .addField("Bot user:", user.bot ? "True": "False", true); break; case "role": + var role; guild.roles.forEach(element => { if (element.name.toLowerCase() === user.toLowerCase()) { role = element; } }); - if (!role) { return message.channel.send("Looks like I can't find the role. Be sure it is spelled correctly."); } + if (!role) { return message.channel.send(client.speech(message, ["info", "role"])); } embed.addField("Role:", `${role.name} - ${role.id}`) .addField("Position:", role.position, true) .addField("Hex Colour:", role.hexColor, true) .addField("Users:", role.members.size, true); break; case "server": - if (user) { return message.reply("You can't ask information about a server with additional stuff!"); } + if (user) { return message.reply(client.speech(message, ["info", "server"])); } embed.setThumbnail(guild.iconURL()) .addField("Region:", guild.region, true) @@ -49,11 +49,10 @@ exports.run = async (client, message, [kind, search]) => { .addField("Owner:", `${guild.owner.user.tag} - ${guild.owner.id}`) .addField("Members:", `${guild.memberCount - guild.members.filter(m => m.user.bot).size} (${guild.members.filter(m => m.user.bot).size} bots)`, true) .addField("Roles:", guild.roles.size, true); break; - default: return message.channel.send("You didn't give a correct search term. Do either server, user, or role."); + default: return message.channel.send(client.speech(message, ["info", "noTerm"])); }; - var colour = (kind === "role") ? role.hexColor : 0x04d5fd; - embed.setColor(colour); + embed.setColor((kind === "role") ? role.hexColor : 0x04d5fd); message.channel.send({embed}); }; diff --git a/commands/Music/join.js b/commands/Music/join.js index ba606c7..34f9c27 100644 --- a/commands/Music/join.js +++ b/commands/Music/join.js @@ -1,13 +1,25 @@ -exports.run = async (client, message) => { - const voiceChannel = message.member.voiceChannel; - if (!message.member.voiceChannel) { return message.channel.send("You are not in a voice channel, baka! Don't force me to be lonely!"); } +exports.run = async (client, msg) => { + var check = client.funcs.musicCheck(msg, "join"); + if (check === false) { return; } + var vcID = msg.guild.channels.get(msg.member.voice.channelID); - const permissions = message.member.voiceChannel.permissionsFor(message.guild.me); - if (permissions.has("CONNECT") === false) { return message.channel.send(":x: I do not have enough permissions to connect to your voice channel. I am missing the Connect permission."); } - if (permissions.has("SPEAK") === false) { return message.channel.send("Wow. Invite me to play music for you, yet I can't speak in the channel. You're more heartless than my owner. Give me the channel permission to speak and then come back and invite me."); } + const permissions = vcID.permissionsFor(msg.guild.me); + if (permissions.has("CONNECT") === false) { return msg.channel.send(client.speech(msg, ["join", "noConnect"])); } + if (permissions.has("SPEAK") === false) { return msg.channel.send(client.speech(msg, ["join", "noSpeak"])); } - message.member.voiceChannel.join(); - return message.channel.send(`Now tuned into: ${message.member.voiceChannel}. Ready and awaiting orders!`); + var vcSettings = { + channel: vcID, + queue: [], + volume: 100, + state: "STOP", + connection: null, + dispatcher: null + }; + + vcID.join().then(connection => { vcSettings.connection = connection; }); + client.music.set(msg.guild.id, vcSettings); + + msg.channel.send(client.speech(msg, ["join", "success"]).replace("-channel", vcID.name)); }; exports.conf = { @@ -15,13 +27,12 @@ exports.conf = { runIn: ["text"], aliases: [], permLevel: 0, - botPerms: [], - requiredFuncs: [], + botPerms: [] }; exports.help = { name: "join", - description: "Joins the VC that you are in.", - usage: "", - usageDelim: "", + description: "Joins the VC that you are in.", usage: "" }; + +exports.init = (client) => { client.music = new client.methods.Collection(); }; \ No newline at end of file diff --git a/commands/Music/leave.js b/commands/Music/leave.js index 0c9f586..5ebde19 100644 --- a/commands/Music/leave.js +++ b/commands/Music/leave.js @@ -1,23 +1,21 @@ -exports.run = async (client, message) => { - if (!message.member.voiceChannel) { return message.channel.send("You are not in my voice channel! Come in and tell me face to face!"); } +exports.run = async (client, msg) => { + var vcID = client.funcs.musicCheck(msg); + if (vcID === false) { return; } + + vcID.channel.leave(); + client.music.delete(msg.guild.id); + msg.channel.send(client.speech(msg, ["leave"]).replace("-channel", vcID.channel.name)); +}; - message.member.voiceChannel.leave(); - return message.channel.send(`I have left ${message.member.voiceChannel}.`); - }; +exports.conf = { + enabled: true, + runIn: ["text"], + aliases: [], + permLevel: 0, + botPerms: [] +}; - exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: [], - }; - - exports.help = { - name: "leave", - description: "Leaves the VC that you are in.", - usage: "", - usageDelim: "", - }; - \ No newline at end of file +exports.help = { + name: "leave", + description: "Leaves the VC that you are in.", usage: "" +}; \ No newline at end of file diff --git a/commands/Music/nowplaying.js b/commands/Music/nowplaying.js index 9061c6d..e488d43 100644 --- a/commands/Music/nowplaying.js +++ b/commands/Music/nowplaying.js @@ -1,24 +1,24 @@ const moment = require("moment"); require("moment-duration-format"); -exports.run = async (client, message) => { - if (!message.guild.voiceConnection) { return message.channel.send("How can I be playing music when I'm not in a voice channel, baka!"); } - - const handler = client.queue.get(message.guild.id); - if (!handler || handler.playing === false) { return message.channel.send(`I'm not playing any music right now! Add some using ${message.guild.settings.prefix}`); } +exports.run = async (client, msg) => { + const handler = client.music.get(msg.guild.id); + if (!handler) { throw client.speech(msg, ["func-music", "general", "noQueue"]); } + if (handler.queue.length < 1) { return msg.channel.send(client.speech(msg, ["nowplaying", "noQueue"])); } + if (handler.state !== "PLAY") { return msg.channel.send(client.speech(msg, ["nowplaying", "notPlay"])); } - let song = handler.songs[0]; + let song = handler.queue[0]; const embed = new client.methods.Embed() .setColor(0x04d5fd) .setTimestamp() - .setTitle(`šŸ“» __${message.guild.name}'s Music Stream__`) + .setTitle(`šŸ“» __${msg.guild.name}'s Music Stream__`) .setDescription("*Streaming all your requests from the fabulous library of Youtube.*") .setThumbnail(song.image) .addField("**Title:**", `[${song.title}](${song.url})`) .addField("**Requested by:**", song.requester, true) - .addField("**Time Left:**", `${moment.duration((handler.songs[0].seconds * 1000) - message.guild.voiceConnection.dispatcher.time).format("h:mm:ss", { trim: false })} out of ` + moment.duration(handler.songs[0].seconds * 1000).format("h:mm:ss", { trim: false }), true); + .addField("**Time Left:**", `${moment.duration((song.seconds * 1000) - handler.dispatcher.count).format("h:mm:ss", { trim: false })} out of ` + moment.duration(song.seconds * 1000).format("h:mm:ss", { trim: false }), true); - message.channel.send({embed}); + msg.channel.send({embed}); }; exports.conf = { @@ -26,7 +26,7 @@ exports.conf = { runIn: ["text"], aliases: ["np", "whatsplaying", "whatsplayingfam"], permLevel: 0, - botPerms: [] + botPerms: ["EMBED_LINKS"] }; exports.help = { diff --git a/commands/Music/pause.js b/commands/Music/pause.js index 31c2db6..ab12d88 100644 --- a/commands/Music/pause.js +++ b/commands/Music/pause.js @@ -1,9 +1,11 @@ exports.run = async (client, msg) => { - if (!msg.guild.voiceConnection) { throw `I am not connected in a voice channel, please add some songs to the mix first with ${msg.guild.settings.prefix}queueadd`; } - if (msg.guild.voiceConnection.dispatcher.paused) { return msg.send("The stream is already paused, baka!"); } + var handler = client.funcs.musicCheck(msg); + if (handler === false) { return; } + if (handler.state === "PAUSE") { return msg.send(client.speech(msg, ["pause", "paused"])); } - msg.guild.voiceConnection.dispatcher.pause(); - return msg.send("āø The mix is now paused."); + handler.state = "PAUSE"; + handler.dispatcher.pause(); + msg.send(client.speech(msg, ["pause", "success"])); }; exports.conf = { @@ -11,14 +13,10 @@ exports.conf = { runIn: ["text"], aliases: [], permLevel: 0, - botPerms: [], - requiredFuncs: [], + botPerms: [] }; exports.help = { name: "pause", - description: "Pauses the playlist.", - usage: "", - usageDelim: "", - extendedHelp: "", + description: "Pauses the playlist.", usage: "" }; diff --git a/commands/Music/play.js b/commands/Music/play.js index b3ca44f..086b6b4 100644 --- a/commands/Music/play.js +++ b/commands/Music/play.js @@ -1,42 +1,49 @@ const yt = require("ytdl-core"); exports.run = async (client, msg) => { - const handler = client.queue.get(msg.guild.id); - if (!handler) { throw `Add some songs to the mix first with ${msg.guild.settings.prefix}queueadd [Youtube URL]`; } - - if (!msg.guild.voiceConnection) { - await client.commands.get("join").run(client, msg); - if (!msg.guild.voiceConnection) { return; } - return this.run(client, msg); + const handler = client.music.get(msg.guild.id); + + if (!handler) { + if(msg.member.voice.channelID) { + await client.commands.get("join").run(client, msg); + if(!client.music.get(msg.guild.id)) { return; } + return this.run(client, msg); + } + + throw client.speech(msg, ["func-music", "general", "userVC"]); } - if (handler.playing) { - if (msg.member.voiceConnection !== msg.guild.voiceConnection) { throw "I'm sorry. I'm already playing in another voice channel on your guild!"; } + if (handler.state === "PLAY") { + if (msg.member.voice.channelID !== handler.channel.id) { throw client.speech(msg, ["func-music", "general", "mismatch"]); } - throw "I'm already playing in your channel."; - } else { handler.playing = true; } + throw client.speech(msg, ["play", "alreadyPlay"]); + } else if (handler.state === "PAUSE") { return client.commands.get("resume").run(client, msg); } + else { handler.state = "PLAY"; } + + if(handler.queue.length === 0) { return msg.channel.send(client.speech(msg, ["play", "noQueue"])); } (function play(song) { if (song === undefined) { - return msg.channel.send("All your selected tunes have been played. I'll be taking my leave now.").then(() => { - handler.playing = false; - return msg.member.voiceChannel.leave(); + return msg.channel.send(client.speech(msg, ["play", "allDone"])).then(() => { + handler.state = "STOP"; }); } - msg.channel.send(`šŸ“» Playing ${song.requester}'s request: **${song.title}**`).catch(err => client.emit("log", err, "error")); + msg.channel.send(client.speech(msg, ["play", "nextSong"]) + .replace("-request", song.requester) + .replace("-title", song.title)); - return msg.guild.voiceConnection.playStream(yt(song.url, { audioonly: true }), { passes: 2 }) + return handler.dispatcher = handler.connection.play(yt(song.url, { audioonly: true }), { passes: 2 }) .on("end", () => { setTimeout(() => { - handler.songs.shift(); - play(handler.songs[0]); + handler.queue.shift(); + play(handler.queue[0]); }, 100); }) .on("error", err => msg.channel.send(`error: ${err}`).then(() => { - handler.songs.shift(); - play(handler.songs[0]); + handler.queue.shift(); + play(handler.queue[0]); })); - }(handler.songs[0])); + }(handler.queue[0])); return null; }; @@ -44,13 +51,12 @@ exports.run = async (client, msg) => { exports.conf = { enabled: true, runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] + aliases: [], permLevel: 0, + botPerms: ["CONNECT", "SPEAK"] }; exports.help = { name: "play", description: "Plays the queue of music.", usage: "[songURL:str]" -}; +}; \ No newline at end of file diff --git a/commands/Music/queue.js b/commands/Music/queue.js index dcf4a8c..4fdea8e 100644 --- a/commands/Music/queue.js +++ b/commands/Music/queue.js @@ -1,31 +1,27 @@ const moment = require("moment"); require("moment-duration-format"); -exports.run = (client, message, page) => { - const handler = client.queue.get(message.guild.id); - if (!handler) { throw `Hmm... I've tried to find your list of songs but it doesn't look like you have a queue. Better add some by ${message.guild.settings.prefix}add.`; } +exports.run = (client, msg, page) => { + const handler = client.music.get(msg.guild.id); + if (!handler) { throw client.speech(msg, ["func-music", "general", "noQueue"]); } - var count; - if (page.length < 1 || page === 1) { page = 1; count = 0; } - else { count = (10 * (page - 1)); } + if (page.length < 1 || page === 1) { page = 1; var count = 0; } + else { var count = (10 * (page - 1)); } - if (handler.songs.length < count) { return message.channel.send(`I can't show you that page for its page number is greater than my queue pages. There are currently ${Math.ceil(handler.songs.length / 10)}`); } - - if (handler.songs.length === 1) { var SongMessage = "song"; } - else { var SongMessage = "songs"; } + if (handler.queue.length < count) { return msg.channel.send(client.speech(msg, ["queue"]).replace("-pgs", Math.ceil(handler.queue.length / 10))); } const embed = new client.methods.Embed() .setColor(0x04d5fd) - .setTitle(`šŸ“» __${message.guild.name}'s Stream of Music__`) - .setDescription(`Currently streaming ${handler.songs.length} ${SongMessage}.`) - .setThumbnail(message.guild.iconURL()) - .setFooter(`Page: ${page} of ${Math.ceil(handler.songs.length / 10)}`); + .setTitle(`šŸ“» __${msg.guild.name}'s Stream of Music__`) + .setDescription(`Currently streaming ${handler.queue.length} ${(handler.queue.length === 1) ? "song" : "songs"}.`) + .setThumbnail(msg.guild.iconURL()) + .setFooter(`Page: ${page} of ` + Math.ceil(handler.queue.length / 10)); - for (let i = count; i < Math.min(handler.songs.length, (count + 10)); i++) { - embed.addField(`${i + 1}) ${handler.songs[i].title}`, `Requested by: ${handler.songs[i].requester} - Run time: ${moment.duration(handler.songs[0].seconds * 1000).format("h:mm:ss", { trim: false })}`); + for (let i = count; i < Math.min(handler.queue.length, (count + 10)); i++) { + embed.addField(`${i + 1}) ` + handler.queue[i].title, `Requested by: ${handler.queue[i].requester} - Run time: ` + moment.duration(handler.queue[i].seconds * 1000).format("h:mm:ss", { trim: false })); } - return message.channel.send({embed}); + msg.send(embed); //There is an error here. No idea why but it doesn't affect anything so I'm leaving it alone. }; exports.conf = { @@ -33,14 +29,11 @@ exports.conf = { runIn: ["text"], aliases: [], permLevel: 0, - botPerms: [], - requiredFuncs: [], + botPerms: ["EMBED_LINKS"] }; exports.help = { name: "queue", description: "Displays the music queue.", - usage: "[page:int]", - usageDelim: "", - extendedHelp: "", -}; + usage: "[page:int]", humanUse: "[Page number]" +}; \ No newline at end of file diff --git a/commands/Music/queueadd.js b/commands/Music/queueadd.js index 1a3d006..4b852ee 100644 --- a/commands/Music/queueadd.js +++ b/commands/Music/queueadd.js @@ -1,26 +1,41 @@ const yt = require("ytdl-core"); +const ytPlay = require("youtube-playlist"); const getInfoAsync = require("util").promisify(yt.getInfo); -const url = require("url"); exports.run = async (client, msg, [song]) => { - const YTRegExp = new RegExp(/(?:v.|d\/|e\/)([\w-_]{11})/); - var songID = url.parse(song).path.split("/")[1]; - var id = songID.match(YTRegExp); - - if (id === null) { throw "You must provide a valid YouTube URL."; } - const info = await getInfoAsync(`https://youtu.be/${id[1]}`); - - if (client.queue.has(msg.guild.id) === false) { client.queue.set(msg.guild.id, { playing: false, songs: [], }); } - - client.queue.get(msg.guild.id).songs.push({ - url: song, - title: info.title, - seconds: info.length_seconds, - requester: msg.author.username, - image: info.thumbnail_url - }); - - msg.send(`šŸŽµ Added **${info.title}** to the queue šŸŽ¶`); + var handler = client.funcs.musicCheck(msg); + if (handler === false) { return; } + var id = []; + + if (song.match(/(playlist\?list=\S{30,34})/)) { + msg.send(client.speech(msg, ["queueadd", "listDetect"])); + list = await Promise.resolve(ytPlay(song, "id")); + + for(var x = 0; x < list.data.playlist.length; x++) { + id.push(list.data.playlist[x]); + } + } else if (song.match(/(?:v=)(\S{11}$)/)) { + id.push(song.split(".com/")[1].match(/(?:v=)(\S{11}$)/)[1]); + } else { throw client.speech(msg, ["queueadd", "noURL"]); } + + for(var x = 0; x < id.length; x++) { + try { + info = await getInfoAsync("https://youtu.be/" + id[x]); + + handler.queue.push({ + url: "https://youtu.be/" + id[x], + title: info.title, + seconds: info.length_seconds, + requester: msg.author.tag, + image: info.thumbnail_url + }); + } catch(err) { + msg.send("Whoops! Looks like I can't access this video. "); + } + } + + if (id.length == 1) { msg.send(client.speech(msg, ["queueadd", "success"]).replace("-title", info.title)); } + else { msg.send(client.speech(msg, ["queueadd", "multi"]).replace("-number", id.length)); } }; exports.conf = { @@ -33,8 +48,7 @@ exports.conf = { exports.help = { name: "queueadd", - description: "Adds a song the the queue.", - usage: "[song:str]", -}; - -exports.init = (client) => { client.queue = new client.methods.Collection(); }; + description: "Adds a song or a playlist to the queue.", + usage: "[song:str]", humanUse: "[Song/Playlist URL]", + extendedHelp: "Note: Only Youtube song and Youtube playlist URLs only. Youtube mixes do not count." +}; \ No newline at end of file diff --git a/commands/Music/remove.js b/commands/Music/remove.js index 14d87f3..7174ffb 100644 --- a/commands/Music/remove.js +++ b/commands/Music/remove.js @@ -1,16 +1,12 @@ -exports.run = async (client, message, [songID]) => { - const voiceChannel = message.member.voiceChannel; - if (!message.member.voiceChannel) { return message.channel.send("You are not in the voice channel, baka! You can't spoil someone's queue behind the scenes!"); } - - const handler = client.queue.get(message.guild.id); - if (!handler) { throw `Hmm... I've tried to find your list of songs but it doesn't look like you have a queue. Better add some by ${message.guild.settings.prefix}add.`; } - - if (Number.isInteger(songID) === false) { return message.channel.send("I only have songs queued in whole numbers. Come back with a whole number, will you?"); } +exports.run = async (client, msg, [songID]) => { + var handler = client.funcs.musicCheck(msg); + if (handler === false) { return; } + if (Number.isInteger(songID) === false) { return msg.channel.send(client.speech(msg, ["remove", "noInt"])); } songID = songID - 1; - var title = handler.songs[songID].title; - handler.songs.splice(songID, 1); - message.channel.send(`${title} has been removed from the queue.`); + var title = handler.queue[songID].title; + handler.queue.splice(songID, 1); + msg.channel.send(client.speech(msg, ["remove", "success"]).replace("-title", title)); }; exports.conf = { @@ -24,6 +20,5 @@ exports.conf = { exports.help = { name: "remove", description: "Removes a song from the queue.", - usage: "[songID:int]", -}; - \ No newline at end of file + usage: "[songID:int]", humanUse: "[Song number]" +}; \ No newline at end of file diff --git a/commands/Music/resume.js b/commands/Music/resume.js index 1c9c84d..1bbc144 100644 --- a/commands/Music/resume.js +++ b/commands/Music/resume.js @@ -1,9 +1,11 @@ exports.run = async (client, msg) => { - if (!msg.guild.voiceConnection) { throw "I am not connected in a voice channel, please add some songs to the mix first!"; } - if (msg.guild.voiceConnection.dispatcher.paused === false) { return msg.send("The stream is not paused, baka!"); } + var handler = client.funcs.musicCheck(msg); + if (handler === false) { return; } + if (handler.state != "PAUSE") { return msg.channel.send(client.speech(msg, ["resume", "noPause"])); } - msg.guild.voiceConnection.dispatcher.resume(); - msg.send("ā–¶ Now resuming your tunes. Keep partying!"); + handler.dispatcher.resume(); + handler.state = "PLAY"; + msg.channel.send(client.speech(msg, ["resume", "success"])); }; exports.conf = { @@ -16,6 +18,5 @@ exports.conf = { exports.help = { name: "resume", - description: "Resumes the playlist.", - usage: "" + description: "Resumes the playlist.", usage: "" }; diff --git a/commands/Music/skip.js b/commands/Music/skip.js index fcbf8f1..271612f 100644 --- a/commands/Music/skip.js +++ b/commands/Music/skip.js @@ -1,9 +1,9 @@ exports.run = async (client, msg) => { - if (!msg.guild.voiceConnection) { throw "I am not connected in a voice channel, please add some songs to the mix first!"; } - if (msg.member.voiceConnection !== msg.guild.voiceConnection) { throw "You can't skip a song if you are not listening to it!"; } + var handler = client.funcs.musicCheck(msg); + if (handler === false) { return; } - msg.guild.voiceConnection.dispatcher.end(); - msg.send("ā­ Skipped the current song."); + handler.dispatcher.end(); + msg.channel.send(client.speech(msg, ["skip"])); }; exports.conf = { @@ -16,6 +16,5 @@ exports.conf = { exports.help = { name: "skip", - description: "Skips the current song.", - usage: "" + description: "Skips the current song.", usage: "" }; diff --git a/commands/Music/volume.js b/commands/Music/volume.js index e38f498..85a0f8d 100644 --- a/commands/Music/volume.js +++ b/commands/Music/volume.js @@ -1,18 +1,17 @@ exports.run = async (client, msg, [volume]) => { - if (!msg.guild.voiceConnection) { throw "I am not connected in a voice channel, please add some songs to the mix first!"; } - const handler = client.queue.get(msg.guild.id); - if (!handler || handler.playing === false) { throw "Kind of hard to adjust the volume if I am not playing music."; } + var handler = client.funcs.musicCheck(msg); + if (handler === false) { return; } - const dispatcher = msg.guild.voiceConnection.dispatcher; + if (!volume) { return msg.send(client.speech(msg, ["volume", "noArgs"]).replace("-vol", Math.round(dispatcher.volume * 50))); } + if (volume === 0) { return msg.send(client.speech(msg, ["volume", "zero"])); } + if (volume > 100) { return msg.send(client.speech(msg, ["volume", "overHun"])); } + if (handler.playing !== "PLAY") { return msg.send(client.speech(msg, ["volume", "notPlay"])); } - if (!volume) { return msg.send(`šŸ“¢ Volume: ${Math.round(dispatcher.volume * 50)}%`); } - if (volume === 0) { return msg.send("You might as well mute me if you don't want any noise."); } - if (volume > 100) { return msg.send("100% is the max. You jsut can't have 110% with this bot."); } - - var emote = (volume < (dispatcher.volume * 50)) ? ["šŸ”‰", "Decreasing"] : ["šŸ”Š", "Increasing"]; + const dispatcher = handler.dispatcher; + var emote = (volume < (dispatcher.volume * 50)) ? ["šŸ”‰ Decreasing"] : ["šŸ”Š Increasing"]; dispatcher.setVolume(Math.min(volume) / 50, 2); - msg.send(`${emote[0]} ${emote[1]} the volume! Volume: ${Math.round(dispatcher.volume * 50)}%`); + msg.send(client.speech(msg, ["volume", "success"]).replace("-action", emote).replace("-vol", Math.round(dispatcher.volume * 50))); }; exports.conf = { @@ -26,5 +25,5 @@ exports.conf = { exports.help = { name: "volume", description: "Manage the volume for current song.", - usage: "[volume:int]" -}; + usage: "[volume:int]", humanUse: "[Volume percentage]" +}; \ No newline at end of file diff --git a/commands/System/about.js b/commands/System/about.js index 3db481b..c1b403a 100644 --- a/commands/System/about.js +++ b/commands/System/about.js @@ -4,7 +4,6 @@ require("moment-duration-format"); exports.run = async (client, msg) => { const prefix = msg.guildSettings.prefix || client.config.prefix; const duration = moment.duration(client.uptime).format(" D [days], H [hours], m [minutes and] s [seconds]"); - const birthday = dateMaker(client.user.createdAt); const embed = new client.methods.Embed() .setColor(0x37FDFC) @@ -13,7 +12,7 @@ exports.run = async (client, msg) => { \nI am a very helpful and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written in Komada, a Discord.js framework. \n**Stats:** I have been online, helping out, for ${duration} using ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB of memory. ${client.users.size} users across ${client.guilds.size} guilds with ${client.channels.size.toLocaleString()} channels depend on my functions to be as reliable as possible! \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 the ${birthday} by Butterstroke#7150.`) + \n**Creation:** I was created on the ${dateMaker(client.user.createdAt)} by Butterstroke#7150.`) .setThumbnail(client.user.displayAvatarURL()) .setFooter("Running on Margarine " + client.ownerSetting.get("build").version + " | Released on: " + client.ownerSetting.get("build").releaseDate); msg.channel.send({embed}); @@ -34,16 +33,7 @@ exports.help = { function dateMaker(date) { var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; - var ed = ["st", "nd", "rd", "th"]; - var d = date.toLocaleString().split(" ")[0].split("-"); - if (d[2][d[2].length - 1] === "1") { d[2] += ed[0]; } - else if (d[2][d[2].length - 1] === "2") { d[2] += ed[1]; } - else if (d[2][d[2].length - 1] === "3") { d[2] += ed[2]; } - else { d[2] += ed[3]; } - - d = d[2] + " " + months[d[1]] + ", " + d[0]; - - return d; + return d[2] + " " + months[d[1]] + ", " + d[0]; }; \ No newline at end of file diff --git a/commands/System/exit.js b/commands/System/exit.js index e61d2f2..c819cc0 100644 --- a/commands/System/exit.js +++ b/commands/System/exit.js @@ -14,6 +14,5 @@ exports.conf = { exports.help = { name: "exit", - description: "Shuts down the bot.", - usage: "" + description: "Shuts down the bot.", usage: "" }; \ No newline at end of file diff --git a/commands/System/ping.js b/commands/System/ping.js index 7535dd8..5034b6a 100644 --- a/commands/System/ping.js +++ b/commands/System/ping.js @@ -13,6 +13,5 @@ exports.conf = { exports.help = { name: "ping", - description: "Ping/Pong command.", - usage: "" + description: "Ping/Pong command.", usage: "" }; \ No newline at end of file diff --git a/functions/musicCheck.js b/functions/musicCheck.js index 7984769..4b8f473 100644 --- a/functions/musicCheck.js +++ b/functions/musicCheck.js @@ -4,7 +4,7 @@ module.exports = (msg, tag) => { if (!msg.member.voice.channelID) { result = false; speech = client.speech(msg, ["func-music", "general", "userVC"]); - } else if (tag != "join") { + } else if (tag !== "join") { if (!client.music.get(msg.guild.id)) { result = false; speech = client.speech(msg, ["func-music", "general", "noQueue"]); diff --git a/functions/transaction.js b/functions/transaction.js new file mode 100644 index 0000000..daf3d41 --- /dev/null +++ b/functions/transaction.js @@ -0,0 +1,37 @@ +module.exports = (msg, amount, user, callback) => { + const client = msg.client; + const sqlite3 = require("sqlite3").verbose(); + let db = new sqlite3.Database(client.database.general); + + if (!user) { user = msg.author; } + + var check; + if (!amount) { check = "none"; } + else if (amount === 0) { check = "zero"; } + else if (Number.isInteger(amount) === false) { check = "noInt"; } + + if (check) { + msg.channel.send(client.speech(msg, ["func-transaction", "validate", check])); + return false; + } + + db.get(`SELECT credits FROM users WHERE userId = "${user.id}"`, [], (err, row) => { + let text; + if (err) { + console.log(err); + text = "err"; + } else if (!row) { text = "noRow"; } + else if (row.credits < credits) { text = "lessCredit"; } + + if (text) { msg.channel.send(client.speech(msg, ["func-transaction", "dbCheck", test])); return false; } + + db.run(`UPDATE users SET credits ="${amount + row.credits}" WHERE userId = "${user.id}"`); + callback([true, row.credits, (row.credits + amount)]); + }); +}; + +exports.help = { + name: "transaction", + type: "functions", + description: "Checks and does any credit transactions." +}; \ No newline at end of file diff --git a/functions/transactions.js b/functions/transactions.js deleted file mode 100644 index c77fd89..0000000 --- a/functions/transactions.js +++ /dev/null @@ -1,53 +0,0 @@ -const sqlite3 = require("sqlite3").verbose(); -let db = new sqlite3.Database("./assets/data/score.sqlite"); -const speech = require("../assets/speech.json"); - -module.exports = async (msg, args, callback) => { - var user = args.user || msg.author; - - var tags = args.tags ? args.tags[0] : "credit"; - var checker = await msg.client.funcs.validator({credit: args.credit[0], tags: tags}); - if (checker.valid === false) { - msg.channel.send(checker.message); - callback({valid: false}); - } else { - this.dbChecker({user: user, credits: args.credit[0]}, function(data) { - if (data.valid === false) { - msg.channel.send(data.credits); - callback({valid: false}); - } else if (args.credit !== undefined) { - if (args.credit[1] === "+") { var amount = args.credit[0] + args.credit[2]; } - else if (args.credit[1] === "-") { var amount = args.credit[0] - args.credit[2]; } - else if (args.credit[1] === "*") { - var amount = args.credit[0] * args.credit[2]; - amount = (amount < 0) ? amount : amount - args.credit[0]; - } - - db.run(`UPDATE scores SET credits = "${Number(amount) + data.credits}" WHERE userId = "${user.id}"`); - - callback({valid: true, earnings: amount}); - } else { callback(data); } - }); - } -}; - -exports.conf = { requiredModules: [] }; - -exports.help = { - name: "transactions", - type: "functions", - description: "Checks and does any credit transaction.", -}; - -exports.dbChecker = (args, callback) => { - db.get(`SELECT credits FROM scores WHERE userId = "${args.user.id}"`, [], (err, row) => { - let text; - if (err) { console.log(err); text === speech["dbError"][Math.floor(Math.random() * speech["dbError"].length)]; } - else if (!row) { text === speech["noRow"][Math.floor(Math.random() * speech["noRow"].length)]; } - else if (row.credits < args.credits) { text === speech["lessCredit"][Math.floor(Math.random() * speech["lessCredit"].length)]; } - else { text = row.credits; } - - if (Number(text) !== text) { callback({valid: false, credits: text}); } - else { callback({valid: true, credits: text }); } - }); -}; \ No newline at end of file diff --git a/functions/userSearch.js b/functions/userSearch.js index 901d2c0..807906e 100644 --- a/functions/userSearch.js +++ b/functions/userSearch.js @@ -10,7 +10,7 @@ module.exports = async (client, msg, user, tags) => { user = item[0][1].toString().slice(2, -1); } else if (msg.mentions.users.size > 0) { if (msg.content.startsWith("<") === false) { user = msg.mentions.users.first().id; } - else if (msg.content.indexOf("<") != msg.content.lastIndexOf("<")) { user = Array.from(msg.mentions.users)[0][1].toString().slice(2, -1); } + else if (msg.content.indexOf("<") !== msg.content.lastIndexOf("<")) { user = Array.from(msg.mentions.users)[0][1].toString().slice(2, -1); } } else if (/^(\d{17,21})$/.test(user)) { user = await Promise.resolve(client.users.fetch(user)); @@ -35,7 +35,7 @@ module.exports = async (client, msg, user, tags) => { if (user === null) { msg.channel.send(client.speech(msg, ["func-userSearch", "default"])); return false; - } else if (user.user.bot == true && tags.includes("bot")) { + } else if (user.user.bot === true && tags.includes("bot")) { msg.channel.send(client.speech(msg, ["func-userSearch", tags[0]])); return false; } else { return user; } diff --git a/functions/validator.js b/functions/validator.js deleted file mode 100644 index 0a2c5e7..0000000 --- a/functions/validator.js +++ /dev/null @@ -1,29 +0,0 @@ -const speech = require("../assets/speech.json")["intChecker"]; - -module.exports = async (args) => { - var credit = args.credit; - var tag = args.tags ? args.tags : ["none"]; - var text = []; - - if (!credit || credit === undefined) { text.push("none"); } - else if (credit < 0) { text.push("negative"); } - else if (credit === 0) { text.push("zero"); } - else if (Number.isInteger(credit) === false) { text.push("noInteger"); } - - if (args.tags.length === 4) { text.push("default"); } - else { text.push(args.tags); } - - if (!text[1]) { return {valid: true}; } - else { - text = speech[text[0]][text[1]][Math.floor(Math.random() * speech[text[0]][text[1]].length)]; - return {valid: false, message: text}; - } -}; - -exports.conf = { requiredModules: [] }; - -exports.help = { - name: "validator", - type: "functions", - description: "Validates any credit amount." -}; \ No newline at end of file diff --git a/index.js b/index.js index fec0bd0..0f899fb 100644 --- a/index.js +++ b/index.js @@ -1,42 +1,36 @@ const Komada = require("komada"); const Discord = require("discord.js"); const config = require("./assets/settings.json"); -const speech = require("./assets/speech.json"); const localization = require("./assets/localization.json"); -const remove = require("./commandRemover.js"); +const util = require("./utilities/utilExport.js"); -remove(); //Removes most default commands from the Komada directory so that there is absolutly no conflicts. - -const permStructure = new Komada.PermLevels() - .addLevel(0, false, () => true) - .addLevel(2, false, (client, msg) => { - if (!msg.guild || !msg.guild.settings.modRole) { return false; } - const modRole = msg.guild.roles.get(msg.guild.settings.modRole); - return modRole && msg.member.roles.has(modRole.id); - }) - .addLevel(3, false, (client, msg) => { - if (!msg.guild || !msg.guild.settings.adminRole) { return false; } - const adminRole = msg.guild.roles.get(msg.guild.settings.adminRole); - return adminRole && msg.member.roles.has(adminRole.id); - }) - .addLevel(4, false, (client, msg) => msg.guild && msg.author.id === msg.guild.owner.id) - .addLevel(9, false, (client, msg) => msg.author.id === config.secondary) - .addLevel(10, false, (client, msg) => msg.author === client.owner); +util.envCheck(); //Checks for the proper enviroment. const client = new Komada.Client({ ownerID: config.ownerID, prefix: config.prefix, clientOptions: { fetchAllMembers: false }, - cmdLogging: false + cmdLogging: false, + permStructure: new Komada.PermLevels() + .addLevel(0, false, () => true) + .addLevel(2, false, (client, msg) => { + if (!msg.guild || !msg.guild.settings.modRole) { return false; } + const modRole = msg.guild.roles.get(msg.guild.settings.modRole); + return modRole && msg.member.roles.has(modRole.id); + }) + .addLevel(3, false, (client, msg) => { + if (!msg.guild || !msg.guild.settings.adminRole) { return false; } + const adminRole = msg.guild.roles.get(msg.guild.settings.adminRole); + return adminRole && msg.member.roles.has(adminRole.id); + }) + .addLevel(4, false, (client, msg) => msg.guild && msg.author.id === msg.guild.owner.id) + .addLevel(9, false, (client, msg) => msg.author.id === config.secondary) + .addLevel(10, false, (client, msg) => msg.author === client.owner) }); -client.speech = function(keys, msg) { - if (!keys) { throw new Error("Keys missing in function call!"); } - var t = speech; - for (var x = 0; x < keys.length; x++) { t = t[keys[x]]; } - var text = t[Math.floor(Math.random() * t.length)]; var prefix = msg.guildSettings.prefix || config.prefix; - return text.replace("-prefix-", prefix); -}; +util.remove(client); //Removes most default commands from the Komada directory so that there is absolutly no conflicts. + +client.speech = util.speech; client.ownerSetting = new Discord.Collection(); var keys = Object.keys(config); diff --git a/utilities/speechHelper.js b/utilities/speechHelper.js new file mode 100644 index 0000000..749170d --- /dev/null +++ b/utilities/speechHelper.js @@ -0,0 +1,26 @@ +const fs = require("fs"); + +module.exports = function(msg, keys) { + if (!keys) { throw new Error("Keys missing in function call!"); } + + var name = keys[0]; + if (name.startsWith("func-")) { var category = name.slice(5); } + else { + var category = msg.client.commands.get(name).help.fullCategory; + category = category[category.length - 1].toLowerCase(); + } + + var PATH = msg.client.clientBaseDir + "\\assets\\speech\\" + msg.guildSettings.lang + "\\" + category + ".js"; + + if (fs.existsSync(PATH) == false) { + throw new Error("Localization file is missing.\nLanguage: " + msg.guildSettings.lang + "\nCategory: " + category + "\nCommand: " + name); + } + + var t = require(PATH); var n; + if (name.startsWith("func-") == false) { t = t[name]; n = 1; } + else { t = t[keys[1]]; n = 2; } + for (var x = n; x < keys.length; x++) { t = t[keys[x]]; } + var text = t[Math.floor(Math.random() * t.length)]; var prefix = msg.guildSettings.prefix || msg.client.config.prefix; + + return text.replace("-prefix", prefix); +}; \ No newline at end of file diff --git a/utilities/utilExport.js b/utilities/utilExport.js index 9d580db..f20dbd0 100644 --- a/utilities/utilExport.js +++ b/utilities/utilExport.js @@ -1,3 +1,3 @@ -//exports.speech = require("./speechHelper.js"); +exports.speech = require("./speechHelper.js"); exports.remove = require("./commandRemover.js"); exports.envCheck = require("./envCheck.js"); \ No newline at end of file From b226fb1db84b186c7df56a6028a219d2f1f4ac69 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Sun, 13 Jan 2019 03:35:04 -0400 Subject: [PATCH 18/38] Mod Update (Part 1) - Updated the modEmbed function - Fixed an issue with the defaultChannel function - Removed the leaderboard command --- commands/Economy/leaderboard.js | 59 ----------------------------- commands/Fun/Interactions/baka.js | 1 - commands/General/award.js | 37 +++++++++--------- commands/Mod/kick.js | 45 +++++++++++----------- functions/defaultChannel.js | 11 +++--- functions/modEmbed.js | 62 +++++++++++++++---------------- 6 files changed, 77 insertions(+), 138 deletions(-) delete mode 100644 commands/Economy/leaderboard.js diff --git a/commands/Economy/leaderboard.js b/commands/Economy/leaderboard.js deleted file mode 100644 index 189133a..0000000 --- a/commands/Economy/leaderboard.js +++ /dev/null @@ -1,59 +0,0 @@ -exports.run = async (client, message, [type, global]) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/score.sqlite"); - - const types = { - credits: "Credits", - rep: "Rep" - }; - - const Leaders = []; - - var name = global ? "Global Leaderboard" : message.guild.name + " Leaderboard"; - - const embed = new client.methods.Embed() - .setTimestamp() - .setFooter(name, message.guild.iconURL()) - .setColor(0x04d5fd); - - db.all(`SELECT ${type}, userID FROM scores ORDER BY ${types[type.toLowerCase()]} DESC`, [], (err, rows) => { - if (err) { return console.log(err); } - var x = 1; - rows.forEach((row) => { - if (global) { - var user = client.users.find("id", row.userID); - user = (user !== null) ? user.tag : "User abandoned me"; - } else { - var user = message.guild.members.find("id", `${row.userID}`); - user = (user !== null) ? user.user.tag : null; - } - - if (x < 10 && user !== null) { - if (type.toLowerCase() === "credits") { - Leaders.push(`${x}) ${user} - ${types[type.toLowerCase()]}: ${row.credits.toLocaleString()}\n`); - } if (type.toLowerCase() === "rep") { - Leaders.push(`${x}) ${user} - ${types[type.toLowerCase()]}: ${row.rep.toLocaleString()}\n`); - } - x++; - } else if (Leaders.length === 10) { return; } - }); - embed.setDescription(Leaders); - message.channel.send({embed}); - }); - db.close(); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["lb"], - permLevel: 0, - botPerms: [], -}; - -exports.help = { - name: "leaderboard", - description: "Check the guild or global leaderboards!", - usage: " [global]", - usageDelim: " ", -}; \ No newline at end of file diff --git a/commands/Fun/Interactions/baka.js b/commands/Fun/Interactions/baka.js index 7c81dbf..e23d391 100644 --- a/commands/Fun/Interactions/baka.js +++ b/commands/Fun/Interactions/baka.js @@ -1,6 +1,5 @@ exports.run = async (client, msg, [user]) => { var data = await client.funcs.userSearch(client, msg, {user: [user], name: this.help.name}); - if (data.valid !== false) { msg.channel.send("Baka " + data.user[0].prefered + "!"); } }; diff --git a/commands/General/award.js b/commands/General/award.js index 52bfd5d..717320e 100644 --- a/commands/General/award.js +++ b/commands/General/award.js @@ -1,8 +1,7 @@ -const settings = require("../../assets/settings.json")["owner"]; - exports.run = async (client, message, [user, type, ...text]) => { const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/score.sqlite"); + let db = new sqlite3.Database(client.database.general); + const settings = client.ownerSetting; const embed = new client.methods.Embed() .setColor(0x04d5fd) @@ -12,8 +11,7 @@ exports.run = async (client, message, [user, type, ...text]) => { if (!type) { return message.reply("BAKA! I need a type of an award!"); } if (!text) { return message.reply("Explain yourself on giving the award!"); } - var data = await client.funcs.userSearch(message, {user: [user], tags:["bot"], name: this.help.name}); - + var data = await client.funcs.userSearch(client, message, {user: [user], tags:["bot"], name: this.help.name}); if (data.valid === false) { return; } db.get(`SELECT credits FROM scores WHERE userId = "${data.user[0].id}"`, [], (err, row) => { @@ -36,30 +34,32 @@ exports.run = async (client, message, [user, type, ...text]) => { }); }; - embed.setTitle(":tada: Award Notification! :tada:") - .addField(`To ${data.user[0].tag} for the reason of ${text.join(" ")}`, `User has been awarded ${awards[type][1]} credits!`) - .setFooter("Awarded to: " + data.user[0].tag + " (" + data.user[0].id + ") on:", data.user.displayAvatarURL()); + client.users.get(data.user[0].id).then(avatar => { + embed.setTitle(":tada: Award Notification! :tada:") + .addField(`To ${data.user[0].tag} for the reason of ${text.join(" ")}`, `User has been awarded ${awards[type][1]} credits!`) + .setFooter("Awarded to: " + data.user[0].tag + " (" + data.user[0].id + ") on:", avatar.displayAvatarURL()); - message.reply(data.user[0].ping + `(${data.user[0].id}) have been awarded ${awards[type][1]} credits!`); + message.reply(data.user[0].ping + ` (${data.user[0].id}) have been awarded ${awards[type][1]} credits!`); - client.channels.get(settings.channels.award).send({embed}); - db.run(`UPDATE scores SET credits = ${row.credits + awards[type][1]} WHERE userId = "${data.user[0].id}"`); + client.channels.get(settings.channels.award).send({embed}); + db.run(`UPDATE scores SET credits = ${row.credits + awards[type][1]} WHERE userId = "${data.user[0].id}"`); + }); }); } else { db.get("SELECT * FROM awards WHERE userID = 'Overall'", [], (err, row) => { if (err) { return console.log(err); } - settings = settings.awards; + let award = settings.awards; var sum = row.suggest + row.bugs + row.minor + row.major; - var reward = (row.suggest * settings.suggest) + (row.bugs * settings.bug) + (row.minor * settings.minor) + (row.major * settings.major); + var reward = (row.suggest * award.suggest) + (row.bugs * award.bug) + (row.minor * award.minor) + (row.major * award.major); embed.setTitle(client.user.username + "'s Award System") .setDescription(sum + " awards given equaling " + reward + " credits") .setFooter(message.guild.name, message.guild.iconURL()) .addField("Description:", "For those who have signed up with the daily command, there is a way in which users can earn more credits. By suggesting or bug and issue finding and reporting them with the report command, users can earn an amount of credits once the item is added or fixed.") - .addField("Improvements (" + settings.suggest + "):", row.suggest, true) - .addField("Bugs (" + settings.bug + "):", row.bugs, true) - .addField("Minor Issues (" + settings.minor + "):", row.minor, true) - .addField("Major Issues (" + settings.major + "):", row.major, true); + .addField("Improvements (" + award.suggest + "):", row.suggest, true) + .addField("Bugs (" + award.bug + "):", row.bugs, true) + .addField("Minor Issues (" + award.minor + "):", row.minor, true) + .addField("Major Issues (" + award.major + "):", row.major, true); message.channel.send({embed}); }); } @@ -79,6 +79,5 @@ exports.help = { name: "award", description: "Information on the awards given out.", usage: "[user:str] [suggest|bug|minor|major] [text:str][...]", - usageDelim: " ", - humanUse: " " + usageDelim: " ", humanUse: " " }; \ No newline at end of file diff --git a/commands/Mod/kick.js b/commands/Mod/kick.js index ff83ffe..a0e1587 100644 --- a/commands/Mod/kick.js +++ b/commands/Mod/kick.js @@ -1,33 +1,32 @@ exports.run = async (client, msg, [user, reason]) => { - user = await client.funcs.userSearch(msg, {user: [user], name: this.help.name}); - if (user.valid === null) { return; } - user = client.users.find("username", user.user[0].username); + user = await client.funcs.userSearch(client, msg, user); + if (user === false) { return; } - if (!reason) { return msg.reply("You must supply a reason!"); } - if (msg.guild.member(user).kickable === false) { return msg.reply("I cannot kick that member"); } + if (!reason) { return msg.reply("You must supply a reason!"); } + if (user.kickable === false) { return msg.reply("I cannot kick that member"); } - var Toast = await client.funcs.modEmbed(client, msg, "kick", user.user[0], reason); - - if (Toast.embed.thumbnail) { - await user.send({embed: Toast.DMembed}); - await msg.client.users.fetch(user.id).kick(reason); - } - - await Toast.channel.send({embed: Toast[0]}); + var data = await client.funcs.modEmbed(msg, "kick", user, reason); + + if (data.embed.thumbnail) { + await user.send({embed: data.DMembed}); + await user.kick(reason); + } + + var channel = client.funcs.defaultChannel(client, msg.guild, "mod"); + await channel.send({embed: data.embed}); }; exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["k"], - permLevel: 2, - botPerms: ["KICK_MEMBERS", "EMBED_LINKS"], - requiredFuncs: ["modEmbed", "userSearch"] + enabled: true, + runIn: ["text"], + aliases: ["k"], permLevel: 2, + botPerms: ["KICK_MEMBERS", "EMBED_LINKS"], + requiredFuncs: ["modEmbed", "userSearch"] }; exports.help = { - name: "kick", - description: "Kicks the mentioned user.", - usage: "[user:str] [reason:str] [...]", - usageDelim: " " + name: "kick", + description: "Kicks the mentioned user.", + usage: "[user:str] [reason:str]", usageDelim: "|", + humanUse: "[user] [reason]" }; \ No newline at end of file diff --git a/functions/defaultChannel.js b/functions/defaultChannel.js index 3435aa2..ff1c91b 100644 --- a/functions/defaultChannel.js +++ b/functions/defaultChannel.js @@ -1,6 +1,7 @@ module.exports = (client, guild, args) => { if (!args) { args == "default"; } - var channelID = schemaCheck(client, args); + + var channelID = schemaCheck(client, guild, args); if (channelID == false) { channelID = locate(Array.from(guild.channels), ["general", "general-chat", "off-topic"]); @@ -19,12 +20,12 @@ module.exports = (client, guild, args) => { return guild.channels.get(channelID); }; -function schemaCheck(client, schema, args) { - var schema = client.settings.guilds.schema; +function schemaCheck(client, guild, args) { + var schema = client.settings.guilds.get(guild.id); if(!schema.defaultChannel || !schema.modlog) { client.funcs.confAdd(client); } - if(schema.defaultChannel != null && args == "default") { return schema.defaultChannel; } - else if(schema.modlog != null && args == "mod") { return schema.modlog; } + if(schema.defaultChannel != null && args === "default") { return schema.defaultChannel; } + else if(schema.modlog != null && args === "mod") { return schema.modlog; } else { return false; } }; diff --git a/functions/modEmbed.js b/functions/modEmbed.js index 9f2318d..3c7e2f1 100644 --- a/functions/modEmbed.js +++ b/functions/modEmbed.js @@ -1,37 +1,37 @@ -module.exports = (client, message, action, user, reason) => { - const options = { - ban: ["Ban", "BAN_MEMBERS", "banned", 0xDD2E44], - unban: ["Unban", "BAN_MEMBERS", "unbanned", 0x21A321], - kick: ["Kick", "KICK_MEMBERS", "kicked", 0x00AE86] - }; +module.exports = (msg, action, user, reason) => { + const client = msg.client; + const Options = { + ban: ["BAN_MEMBERS", "banned", 0xDD2E44], + unban: ["BAN_MEMBERS", "unbanned", 0x21A321], + kick: ["KICK_MEMBERS", "kicked", 0x00AE86] + }; - const embed = new client.methods.Embed().setTimestamp(); - options = options[action.toLowerCase()]; + const embed = new client.methods.Embed().setTimestamp(); + var options = Options[action.toLowerCase()]; - if (message.channel.permissionsFor(message.author).has(options[1]) === false) { - embed.setColor(0xDD2E44) - .setTitle("āŒ ERROR: MISSING PERMISSIONS! āŒ") - .setDescription("You do not have the correct permissions for this command!"); - } else if (message.channel.permissionsFor(client.user).has(option[1]) === false) { - embed.setColor(0xDD2E44) - .setTitle("āŒ ERROR: MISSING PERMISSIONS! āŒ") - .setDescription("I do not have the correct permissions for this command!"); - } else { - embed.setColor(options[3]) - .addField(`**Action:** ${options[0]}`, `**Moderator:** ${message.author.tag}`) - .addField("**User:**", user.tag) - .addField("**Reason:**", reason) - .setThumbnail(message.author.displayAvatarURL()); - } + if (msg.channel.permissionsFor(msg.author).has(options[0]) === false) { + embed.setColor(0xDD2E44) + .setTitle("āŒ ERROR: MISSING PERMISSIONS! āŒ") + .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! āŒ") + .setDescription("I do not have the correct permissions for this command!"); + } else { + embed.setColor(options[2]) + .setTitle("**User " + options[1] + "!**") + .setDescription(reason) + .addField("**Moderator:**", msg.author.tag + " (" + msg.author.id + ")") + .addField("**User:**", user.user.tag + " (" + user.user.id + ")") + .setThumbnail(msg.author.displayAvatarURL()); + } - const DMembed = new client.methods.Embed() - .setColor(options[3]) - .setTitle("Moderator Message:") - .setDescription(`You have been ${options[2]} from ${message.guild.name}!\n**Reason:** ${reason}`); + const DMembed = new client.methods.Embed() + .setColor(options[2]) + .setTitle("Moderator Message:") + .setDescription(`You have been ${options[1]} from ${msg.guild.name}!\n**Reason:** ${reason}`); - var channel = !embed.thumbnail ? message.channel : client.funcs.defaultChannel(client, message.guild.id, ["mod", message.channel]); - - return { embed: embed, channel: channel, DMembed: DMembed }; + return { embed: embed, DMembed: DMembed }; }; module.exports.conf = { requiredModules: [] }; @@ -39,5 +39,5 @@ module.exports.conf = { requiredModules: [] }; module.exports.help = { name: "modEmbed", type: "functions", - description: "General embeder for moderation commands.", + description: "General embeder for moderation commands." }; \ No newline at end of file From b4218cacd717dcd562f680f0c644a0a651cd95cc Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Mon, 4 Feb 2019 14:58:03 -0400 Subject: [PATCH 19/38] Updated Emoji command Now emotes can have :: around it. --- assets/speech/en/general.js | 51 ++++++++++++++++++++++++++++++ commands/General/choose.js | 4 +-- commands/General/emoji.js | 25 ++++++++++----- commands/Mod/lockdown.js | 63 ------------------------------------- 4 files changed, 70 insertions(+), 73 deletions(-) create mode 100644 assets/speech/en/general.js delete mode 100644 commands/Mod/lockdown.js diff --git a/assets/speech/en/general.js b/assets/speech/en/general.js new file mode 100644 index 0000000..1536e0d --- /dev/null +++ b/assets/speech/en/general.js @@ -0,0 +1,51 @@ +exports.anilist = []; + +exports.avatar = []; + +exports.award = []; + +exports.calculate = []; + +exports.choose = [ + "-user, I think that **-result** would be the best choice!", + "Hmm... looks like **-result** is the best option" +]; + +exports.emoji = { + "noName": [ + "You need a name of an emote to search with, baka!" + ], + "noID": [ + "You need to specify a message's ID so that I can find it!" + ], + "badName": [ + "Type the emote's name right and try again, baka!" + ] +}; + +exports.greet = { + "me": [ + "How rude, -user! I'm not that lonely!" + ], + "success": [ + "Why hello there, -user!" + ] +}; + +exports.help = []; + +exports.info = { + "role": [ + "Looks like I can't find the role. Be sure it is spelled correctly." + ], + "server": [ + "You can't ask information about a server with additional stuff!" + ], + "noTerm": [ + "You didn't give a correct search term. Do either server, user, or role." + ] +}; + +exports.mal = []; + +exports.report = []; \ No newline at end of file diff --git a/commands/General/choose.js b/commands/General/choose.js index 930a286..b537d1b 100644 --- a/commands/General/choose.js +++ b/commands/General/choose.js @@ -1,6 +1,6 @@ -exports.run = async (client, message, [...choice]) => { +exports.run = async (client, msg, [...choice]) => { var results = choice[(Math.ceil(Math.random() * choice.length) - 1)]; - message.channel.send(`${message.author.username}, I think **${results}** would be the best choice!`); + msg.channel.send(client.speech(msg, ["choose"]).replace("-user", msg.author.username).replace("-result", results)); }; exports.conf = { diff --git a/commands/General/emoji.js b/commands/General/emoji.js index cd2f361..21b242f 100644 --- a/commands/General/emoji.js +++ b/commands/General/emoji.js @@ -1,17 +1,18 @@ exports.run = async (client, msg, [Name, ID]) => { const prefix = msg.guild.settings.prefix || client.config.prefix; - msg.delete(); - if (!Name) { return msg.channel.send("You need a name of an emote to search with, baka!").then(msg => { setTimeout(() => { msg.delete(); }, 4000); }); } - if (msg.content.slice(prefix.length).startsWith("react") && (!ID)) { - return msg.channel.send("You need to specify a message's ID so that I can find it!").then(msg => { setTimeout(() => { msg.delete(); }, 4000); }); - } + if (msg.channel.permissionsFor(client.user).has("MANAGE_MESSAGES")) { msg.delete(); } + if (!Name) { return errMsg(msg, "noName"); } + if (msg.content.slice(prefix.length).startsWith("react") && (!ID)) { return errMsg(msg, "noID"); } + if (Name.startsWith("<")) { Name = Name.slice(2, -20); } let emotes = Array.from(client.emojis); let emoji = emotes.filter((element) => { if (element[1].name === Name) { return element; } }); - var type = emoji[0][1].animated === true ? "gif" : "png"; + + try { var type = emoji[0][1].animated === true ? "gif" : "png"; } + catch(err) { return errMsg(msg, "badName"); } if (msg.content.slice(prefix.length).startsWith("react")) { msg.channel.messages.fetch(ID).then(msg => msg.react(client.emojis.get(emoji[0][0]))); @@ -23,7 +24,7 @@ exports.conf = { runIn: ["text"], aliases: ["see", "emote", "react"], permLevel: 0, - botPerms: ["ATTACH_FILES", "ADD_REACTIONS", "MANAGE_MESSAGES"] + botPerms: ["ATTACH_FILES", "ADD_REACTIONS"] }; exports.help = { @@ -32,4 +33,12 @@ exports.help = { usage: "[Name:str] [messageID:str]", usageDelim: " ", extendedHelp: "Bring in your pool of emotes from other servers! Either use the big image or use the alias of react and add a message ID to react to a message instead!", humanUse: "(name)_([If reacting] messageID)" -}; \ No newline at end of file +}; + +function errMsg(msg, type) { + msg.channel.send(msg.client.speech(msg, ["emoji", type])).then(msg => { + if (msg.channel.permissionsFor(msg.client.user).has("MANAGE_MESSAGES")) { + setTimeout(() => { msg.delete(); }, 4000); + } + }); +} \ No newline at end of file diff --git a/commands/Mod/lockdown.js b/commands/Mod/lockdown.js deleted file mode 100644 index bf40e6c..0000000 --- a/commands/Mod/lockdown.js +++ /dev/null @@ -1,63 +0,0 @@ -const ms = require("ms"); - -exports.run = async (client, message, [time, reason]) => { - if (!client.lockit) { client.lockit = []; } - let validUnlocks = ["release", "unlock", "u"]; - if (!time) { return message.reply("I need a set time to lock the channel down for!"); } - - const Lockembed = new client.methods.Embed() - .setColor(0xDD2E44) - .setTimestamp() - .setTitle("šŸ”’ LOCKDOWN NOTICE šŸ”’") - .setDescription(`This channel has been lockdown by ${message.author.tag} for ${time}`); - if (reason != null) { Lockembed.addField("Reason: ", reason); } - - const Unlockembed = new client.methods.Embed() - .setColor(0xDD2E44) - .setTimestamp() - .setTitle("šŸ”“ LOCKDOWN NOTICE šŸ”“") - .setDescription("This channel is now unlocked."); - - if (message.channel.permissionsFor(message.author.id).has("MUTE_MEMBERS") === false) { - const embed = new client.methods.Embed() - .setColor(0xDD2E44) - .setTimestamp() - .setTitle("āŒ ERROR: MISSING PERMISSIONS! āŒ") - .setDescription("You do not have the correct permissions for this command!"); - return message.channel.send({embed}); - } - - if (validUnlocks.includes(time)) { - message.channel.overwritePermissions(message.guild.id, { SEND_MESSAGES: null }).then(() => { - message.channel.send({embed: Unlockembed}); - clearTimeout(client.lockit[message.channel.id]); - delete client.lockit[message.channel.id]; - }).catch(error => { console.log(error); }); - } else { - message.channel.overwritePermissions(message.guild.id, { SEND_MESSAGES: false }).then(() => { - message.channel.send({embed: Lockembed}).then(() => { - client.lockit[message.channel.id] = setTimeout(() => { - message.channel.overwritePermissions(message.guild.id, { - SEND_MESSAGES: null - }).then(message.channel.send({embed: Unlockembed})).catch(console.error); - delete client.lockit[message.channel.id]; - }, ms(time)); - }).catch(error => { console.log(error); }); - }); - } -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["ld", "lock"], - permLevel: 2, - botPerms: ["MANAGE_ROLES", "EMBED_LINKS", "ADMINISTRATOR"] -}; - -exports.help = { - name: "lockdown", - description: "Locks or unlocks the channel.", - usage: "[time:str] [reason:str]", - usageDelim: " | " -}; \ No newline at end of file From 9cb908acd35db0638357f856db2e78d4d6b68fc8 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Mon, 4 Feb 2019 15:21:23 -0400 Subject: [PATCH 20/38] Linux Fix Fixed an issue with not being able to find the localization files on Linux systems. --- functions/confAdd.js | 6 +++--- utilities/commandRemover.js | 4 ++-- utilities/speechHelper.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/confAdd.js b/functions/confAdd.js index eada66f..5c5d9ae 100644 --- a/functions/confAdd.js +++ b/functions/confAdd.js @@ -1,8 +1,8 @@ module.exports = async client => { if (!client.settings.guilds.schema.modlog) { await client.settings.guilds.add("modlog", { type: "TextChannel" }); } - if (!client.settings.guilds.schema.starboard) { await client.settings.guilds.add("starboard", { type: "TextChannel" }); } - if (!client.settings.guilds.schema.defaultChannel) { await client.settings.guilds.add("defaultChannel", {type: "TextChannel"}); } - if (!client.settings.guilds.schema.welcomeChannel) { await client.settings.guilds.add("welcomeChannel", { type: "TextChannel"}); } + if (!client.settings.guilds.schema.defaultChannel) { await client.settings.guilds.add("defaultChannel", { type: "TextChannel"}); } + if (!client.settings.guilds.schema.lang) { await client.settings.guilds.add("lang", { type: "string", value: "en" }); } + if (!client.settings.guilds.schema.muteRole) { await client.settings.guilds.add("muteRole", {type: "role"}); } }; module.exports.conf = { requiredModules: [] }; diff --git a/utilities/commandRemover.js b/utilities/commandRemover.js index 317b113..5147855 100644 --- a/utilities/commandRemover.js +++ b/utilities/commandRemover.js @@ -4,8 +4,8 @@ module.exports = function(client) { var files = ["stats", "download", "info", "ping", "invite", "reboot", "help"]; for(var x = 0; x < files.length; x++) { - if (fs.existsSync(client.clientBaseDir + "\\node_modules\\komada\\src\\commands\\System\\" + files[x] + ".js")) { - fs.unlinkSync(client.clientBaseDir + "\\node_modules\\komada\\src\\commands\\System\\" + files[x] + ".js"); + if (fs.existsSync(client.clientBaseDir + "/node_modules/komada/src/commands/System/" + files[x] + ".js")) { + fs.unlinkSync(client.clientBaseDir + "/node_modules/komada/src/commands/System/" + files[x] + ".js"); } } }; \ No newline at end of file diff --git a/utilities/speechHelper.js b/utilities/speechHelper.js index 749170d..807ccd2 100644 --- a/utilities/speechHelper.js +++ b/utilities/speechHelper.js @@ -10,7 +10,7 @@ module.exports = function(msg, keys) { category = category[category.length - 1].toLowerCase(); } - var PATH = msg.client.clientBaseDir + "\\assets\\speech\\" + msg.guildSettings.lang + "\\" + category + ".js"; + var PATH = msg.client.clientBaseDir + "assets/speech/" + msg.guildSettings.lang + "/" + category + ".js"; if (fs.existsSync(PATH) == false) { throw new Error("Localization file is missing.\nLanguage: " + msg.guildSettings.lang + "\nCategory: " + category + "\nCommand: " + name); From 9dc3e6af02888e66b31116f327236a2c11777761 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Mon, 4 Feb 2019 17:32:21 -0400 Subject: [PATCH 21/38] Cleaned Code Added the ability for the speech module in the awards command Fixed Codacy issues with a couple files. --- assets/speech/en/general.js | 19 +++++++++++++++++-- commands/General/anilist.js | 3 ++- commands/General/avatar.js | 6 +++--- commands/General/award.js | 36 +++++++++++++++++------------------- commands/General/info.js | 8 +++----- commands/Music/queueadd.js | 6 +++--- functions/presenceHelper.js | 14 +++++++------- 7 files changed, 52 insertions(+), 40 deletions(-) diff --git a/assets/speech/en/general.js b/assets/speech/en/general.js index 1536e0d..c9f623a 100644 --- a/assets/speech/en/general.js +++ b/assets/speech/en/general.js @@ -1,8 +1,23 @@ -exports.anilist = []; +exports.anilist = [ //Missing search term + "You forgot to include a search term!" +]; exports.avatar = []; -exports.award = []; +exports.award = { + "noType": [ + "BAKA! I need a type of an award!" + ], + "noText": [ + "Explain yourself on giving the award!" + ], + "noRow": [ + "That user has not gotten their first daily yet!" + ], + "success": [ + "<@-id>, (-id) have been awarded -credits credits!" + ] +}; exports.calculate = []; diff --git a/commands/General/anilist.js b/commands/General/anilist.js index adf3e11..5f05816 100644 --- a/commands/General/anilist.js +++ b/commands/General/anilist.js @@ -1,12 +1,13 @@ const fetch = require("node-fetch"); exports.run = async (client, msg, [term]) => { + if (!term) { return msg.channel.send(client.speech(msg, ["anilist"])); } var options = { method: "POST", headers: { "Content-Type": "application/json", "Accept": "application/json" }, body: JSON.stringify({ query: `query ($name: String) { User(name: $name) { avatar { large } siteUrl stats { watchedTime chaptersRead animeListScores { meanScore } mangaListScores { meanScore } - animeStatusDistribution { status amount } mangaStatusDistribution { status amount } } + animeStatusDistribution { amount } mangaStatusDistribution { amount } } } }`, variables: { name: term } }) }; var response = await fetch("https://graphql.anilist.co", options); diff --git a/commands/General/avatar.js b/commands/General/avatar.js index 6d1d84b..976d95d 100644 --- a/commands/General/avatar.js +++ b/commands/General/avatar.js @@ -1,7 +1,7 @@ exports.run = async (client, msg, [user]) => { - client.funcs.userSearch(client, msg, {user: [user], name: this.help.name}).then(data => { - if (data.valid !== false) { - client.users.fetch(data.user[0].id).then(avatar => { msg.channel.send("", { files: [avatar.displayAvatarURL()]}); }); + client.funcs.userSearch(client, msg, user).then(data => { + if (data !== false) { + msg.channel.send("", { files: [data.user.displayAvatarURL()]}); } }); }; diff --git a/commands/General/award.js b/commands/General/award.js index 717320e..f61a472 100644 --- a/commands/General/award.js +++ b/commands/General/award.js @@ -1,4 +1,4 @@ -exports.run = async (client, message, [user, type, ...text]) => { +exports.run = async (client, msg, [user, type, ...text]) => { const sqlite3 = require("sqlite3").verbose(); let db = new sqlite3.Database(client.database.general); const settings = client.ownerSetting; @@ -7,16 +7,16 @@ exports.run = async (client, message, [user, type, ...text]) => { .setColor(0x04d5fd) .setTimestamp(); - if (user !== undefined && message.author.id === client.owner.id) { - if (!type) { return message.reply("BAKA! I need a type of an award!"); } - if (!text) { return message.reply("Explain yourself on giving the award!"); } + if (user !== undefined && msg.author.id === client.owner.id) { + if (!type) { return msg.reply(client.speech(msg, ["award", "noType"])); } + if (!text) { return msg.reply(client.speech(msg, ["award", "noText"])); } - var data = await client.funcs.userSearch(client, message, {user: [user], tags:["bot"], name: this.help.name}); - if (data.valid === false) { return; } + var data = await client.funcs.userSearch(client, msg, user, ["bot"]); + if (data === false) { return; } - db.get(`SELECT credits FROM scores WHERE userId = "${data.user[0].id}"`, [], (err, row) => { + db.get(`SELECT credits FROM scores WHERE userId = "${data.id}"`, [], (err, row) => { if (err) { return console.log(err); } - if (!row) { return message.reply("That user has not gotten their first daily yet!"); } + if (!row) { return msg.reply(client.speech(msg, ["award", "noRow"])); } type = type.toLowerCase(); @@ -27,23 +27,21 @@ exports.run = async (client, message, [user, type, ...text]) => { major: ["major", settings.awards.major] }; - let users = ["Overall", data.user[0].id]; + let users = ["Overall", data.id]; for (var x = 0; x < users.length; x++) { db.get(`SELECT ${awards[type][0]} FROM awards WHERE userId = "${users[x]}"`, [], (err, row) => { db.run(`UPDATE awards SET ${awards[type][0]} = ${Object.values(row)[0] + 1} WHERE userId = "${users[x]}"`); }); }; - client.users.get(data.user[0].id).then(avatar => { - embed.setTitle(":tada: Award Notification! :tada:") - .addField(`To ${data.user[0].tag} for the reason of ${text.join(" ")}`, `User has been awarded ${awards[type][1]} credits!`) - .setFooter("Awarded to: " + data.user[0].tag + " (" + data.user[0].id + ") on:", avatar.displayAvatarURL()); + embed.setTitle(":tada: Award Notification! :tada:") + .addField(`To ${data.user.tag} for the reason of ${text.join(" ")}`, `User has been awarded ${awards[type][1]} credits!`) + .setFooter("Awarded to: " + data.user.tag + " (" + data.id + ") on:", data.user.displayAvatarURL()); - message.reply(data.user[0].ping + ` (${data.user[0].id}) have been awarded ${awards[type][1]} credits!`); + msg.reply(client.speech(msg, ["award", "success"]).replace(/-id/g, data.id).replace("-credit", awards[type][1])); - client.channels.get(settings.channels.award).send({embed}); - db.run(`UPDATE scores SET credits = ${row.credits + awards[type][1]} WHERE userId = "${data.user[0].id}"`); - }); + client.channels.get(settings.channels.award).send({embed}); + db.run(`UPDATE scores SET credits = ${row.credits + awards[type][1]} WHERE userId = "${data.id}"`); }); } else { db.get("SELECT * FROM awards WHERE userID = 'Overall'", [], (err, row) => { @@ -54,13 +52,13 @@ exports.run = async (client, message, [user, type, ...text]) => { embed.setTitle(client.user.username + "'s Award System") .setDescription(sum + " awards given equaling " + reward + " credits") - .setFooter(message.guild.name, message.guild.iconURL()) + .setFooter(msg.guild.name, msg.guild.iconURL()) .addField("Description:", "For those who have signed up with the daily command, there is a way in which users can earn more credits. By suggesting or bug and issue finding and reporting them with the report command, users can earn an amount of credits once the item is added or fixed.") .addField("Improvements (" + award.suggest + "):", row.suggest, true) .addField("Bugs (" + award.bug + "):", row.bugs, true) .addField("Minor Issues (" + award.minor + "):", row.minor, true) .addField("Major Issues (" + award.major + "):", row.major, true); - message.channel.send({embed}); + msg.channel.send({embed}); }); } db.close(); diff --git a/commands/General/info.js b/commands/General/info.js index 6f9d282..639c0b4 100644 --- a/commands/General/info.js +++ b/commands/General/info.js @@ -14,8 +14,6 @@ exports.run = async (client, message, [kind, search]) => { user = await client.funcs.userSearch(client, message, user); if (user === false) { return; } - var userC = client.users.get(user.id); - const statusList = { online: "online", idle: "idle", @@ -25,10 +23,10 @@ exports.run = async (client, message, [kind, search]) => { var Status = statusList[user.presence.status] || "offline"; var activity = user.presence.activity !== null ? " while playing " + user.presence.activity.name: " "; - embed.setThumbnail(userC.displayAvatarURL()) - .setAuthor("User: " + user.user.tag + " | ID: " + user.id) + embed.setThumbnail(user.user.displayAvatarURL()) + .setAuthor(user.user.tag + " | " + user.id) .setDescription("Currently " + Status + activity) - .addField("Created:", userC.createdAt.toLocaleString(), true) + .addField("Created:", user.user.createdAt.toLocaleString(), true) .addField("Joined:", user.joinedAt.toLocaleString(), true) .addField("Bot user:", user.bot ? "True": "False", true); break; case "role": diff --git a/commands/Music/queueadd.js b/commands/Music/queueadd.js index 4b852ee..b110e45 100644 --- a/commands/Music/queueadd.js +++ b/commands/Music/queueadd.js @@ -9,7 +9,7 @@ exports.run = async (client, msg, [song]) => { if (song.match(/(playlist\?list=\S{30,34})/)) { msg.send(client.speech(msg, ["queueadd", "listDetect"])); - list = await Promise.resolve(ytPlay(song, "id")); + var list = await Promise.resolve(ytPlay(song, "id")); for(var x = 0; x < list.data.playlist.length; x++) { id.push(list.data.playlist[x]); @@ -20,7 +20,7 @@ exports.run = async (client, msg, [song]) => { for(var x = 0; x < id.length; x++) { try { - info = await getInfoAsync("https://youtu.be/" + id[x]); + var info = await getInfoAsync("https://youtu.be/" + id[x]); handler.queue.push({ url: "https://youtu.be/" + id[x], @@ -34,7 +34,7 @@ exports.run = async (client, msg, [song]) => { } } - if (id.length == 1) { msg.send(client.speech(msg, ["queueadd", "success"]).replace("-title", info.title)); } + if (id.length === 1) { msg.send(client.speech(msg, ["queueadd", "success"]).replace("-title", info.title)); } else { msg.send(client.speech(msg, ["queueadd", "multi"]).replace("-number", id.length)); } }; diff --git a/functions/presenceHelper.js b/functions/presenceHelper.js index 108d28b..eb09614 100644 --- a/functions/presenceHelper.js +++ b/functions/presenceHelper.js @@ -1,15 +1,15 @@ let games = require("../assets/localization.json")["games"]; module.exports = (client, name, type, status) => { - if (status == null) { status == "online"; } - if (type == null) { type == 0; } //A.K.A => play + if (status === null) { status = "online"; } + if (type === null) { type = 0; } //A.K.A => play - if (name == "-start" || name == "-reset") { + if (name === "-start" || name === "-reset") { Presence(client, "play", "Playing around with " + client.owner.username, "online"); client.timer = setInterval(function() { do { //No duplicate statuses, Margarine. K thx. var items = games[Math.floor(Math.random() * games.length)]; - } while (client.user.presence.activity.name != null && items[0] == client.user.presence.activity.name.slice(9)); + } while (client.user.presence.activity.name !== null && items[0] === client.user.presence.activity.name.slice(9)); Presence(client, items[1], items[0], status); }, 900000); @@ -22,7 +22,7 @@ module.exports = (client, name, type, status) => { function Presence(client, type, name, status) { const tList = { "play": "PLAYING", "stream": "STREAMING", "listen": "LISTENING", "watch": "WATCHING" }; type = tList[type]; - name = (name != "-null") ? "m~help | " + name : null; + name = (name !== "-null") ? "m~help | " + name : null; - client.user.setPresence({ activity: { name: name, type: type }, status: status }); -}; \ No newline at end of file + client.user.setPresence({ activity: { name, type }, status }); +} \ No newline at end of file From 1ee44dad4cc246ee5adfd33f789377db174a5a5b Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Wed, 6 Feb 2019 09:48:27 -0400 Subject: [PATCH 22/38] Fixed and Improved Report Command Improved the Report command's filter and code Added the ability of speech to the report command Codacy Fixes on several files. --- assets/settingsExample.json | 5 ++-- assets/speech/en/general.js | 23 ++++++++++++++++- commands/General/award.js | 13 +++++----- commands/General/report.js | 50 +++++++++++++------------------------ commands/Music/resume.js | 2 +- commands/System/about.js | 2 +- functions/defaultChannel.js | 18 ++++++------- utilities/speechHelper.js | 4 +-- 8 files changed, 63 insertions(+), 54 deletions(-) diff --git a/assets/settingsExample.json b/assets/settingsExample.json index 6b6ea80..d67ea48 100644 --- a/assets/settingsExample.json +++ b/assets/settingsExample.json @@ -9,7 +9,7 @@ "owner": { "channels": { "award": "", - "report": "" }, "awards": { "suggest": 250, @@ -20,6 +20,7 @@ }, "database": { "general": "./assets/data/general.sqlite", - "inv": "./assets/data/inventory.sqlite" + "inv": "./assets/data/inventory.sqlite", + "user": "./assets/data/users.sqlite" } } diff --git a/assets/speech/en/general.js b/assets/speech/en/general.js index c9f623a..3938b6e 100644 --- a/assets/speech/en/general.js +++ b/assets/speech/en/general.js @@ -63,4 +63,25 @@ exports.info = { exports.mal = []; -exports.report = []; \ No newline at end of file +exports.report = { + "start": [ + "I'm going to be asking a couple of questions so I'll be taking this into the DMs." + ], + "q1": [ + "Alright. Let's get to the point. First question: What kind of issue is this?\nPlease answer `issue`, `bug`, `complaint`, or `suggestion`" + ], + "q2": [ + "Next: Please provide a decently sized message explaining the item." + ], + "err1": [ + "You are not able to send todo reports. Only the bot owner can." + ], + "timeout": { + "t1": [ + "You didn't provide me with a description in time. I recommend either making your report shorter or copy and pasting so that you don't have to try and type it so quickly." + ], + "t2": [ + "It seems you have timed out with making a report. When you are ready, feel free to try again!" + ] + } +}; \ No newline at end of file diff --git a/commands/General/award.js b/commands/General/award.js index f61a472..3abe409 100644 --- a/commands/General/award.js +++ b/commands/General/award.js @@ -27,12 +27,13 @@ exports.run = async (client, msg, [user, type, ...text]) => { major: ["major", settings.awards.major] }; - let users = ["Overall", data.id]; - for (var x = 0; x < users.length; x++) { - db.get(`SELECT ${awards[type][0]} FROM awards WHERE userId = "${users[x]}"`, [], (err, row) => { - db.run(`UPDATE awards SET ${awards[type][0]} = ${Object.values(row)[0] + 1} WHERE userId = "${users[x]}"`); - }); - }; + db.get(`SELECT ${awards[type][0]} FROM awards WHERE userId = "Overall"`, [], (err, row) => { + db.run(`UPDATE awards SET ${awards[type][0]} = ${Object.values(row)[0] + 1} WHERE userId = "Overall"`); + }); + + db.get(`SELECT ${awards[type][0]} FROM awards WHERE userId = "${data.id}"`, [], (err, row) => { + db.run(`UPDATE awards SET ${awards[type][0]} = ${Object.values(row)[0] + 1} WHERE userId = "${data.id}"`); + }); embed.setTitle(":tada: Award Notification! :tada:") .addField(`To ${data.user.tag} for the reason of ${text.join(" ")}`, `User has been awarded ${awards[type][1]} credits!`) diff --git a/commands/General/report.js b/commands/General/report.js index a8815aa..30b23dc 100644 --- a/commands/General/report.js +++ b/commands/General/report.js @@ -1,63 +1,50 @@ exports.run = async (client, msg) => { const sqlite3 = require("sqlite3").verbose(); let db = new sqlite3.Database(client.database.general); - - const reports = []; const reportTypes = { issue: ["Issue", 0xFF0000], bug: ["Bug", 0xFFFF00], - improvement: ["Improvement", 0xFFA500], suggestion: ["Suggestion", 0xFFA500], complaint: ["Complaint", 0xDB3E17], todo: ["Todo", 0x04d5fd] }; - const text = [ - "Alright. Let's get to the point. First question: What kind of issue is this?\nPlease answer `issue`, `bug`, `complaint`, `suggestion`, or `improvement`", - "Next: Please provide a decently sized message explaining the item." - ]; + const filter = m => Object.keys(reportTypes).includes(m.content.toLowerCase()); - const issue = [ - "It seems you have timed out with making a report. When you are ready, feel free to try again!", - "You didn't provide me with a description in time. I recommend either making your report shorter or copy and pasting so that you don't have to try and type it so quickly." - ]; + await msg.reply(client.speech(msg, ["report", "start"])); + await msg.author.send(client.speech(msg, ["report", "q1"])).then(() => { + msg.author.dmChannel.awaitMessages(filter, { max: 1, time: 160000, errors: ["time"], }).then((collected) => { + var type = collected.first().content.toLowerCase(); + if (type === "todo" && msg.author.id !== client.owner.id) { return msg.author.send(client.speech(msg, ["report", "err1"])); } - await msg.reply("I'm going to be asking a couple of questions so I'll be taking this into the DMs."); - await msg.author.send(text[0]).then(() => { - msg.author.dmChannel.awaitMessages(m => m.content, { max: 1, time: 160000, errors: ["time"], }).then((collected) => { - var type = collected.first().content; - if (type.toLowerCase() !== reportTypes[type.toLowerCase()][0].toLowerCase()) { return msg.author.send("You have provided me with an invalid type of issue. Please try again with a valid one."); } - if (reportTypes[type.toLowerCase()][0] === "Todo" && msg.author.id !== client.owner.id) { return msg.author.send("You are not able to send todo reports. Only the bot owner can."); } - - reports.push(reportTypes[type.toLowerCase()]); - msg.author.send(text[1]).then(() => { - msg.author.dmChannel.awaitMessages(m => m.content, { max: 1, time: 130000, errors: ["time"], }).then((collected) => { - reports.push(collected.first().content); + type = reportTypes[type]; + msg.author.send(client.speech(msg, ["report", "q2"])).then(() => { + msg.author.dmChannel.awaitMessages(m => m.content, { max: 1, time: 130000, errors: ["time"], }).then((desc) => { db.get("SELECT reportNumber FROM stats WHERE statName = 'report'", [], (err, row) => { if (err) { return console.log(err); } const embed = new client.methods.Embed() .setTimestamp() - .setColor(reports[0][1]) - .setTitle(`${reports[0][0]} Report: ${row.reportNumber}`) - .setDescription(reports[1]) + .setColor(type[0][1]) + .setTitle(`${type[0][0]} Report: ${row.reportNumber}`) + .setDescription(desc.first().content) .setFooter(`Reported by: ${msg.author.tag} from ${msg.channel.guild.name}`, msg.author.displayAvatarURL()); const DMembed = new client.methods.Embed() .setColor(0x00AE86) .setTimestamp() - .setDescription(`**Report number:** ${row.reportNumber} \n**Issue:** ${reports[1]} - \nYour report has been sent! Any more questions, please ask Butterstroke#7150!`); + .setDescription(`**Report number:** ${row.reportNumber} \n**Issue:** ${desc.first().content} + \nYour report has been sent! Any more questions, please ask ${client.owner.tag}!`); - db.run(`UPDATE stats SET reportNumber = ${row.reportNumber + 1} WHERE statName ="general"`); + db.run(`UPDATE stats SET reportNumber = ${row.reportNumber + 1} WHERE statName ="report"`); client.channels.get(client.ownerSetting.get("channels").report).send({embed}); msg.author.send({embed: DMembed}); }); db.close(); - }).catch(() => { msg.author.send(issue[1]); }); + }).catch(() => { msg.author.send(client.speech(msg, ["report", "timeout", "t2"])); }); }); - }).catch(() => { msg.author.send(issue[0]); }); + }).catch(() => { msg.author.send(client.speech(msg, ["report", "timeout", "t1"])); }); }); }; @@ -71,7 +58,6 @@ exports.conf = { exports.help = { name: "report", - description: "File a report to the bot developer. (ie: Bug, issue, complaint)", - usage: "", + description: "File a report to the bot developer. (ie: Bug, issue, complaint)", usage: "", extendedHelp: "Margarine will be sliding into your DMs for a few questions. Be sure to have DMs open and ready to answer some questions!" }; \ No newline at end of file diff --git a/commands/Music/resume.js b/commands/Music/resume.js index 1bbc144..1f22759 100644 --- a/commands/Music/resume.js +++ b/commands/Music/resume.js @@ -1,7 +1,7 @@ exports.run = async (client, msg) => { var handler = client.funcs.musicCheck(msg); if (handler === false) { return; } - if (handler.state != "PAUSE") { return msg.channel.send(client.speech(msg, ["resume", "noPause"])); } + if (handler.state !== "PAUSE") { return msg.channel.send(client.speech(msg, ["resume", "noPause"])); } handler.dispatcher.resume(); handler.state = "PLAY"; diff --git a/commands/System/about.js b/commands/System/about.js index c1b403a..620b63f 100644 --- a/commands/System/about.js +++ b/commands/System/about.js @@ -36,4 +36,4 @@ function dateMaker(date) { var d = date.toLocaleString().split(" ")[0].split("-"); return d[2] + " " + months[d[1]] + ", " + d[0]; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/functions/defaultChannel.js b/functions/defaultChannel.js index ff1c91b..67ba666 100644 --- a/functions/defaultChannel.js +++ b/functions/defaultChannel.js @@ -1,15 +1,15 @@ module.exports = (client, guild, args) => { - if (!args) { args == "default"; } + if (!args) { args === "default"; } var channelID = schemaCheck(client, guild, args); - if (channelID == false) { + if (channelID === false) { channelID = locate(Array.from(guild.channels), ["general", "general-chat", "off-topic"]); - if (channelID == false) { + if (channelID === false) { var channels = Array.from(guild.channels.sort((e1, e2) => e1.rawPosition - e2.rawPosition)); for (var x = 0; x < channels.length; x++) { var currChannel = channels[x][1]; - if (currChannel.type == "text" && currChannel.permissionsFor(guild.members.get(client.user.id)).has("SEND_MESSAGES")) { + if (currChannel.type === "text" && currChannel.permissionsFor(guild.members.get(client.user.id)).has("SEND_MESSAGES")) { channelID = currChannel.id; x = channels.length; } @@ -24,15 +24,15 @@ function schemaCheck(client, guild, args) { var schema = client.settings.guilds.get(guild.id); if(!schema.defaultChannel || !schema.modlog) { client.funcs.confAdd(client); } - if(schema.defaultChannel != null && args === "default") { return schema.defaultChannel; } - else if(schema.modlog != null && args === "mod") { return schema.modlog; } + if(schema.defaultChannel !== null && args === "default") { return schema.defaultChannel; } + else if(schema.modlog !== null && args === "mod") { return schema.modlog; } else { return false; } }; function locate(cList, name) { var channelList = Array.from(cList); for (var x = 0; x < channelList.length; x++) { - if (name.includes(channelList[x][1].name) && channelList[x][1].type == "text") { x = channelList.length; return channelList[x][1].id; } - if (x + 1 == channelList.length) { return false; } + if (name.includes(channelList[x][1].name) && channelList[x][1].type === "text") { x = channelList.length; return channelList[x][1].id; } + if (x + 1 === channelList.length) { return false; } } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/utilities/speechHelper.js b/utilities/speechHelper.js index 807ccd2..629dcd1 100644 --- a/utilities/speechHelper.js +++ b/utilities/speechHelper.js @@ -12,12 +12,12 @@ module.exports = function(msg, keys) { var PATH = msg.client.clientBaseDir + "assets/speech/" + msg.guildSettings.lang + "/" + category + ".js"; - if (fs.existsSync(PATH) == false) { + if (fs.existsSync(PATH) === false) { throw new Error("Localization file is missing.\nLanguage: " + msg.guildSettings.lang + "\nCategory: " + category + "\nCommand: " + name); } var t = require(PATH); var n; - if (name.startsWith("func-") == false) { t = t[name]; n = 1; } + if (name.startsWith("func-") === false) { t = t[name]; n = 1; } else { t = t[keys[1]]; n = 2; } for (var x = n; x < keys.length; x++) { t = t[keys[x]]; } var text = t[Math.floor(Math.random() * t.length)]; var prefix = msg.guildSettings.prefix || msg.client.config.prefix; From 15de8d47c8a5088cdecc17b8bfb704d4511198be Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Tue, 5 Mar 2019 10:09:17 -0400 Subject: [PATCH 23/38] Added more lines to speech Roll and rps now work with the speech module. --- assets/speech/en/fun.js | 23 +++++++++++++++++++++++ commands/Fun/roll.js | 23 +++++++++++------------ commands/Fun/rps.js | 34 +++++++++++++++++++++------------- commands/Fun/say.js | 2 +- commands/General/choose.js | 2 +- 5 files changed, 57 insertions(+), 27 deletions(-) create mode 100644 assets/speech/en/fun.js diff --git a/assets/speech/en/fun.js b/assets/speech/en/fun.js new file mode 100644 index 0000000..ca27366 --- /dev/null +++ b/assets/speech/en/fun.js @@ -0,0 +1,23 @@ +exports.roll = { + "zero": [ + "You can't roll from 0!" + ], + "negative": [ + "You can't roll a negative number, baka!" + ], + "success": [ + "šŸŽ² You rolled a -value! šŸŽ²" + ], + "noNumber": [ + "It seems you added some letters into your number. Please try again!" + ] +}; + +exports.rps = { + "sameUser": [ + "Hey! You can't play rock, paper, scissors with yourself! Invite someone into the mix or play with me instead!" + ], + "success": [ + "-user1 plays -hand1! -user2 plays -hand2! **-result!**" + ] +}; \ No newline at end of file diff --git a/commands/Fun/roll.js b/commands/Fun/roll.js index 30cd599..f82d913 100644 --- a/commands/Fun/roll.js +++ b/commands/Fun/roll.js @@ -1,14 +1,14 @@ -exports.run = (client, message, sides) => { - if (sides.length < 1) { sides = 6; } - if (sides === 0) { return message.channel.send("You can't roll from 0!"); } +exports.run = (client, msg, sides) => { + sides = (sides.length < 1) ? 6 : Number(sides); + if (sides === 0) { return msg.channel.send(client.speech(msg, ["roll", "zero"])); } - if (Number.isInteger(Number(sides))) { + if (Number.isInteger(sides)) { + if (sides < 0) { return msg.channel.send(client.speech(msg, ["roll", "negative"])); } var y = Math.floor(Math.random() * (Math.floor(sides) - Math.ceil(1) + 1)) + Math.ceil(1); - return message.channel.send(`šŸŽ² You rolled a ${y}! šŸŽ²`); - } else { - return message.channel.send("It seems you added some letters into your number. Please try again!"); - } - }; + return msg.channel.send(client.speech(msg, ["roll", "success"]).replace("-value", y)); + } + return msg.channel.send(client.speech(msg, ["roll", "noNumber"])); +}; exports.conf = { enabled: true, @@ -19,7 +19,6 @@ exports.conf = { }; exports.help = { - name: "roll", - description: "Roll a die!", - usage: "[sides:str]" + name: "roll", description: "Roll a die!", + usage: "[sides:str]", humanUse: "[sides]" }; \ No newline at end of file diff --git a/commands/Fun/rps.js b/commands/Fun/rps.js index fbd41d1..8d83f6a 100644 --- a/commands/Fun/rps.js +++ b/commands/Fun/rps.js @@ -1,24 +1,32 @@ exports.run = async (client, msg, [choice, user]) => { - if (!user) { user = client.user.id; } - var data = await client.funcs.userSearch(client, msg, {user: [null, user], name: this.help.name}); - - if (data.valid === false) { return; } - if (data.user[1].id === msg.author.id) { msg.channel.send("Hey! You can't play rock, paper, scissors with yourself! Invite someone into the mix or play with me instead!"); } - - var types = ["rock", "paper", "scissors"]; - var hand = types[Math.floor(Math.random() * (Math.floor(2) - Math.ceil(1) + 1)) + Math.ceil(1)]; + if (!user) { user = client.user.id; } + client.funcs.userSearch(client, msg, user).then(data => { + if (data !== false) { + if (data.user.id === msg.author.id) { return msg.channel.send(client.speech(msg, ["rps", "sameUser"])); } - if ((choice === "rock" && hand === "scissors") || (choice === "paper" && hand === "rock") || (choice === "scissors" && hand === "paper")) { var result = `**${data.user[0].prefered} wins!**`; } - else if ((choice === "rock" && hand === "paper") || (choice === "paper" && hand === "scissors") || (choice === "scissors" && hand === "rock")) { var result = `**${data.user[1].prefered} wins!**`; } - else { var result = "**Draw!**"; } + var types = ["rock", "paper", "scissors"]; + var hand = types[Math.floor(Math.random() * (Math.floor(2) - Math.ceil(1) + 1)) + Math.ceil(1)]; + + if ((choice === "rock" && hand === "scissors") || (choice === "paper" && hand === "rock") || (choice === "scissors" && hand === "paper")) { var result = `${msg.author.username} wins`; } + else if ((choice === "rock" && hand === "paper") || (choice === "paper" && hand === "scissors") || (choice === "scissors" && hand === "rock")) { var result = `${data.user.username} wins`; } + else { var result = "Draw"; } - msg.channel.send(`${data.user[0].prefered} plays ${choice}! ${data.user[1].prefered} plays ${hand}! ${result}`); + msg.channel.send( + client.speech(msg, ["rps", "success"]) + .replace("-user1", msg.author.username) + .replace("-user2", data.user.username) + .replace("-hand1", choice) + .replace("-hand2", hand) + .replace("-result", result) + ); + } + }); }; exports.conf = { enabled: true, runIn: ["text"], - aliases: [], + aliases: ["rockpaperscissors"], permLevel: 0, botPerms: [], requiredFuncs: ["userSearch"] diff --git a/commands/Fun/say.js b/commands/Fun/say.js index 2d78852..8a12072 100644 --- a/commands/Fun/say.js +++ b/commands/Fun/say.js @@ -17,5 +17,5 @@ exports.conf = { exports.help = { name: "say", description: "Have Margarine echo what you said.", - usage: "[msg:str]" + usage: "[msg:str]", humanUse: "[msg]" }; diff --git a/commands/General/choose.js b/commands/General/choose.js index b537d1b..2c8004c 100644 --- a/commands/General/choose.js +++ b/commands/General/choose.js @@ -6,7 +6,7 @@ exports.run = async (client, msg, [...choice]) => { exports.conf = { enabled: true, runIn: ["text"], - aliases: [], + aliases: ["choice"], permLevel: 0, botPerms: [] }; From 83476293320c1932d44e27be08d5b1042d34d16a Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Mon, 8 Apr 2019 02:17:33 -0300 Subject: [PATCH 24/38] Added Anime and Manga commands New and shiny commands. Search for anime and manga via the Anilist API. --- assets/speech/en/fun.js | 3 +- assets/speech/en/general.js | 28 ++++++++++++++-- commands/General/anime.js | 67 +++++++++++++++++++++++++++++++++++++ commands/General/manga.js | 59 ++++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 commands/General/anime.js create mode 100644 commands/General/manga.js diff --git a/assets/speech/en/fun.js b/assets/speech/en/fun.js index ca27366..51d662d 100644 --- a/assets/speech/en/fun.js +++ b/assets/speech/en/fun.js @@ -1,6 +1,7 @@ exports.roll = { "zero": [ - "You can't roll from 0!" + "You can't roll from 0!", + "A die with 0 sides? You got to be joking." ], "negative": [ "You can't roll a negative number, baka!" diff --git a/assets/speech/en/general.js b/assets/speech/en/general.js index 3938b6e..af7744c 100644 --- a/assets/speech/en/general.js +++ b/assets/speech/en/general.js @@ -2,7 +2,31 @@ exports.anilist = [ //Missing search term "You forgot to include a search term!" ]; -exports.avatar = []; +exports.anime = { + "noSearch": [ + "You're missing a search term, baka!" + ], + "noResult": [ + "There's not an anime by that name!" + ], + "nsfw" : [ + "You can't search for hentai in a SFW channel!" + ] +}; + +exports.manga = { + "noSearch": [ + "You're missing a search term, baka!" + ], + "noResult": [ + "There's not a manga by that name!" + ], + "nsfw" : [ + "You can't search for hentai in a SFW channel!" + ] +}; + +exports.avatar = []; //Placeholder exports.award = { "noType": [ @@ -61,7 +85,7 @@ exports.info = { ] }; -exports.mal = []; +exports.mal = []; //Placeholder exports.report = { "start": [ diff --git a/commands/General/anime.js b/commands/General/anime.js new file mode 100644 index 0000000..ac0708f --- /dev/null +++ b/commands/General/anime.js @@ -0,0 +1,67 @@ +const fetch = require("node-fetch"); + +exports.run = async (client, msg, [term]) => { + if (!term) { return msg.channel.send(client.speech(msg, ["anime", "noSearch"])); } + var options = { + method: "POST", + headers: { "Content-Type": "application/json", "Accept": "application/json" }, + body: JSON.stringify({ query: `query ($id: Int, $page: Int, $perPage: Int, $search: String) { + Page (page: $page, perPage: $perPage) { + media (id: $id, search: $search, type:ANIME) { id idMal title { romaji english } description isAdult + coverImage { medium } siteUrl season startDate { year } episodes duration format status meanScore } + } }`, variables: { search: term, page: 1, perPage: 3 } }) + }; + var response = await fetch("https://graphql.anilist.co", options); + var json = await response.json(); + if (!json.data.Page.media) { return msg.channel.send(client.speech(msg, ["anime", "noResult"])); } + + const data = json.data.Page.media[0]; + + if (!msg.channel.nsfw && data.isAdult) { return msg.channel.send(client.speech(msg, ["anime, nsfw"])); } + + title = data.title.romaji + " "; + + if (data.title.english) { + title = title + "| " + data.title.english; + } + + const embed = new client.methods.Embed() + .setTitle(title) + .setColor(0x2E51A2) + .setTimestamp() + .setThumbnail(data.coverImage.medium) + .setFooter("Data pulled from AniList"); + + desc = `[Anilist](${data.siteUrl}) | [MyAnimeList](https://myanimelist.net/anime/${data.idMal})\n\n**Format:** `; + time = data.season.charAt(0) + data.season.substring(1).toLowerCase() + " " + data.startDate.year; + + if (data.format === "MOVIE") { + desc = desc + data.format.charAt(0) + data.format.substring(1).toLowerCase() + `\n**Released:** ${time}\n**Runtime:** ${data.duration} minutes\n`; + } + else { + desc = desc + `${data.format}\n**Season:** ${time}\n**Episodes:** ${data.episodes} (${data.duration} minutes per episode)\n`; + } + + desc = desc + `**Status:** ${data.status.charAt(0) + data.status.substring(1).toLowerCase()} + **Average Score:** ${data.meanScore} out of 100\n\n${data.description.replace(/
/g, "")}`; + + embed.setDescription(desc); + + msg.channel.send({embed}); +}; + +exports.conf = { + enabled: true, + runIn: ["text"], + aliases: [], + permLevel: 10, + botPerms: ["ATTACH_FILES"], + cooldown: 30 +}; + +exports.help = { + name: "anime", + description: "Search for anime on AniList.", + usage: "[term:str]", humanUse: "(Search term)", + extendedHelp: "There is a 30 second cooldown for searches to not spam the site." +}; \ No newline at end of file diff --git a/commands/General/manga.js b/commands/General/manga.js new file mode 100644 index 0000000..f487bee --- /dev/null +++ b/commands/General/manga.js @@ -0,0 +1,59 @@ +const fetch = require("node-fetch"); + +exports.run = async (client, msg, [term]) => { + if (!term) { return msg.channel.send(client.speech(msg, ["manga", "noSearch"])); } + var options = { + method: "POST", + headers: { "Content-Type": "application/json", "Accept": "application/json" }, + body: JSON.stringify({ query: `query ($id: Int, $page: Int, $perPage: Int, $search: String) { + Page (page: $page, perPage: $perPage) { + media (id: $id, search: $search, type:MANGA) { id idMal title { romaji english } description isAdult + coverImage { medium } siteUrl startDate { year } chapters volumes format status meanScore } + } }`, variables: { search: term, page: 1, perPage: 3 } }) + }; + var response = await fetch("https://graphql.anilist.co", options); + var json = await response.json(); + if (!json.data.Page.media) { return msg.channel.send(client.speech(msg, ["manga", "noResult"])); } + + const data = json.data.Page.media[0]; + + if (!msg.channel.nsfw && data.isAdult) { return msg.channel.send(client.speech(msg, ["manga, nsfw"])); } + + title = data.title.romaji + " "; + + if (data.title.english) { + title = title + "| " + data.title.english; + } + + chapCount = (data.status === "RELEASING") ? "" : `**Chapters:** ${data.chapters} - **Volumes:** ${data.volumes}\n`; + + const embed = new client.methods.Embed() + .setTitle(title) + .setColor(0x2E51A2) + .setTimestamp() + .setThumbnail(data.coverImage.medium) + .setFooter("Data pulled from AniList"); + + embed.setDescription(`[Anilist](${data.siteUrl}) | [MyAnimeList](https://myanimelist.net/anime/${data.idMal})\n\n**Format:** ` + + data.format.charAt(0) + data.format.substring(1).toLowerCase() + `\n**Released:** ${data.startDate.year}\n` + chapCount + + "**Status:** " + data.status.charAt(0) + data.status.substring(1).toLowerCase() + "**Average Score:** " + data.meanScore + + " out of 100\n\n" + data.description.replace(/
/g, "").replace(/—/g, "-")); + + msg.channel.send({embed}); +}; + +exports.conf = { + enabled: true, + runIn: ["text"], + aliases: [], + permLevel: 10, + botPerms: ["ATTACH_FILES"], + cooldown: 30 +}; + +exports.help = { + name: "manga", + description: "Search for manga on AniList.", + usage: "[term:str]", humanUse: "(Search term)", + extendedHelp: "There is a 30 second cooldown for searches to not spam the site." +}; \ No newline at end of file From 5da74817cc884ba3d9379b5fff3489cf3df24655 Mon Sep 17 00:00:00 2001 From: Yvain Hoekstra Date: Thu, 11 Jul 2019 10:36:40 -0400 Subject: [PATCH 25/38] Updated Speech Module Again Another rewrite coming for all commands that use the speechHelper. Utility now sends the message instead of the command. Also added edits to the monitors to ignore self and other bots. Anime and manga commands are no longer set to permission level 10 and use the AniList-Node package. --- assets/speech/en/general.js | 18 +++-- commands/General/anime.js | 25 ++----- commands/General/manga.js | 27 ++------ commands/System/about.js | 4 +- functions/musicCheck.js | 22 +++---- functions/transaction.js | 2 +- functions/userSearch.js | 8 ++- monitors/commandHelper.js | 12 ++-- monitors/linkdetector.js | 6 +- monitors/prefixHelp.js | 12 ++-- monitors/sweardetector.js | 12 ++-- package-lock.json | 128 +++++++++++++++++++++--------------- package.json | 5 +- utilities/speechHelper.js | 3 +- 14 files changed, 144 insertions(+), 140 deletions(-) diff --git a/assets/speech/en/general.js b/assets/speech/en/general.js index af7744c..42382e6 100644 --- a/assets/speech/en/general.js +++ b/assets/speech/en/general.js @@ -16,7 +16,8 @@ exports.anime = { exports.manga = { "noSearch": [ - "You're missing a search term, baka!" + "You're missing a search term, baka!", + "I need a title or something, baka! Come back with one!" ], "noResult": [ "There's not a manga by that name!" @@ -36,7 +37,8 @@ exports.award = { "Explain yourself on giving the award!" ], "noRow": [ - "That user has not gotten their first daily yet!" + "That user has not gotten their first daily yet!", + "That user doesn't seem to like my games. They haven't even claimed their first daily yet!" ], "success": [ "<@-id>, (-id) have been awarded -credits credits!" @@ -47,7 +49,8 @@ exports.calculate = []; exports.choose = [ "-user, I think that **-result** would be the best choice!", - "Hmm... looks like **-result** is the best option" + "Hmm... looks like **-result** is the best option", + "**-result** looks rather tempting. I'd pick that one." ]; exports.emoji = { @@ -67,7 +70,8 @@ exports.greet = { "How rude, -user! I'm not that lonely!" ], "success": [ - "Why hello there, -user!" + "Why hello there, -user!", + "Hello, -user! I hope you are doing well." ] }; @@ -98,14 +102,16 @@ exports.report = { "Next: Please provide a decently sized message explaining the item." ], "err1": [ - "You are not able to send todo reports. Only the bot owner can." + "You are not able to send todo reports. Only the bot owner can.", + "You found a secret command word! Too bad only the bot owner can go past this point. Try again with a different word." ], "timeout": { "t1": [ "You didn't provide me with a description in time. I recommend either making your report shorter or copy and pasting so that you don't have to try and type it so quickly." ], "t2": [ - "It seems you have timed out with making a report. When you are ready, feel free to try again!" + "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." ] } }; \ No newline at end of file diff --git a/commands/General/anime.js b/commands/General/anime.js index ac0708f..9b3895a 100644 --- a/commands/General/anime.js +++ b/commands/General/anime.js @@ -1,29 +1,16 @@ -const fetch = require("node-fetch"); +const AniListNode = require("anilist-node"); +const anilist = new AniListNode(); exports.run = async (client, msg, [term]) => { if (!term) { return msg.channel.send(client.speech(msg, ["anime", "noSearch"])); } - var options = { - method: "POST", - headers: { "Content-Type": "application/json", "Accept": "application/json" }, - body: JSON.stringify({ query: `query ($id: Int, $page: Int, $perPage: Int, $search: String) { - Page (page: $page, perPage: $perPage) { - media (id: $id, search: $search, type:ANIME) { id idMal title { romaji english } description isAdult - coverImage { medium } siteUrl season startDate { year } episodes duration format status meanScore } - } }`, variables: { search: term, page: 1, perPage: 3 } }) - }; - var response = await fetch("https://graphql.anilist.co", options); - var json = await response.json(); - if (!json.data.Page.media) { return msg.channel.send(client.speech(msg, ["anime", "noResult"])); } - - const data = json.data.Page.media[0]; + var data = await anilist.search("anime", term, 1, 3); + data = await anilist.media.anime(data.media[0].id); if (!msg.channel.nsfw && data.isAdult) { return msg.channel.send(client.speech(msg, ["anime, nsfw"])); } title = data.title.romaji + " "; - if (data.title.english) { - title = title + "| " + data.title.english; - } + if (data.title.english) { title = title + "| " + data.title.english; } const embed = new client.methods.Embed() .setTitle(title) @@ -54,7 +41,7 @@ exports.conf = { enabled: true, runIn: ["text"], aliases: [], - permLevel: 10, + permLevel: 0, botPerms: ["ATTACH_FILES"], cooldown: 30 }; diff --git a/commands/General/manga.js b/commands/General/manga.js index f487bee..f0943af 100644 --- a/commands/General/manga.js +++ b/commands/General/manga.js @@ -1,29 +1,16 @@ -const fetch = require("node-fetch"); +const AniListNode = require("anilist-node"); +const anilist = new AniListNode(); exports.run = async (client, msg, [term]) => { if (!term) { return msg.channel.send(client.speech(msg, ["manga", "noSearch"])); } - var options = { - method: "POST", - headers: { "Content-Type": "application/json", "Accept": "application/json" }, - body: JSON.stringify({ query: `query ($id: Int, $page: Int, $perPage: Int, $search: String) { - Page (page: $page, perPage: $perPage) { - media (id: $id, search: $search, type:MANGA) { id idMal title { romaji english } description isAdult - coverImage { medium } siteUrl startDate { year } chapters volumes format status meanScore } - } }`, variables: { search: term, page: 1, perPage: 3 } }) - }; - var response = await fetch("https://graphql.anilist.co", options); - var json = await response.json(); - if (!json.data.Page.media) { return msg.channel.send(client.speech(msg, ["manga", "noResult"])); } - - const data = json.data.Page.media[0]; + var data = await anilist.search("manga", term, 1, 3); + data = await anilist.media.manga(data.media[0].id); if (!msg.channel.nsfw && data.isAdult) { return msg.channel.send(client.speech(msg, ["manga, nsfw"])); } title = data.title.romaji + " "; - if (data.title.english) { - title = title + "| " + data.title.english; - } + if (data.title.english) { title = title + "| " + data.title.english; } chapCount = (data.status === "RELEASING") ? "" : `**Chapters:** ${data.chapters} - **Volumes:** ${data.volumes}\n`; @@ -36,7 +23,7 @@ exports.run = async (client, msg, [term]) => { embed.setDescription(`[Anilist](${data.siteUrl}) | [MyAnimeList](https://myanimelist.net/anime/${data.idMal})\n\n**Format:** ` + data.format.charAt(0) + data.format.substring(1).toLowerCase() + `\n**Released:** ${data.startDate.year}\n` + chapCount - + "**Status:** " + data.status.charAt(0) + data.status.substring(1).toLowerCase() + "**Average Score:** " + data.meanScore + + "**Status:** " + data.status.charAt(0) + data.status.substring(1).toLowerCase() + "\n**Average Score:** " + data.meanScore + " out of 100\n\n" + data.description.replace(/
/g, "").replace(/—/g, "-")); msg.channel.send({embed}); @@ -46,7 +33,7 @@ exports.conf = { enabled: true, runIn: ["text"], aliases: [], - permLevel: 10, + permLevel: 0, botPerms: ["ATTACH_FILES"], cooldown: 30 }; diff --git a/commands/System/about.js b/commands/System/about.js index 620b63f..deb8626 100644 --- a/commands/System/about.js +++ b/commands/System/about.js @@ -7,9 +7,9 @@ exports.run = async (client, msg) => { const embed = new client.methods.Embed() .setColor(0x37FDFC) - .setTitle("About Margarine") + .setTitle("About Me") .setDescription(`[Github](https://github.com/Butterstroke/MargarineBot) | [Terms Of Service](https://github.com/Butterstroke/MargarineBot/blob/master/TermsOfService.md) - \nI am a very helpful and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written in Komada, a Discord.js framework. + \nI am a very helpful and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written with Discord.js and Komada, a Discord.js framework. \n**Stats:** I have been online, helping out, for ${duration} using ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB of memory. ${client.users.size} users across ${client.guilds.size} guilds with ${client.channels.size.toLocaleString()} channels depend on my functions to be as reliable as possible! \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 the ${dateMaker(client.user.createdAt)} by Butterstroke#7150.`) diff --git a/functions/musicCheck.js b/functions/musicCheck.js index 4b8f473..971b638 100644 --- a/functions/musicCheck.js +++ b/functions/musicCheck.js @@ -1,19 +1,19 @@ module.exports = (msg, tag) => { - var result, speech; var client = msg.client; if (!msg.member.voice.channelID) { - result = false; - speech = client.speech(msg, ["func-music", "general", "userVC"]); + client.speech(msg, ["func-music", "general", "userVC"]); + return false; } else if (tag !== "join") { if (!client.music.get(msg.guild.id)) { - result = false; - speech = client.speech(msg, ["func-music", "general", "noQueue"]); + client.speech(msg, ["func-music", "general", "noQueue"]); + return false; } else if (msg.member.voice.channelID !== client.music.get(msg.guild.id).channel.id) { - result = false; - speech = client.speech(msg, ["func-music", "general", "mismatch"]); - } else { result = client.music.get(msg.guild.id); } - } else { result = true; } + client.speech(msg, ["func-music", "general", "mismatch"]); + return false; + } + + return client.music.get(msg.guild.id); + } - if(speech) { msg.channel.send(speech); } - return result; + return true; }; \ No newline at end of file diff --git a/functions/transaction.js b/functions/transaction.js index daf3d41..6cf9846 100644 --- a/functions/transaction.js +++ b/functions/transaction.js @@ -23,7 +23,7 @@ module.exports = (msg, amount, user, callback) => { } else if (!row) { text = "noRow"; } else if (row.credits < credits) { text = "lessCredit"; } - if (text) { msg.channel.send(client.speech(msg, ["func-transaction", "dbCheck", test])); return false; } + if (text) { client.speech(msg, ["func-transaction", "dbCheck", test]); return false; } db.run(`UPDATE users SET credits ="${amount + row.credits}" WHERE userId = "${user.id}"`); callback([true, row.credits, (row.credits + amount)]); diff --git a/functions/userSearch.js b/functions/userSearch.js index 807906e..c80d557 100644 --- a/functions/userSearch.js +++ b/functions/userSearch.js @@ -33,12 +33,14 @@ module.exports = async (client, msg, user, tags) => { } else { user = msg.guild.members.get(user); } if (user === null) { - msg.channel.send(client.speech(msg, ["func-userSearch", "default"])); + client.speech(msg, ["func-userSearch", "default"]); return false; } else if (user.user.bot === true && tags.includes("bot")) { - msg.channel.send(client.speech(msg, ["func-userSearch", tags[0]])); + client.speech(msg, ["func-userSearch", tags[0]]); return false; - } else { return user; } + } + + return user; }; module.exports.conf = { requiredModules: [] }; diff --git a/monitors/commandHelper.js b/monitors/commandHelper.js index 26952c2..a5b78b7 100644 --- a/monitors/commandHelper.js +++ b/monitors/commandHelper.js @@ -1,9 +1,3 @@ -exports.conf = { - enabled: true, - ignoreBots: false, - ignoreSelf: false, -}; - exports.run = (client, msg) => { switch (msg.content) { case "/shrug": @@ -24,3 +18,9 @@ exports.run = (client, msg) => { break; } }; + +exports.conf = { + enabled: true, + ignoreBots: true, + ignoreSelf: true, +}; \ No newline at end of file diff --git a/monitors/linkdetector.js b/monitors/linkdetector.js index 8c8f672..ac51e69 100644 --- a/monitors/linkdetector.js +++ b/monitors/linkdetector.js @@ -1,7 +1,7 @@ exports.conf = { - enabled: true, + enabled: false, ignoreBots: false, - ignoreSelf: false, + ignoreSelf: false }; exports.run = (client, message) => { @@ -11,6 +11,6 @@ exports.run = (client, message) => { return; } else if(message.content.includes(Link)) { message.delete(); - message.reply("No advertising links!"); + message.reply("No advertising links, baka!"); } }; diff --git a/monitors/prefixHelp.js b/monitors/prefixHelp.js index ade1a8a..5bb3e8e 100644 --- a/monitors/prefixHelp.js +++ b/monitors/prefixHelp.js @@ -1,11 +1,11 @@ -exports.conf = { - enabled: true, - ignoreBots: false, - ignoreSelf: false -}; - exports.run = (client, msg) => { if ((msg.content.startsWith(client.config.prefix)) && msg.channel.type === "text") { if ((client.config.prefix !== msg.guild.settings.prefix) && (msg.content === (client.config.prefix + "help"))) { return msg.channel.send(`Whoops! Looks like you are thinking of my default prefix. That is not the case here. Please use: ${msg.guild.settings.prefix}`); } else { return; } } }; + +exports.conf = { + enabled: true, + ignoreBots: true, + ignoreSelf: true +}; \ No newline at end of file diff --git a/monitors/sweardetector.js b/monitors/sweardetector.js index 03b8e59..85d1499 100644 --- a/monitors/sweardetector.js +++ b/monitors/sweardetector.js @@ -1,9 +1,3 @@ -exports.conf = { - enabled: true, - ignoreBots: false, - ignoreSelf: false, -}; - exports.run = (client, message) => { const swearWords = [/* Insert swearwords in here */]; var msg = message.content.toLowerCase(); @@ -12,3 +6,9 @@ exports.run = (client, message) => { message.reply("You shouldn't have said that!"); } }; + +exports.conf = { + enabled: false, + ignoreBots: false, + ignoreSelf: false, +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 636fc79..ed4abb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,14 @@ "uri-js": "^4.2.2" } }, + "anilist-node": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/anilist-node/-/anilist-node-1.1.0.tgz", + "integrity": "sha512-l15B3hReXnT0dfmTfLdXlHBKus1sYuM0A7VlOs3Smb/smxiNwOtfv3wjEw9TDeL7f/AU43DrpV3kLM4N61e0iQ==", + "requires": { + "node-fetch": "^2.2.0" + } + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -213,6 +221,7 @@ "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "optional": true, "requires": { "ms": "2.0.0" }, @@ -220,7 +229,8 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "optional": true } } }, @@ -251,7 +261,7 @@ "form-data": "^2.3.2", "node-fetch": "^2.1.2", "pako": "^1.0.0", - "prism-media": "github:amishshah/prism-media#1e336c9a20dd0928ef3bdc2075ab58d1521fb323", + "prism-media": "github:amishshah/prism-media", "setimmediate": "^1.0.5", "tweetnacl": "^1.0.0", "ws": "^6.0.0" @@ -358,9 +368,9 @@ } }, "fs-minipass": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", - "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", + "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", "requires": { "minipass": "^2.2.1" } @@ -404,9 +414,9 @@ } }, "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -604,9 +614,9 @@ } }, "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" }, "lowercase-keys": { "version": "1.0.1", @@ -670,9 +680,9 @@ } }, "minizlib": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.1.tgz", - "integrity": "sha512-TrfjCjk4jLhcJyGMYymBH6oTXcWjYbUAXTHDbtnWHjZC25h0cdajHuPE1zxb4DVmu8crfh+HwH/WMuyLG0nHBg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", "requires": { "minipass": "^2.2.1" } @@ -706,13 +716,23 @@ "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==" }, "needle": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", - "integrity": "sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz", + "integrity": "sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==", "requires": { - "debug": "^2.1.2", + "debug": "^3.2.6", "iconv-lite": "^0.4.4", "sax": "^1.2.4" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + } } }, "node-fetch": { @@ -732,9 +752,9 @@ } }, "node-pre-gyp": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz", - "integrity": "sha512-d1xFs+C/IPS8Id0qPTZ4bUT8wWryfR/OzzAFxweG+uLN85oPzyo2Iw6bVlLQ/JOdgNonXLCoRyqDzDWq4iw72A==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", + "integrity": "sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q==", "requires": { "detect-libc": "^1.0.2", "mkdirp": "^0.5.1", @@ -758,14 +778,14 @@ } }, "npm-bundled": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.5.tgz", - "integrity": "sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==" + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", + "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==" }, "npm-packlist": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.12.tgz", - "integrity": "sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.1.tgz", + "integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", "requires": { "ignore-walk": "^3.0.1", "npm-bundled": "^1.0.1" @@ -999,11 +1019,11 @@ } }, "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "safe-buffer": { @@ -1022,9 +1042,9 @@ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" }, "set-blocking": { "version": "2.0.0", @@ -1047,19 +1067,19 @@ "integrity": "sha512-dyycG9fvwtSJqKPfMVOpXt+60qvMGe7vWLwOJDiSJaiAx+hs2EnFChG2bXCWn7ulz+zGzrHdN9/yeEb0YqEPww==" }, "sqlite3": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-4.0.4.tgz", - "integrity": "sha512-CO8vZMyUXBPC+E3iXOCc7Tz2pAdq5BWfLcQmOokCOZW5S5sZ/paijiPOCdvzpdP83RroWHYa5xYlVqCxSqpnQg==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-4.0.8.tgz", + "integrity": "sha512-kgwHu4j10KhpCHtx//dejd/tVQot7jc3sw+Sn0vMuKOw0X00Ckyg9VceKgzPyGmmz+zEoYue9tOLriWTvYy0ww==", "requires": { - "nan": "~2.10.0", - "node-pre-gyp": "^0.10.3", + "nan": "^2.12.1", + "node-pre-gyp": "^0.11.0", "request": "^2.87.0" }, "dependencies": { "nan": { - "version": "2.10.0", - "resolved": "http://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" } } }, @@ -1118,17 +1138,17 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "tar": { - "version": "4.4.8", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", - "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", + "version": "4.4.9", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.9.tgz", + "integrity": "sha512-xisFa7Q2i3HOgfn+nmnWLGHD6Tm23hxjkx6wwGmgxkJFr6wxwXnJOdJYcZjL453PSdF0+bemO03+flAzkIdLBQ==", "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", + "minipass": "^2.3.5", + "minizlib": "^1.2.1", "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" + "yallist": "^3.0.3" }, "dependencies": { "safe-buffer": { @@ -1240,9 +1260,9 @@ } }, "yallist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", - "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" }, "youtube-playlist": { "version": "1.0.2", @@ -1254,9 +1274,9 @@ } }, "ytdl-core": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.28.2.tgz", - "integrity": "sha512-D9cjjE3qajIMqB/noJ05/PVPbzDxMoILq34Pe8QaCIgFpMBcBx88fEZWxXTZPDGlyUcbPGQ1pxQKKzV5QHhmgw==", + "version": "0.28.3", + "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.28.3.tgz", + "integrity": "sha512-PbUEY7viwO6mJjsZN3vpnjNfpB747rNva3YbOJ9iTM9MtDt2CFcZov4K3Agf22pt/EuPc4zKnk/97K7TeS04yw==", "requires": { "html-entities": "^1.1.3", "m3u8stream": "^0.6.2", diff --git a/package.json b/package.json index 366aec4..50ff024 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Javascript bot using the Komada framework", "main": "index.js", "dependencies": { + "anilist-node": "^1.1.0", "cheerio": "^1.0.0-rc.2", "discord.js": "github:hydrabolt/discord.js", "ffmpeg": "0.0.4", @@ -16,9 +17,9 @@ "querystring": "^0.2.0", "request": "^2.88.0", "snekfetch": "^4.0.4", - "sqlite3": "^4.0.4", + "sqlite3": "^4.0.8", "youtube-playlist": "^1.0.2", - "ytdl-core": "^0.28.2" + "ytdl-core": "^0.28.3" }, "devDependencies": {}, "repository": { diff --git a/utilities/speechHelper.js b/utilities/speechHelper.js index 629dcd1..be06772 100644 --- a/utilities/speechHelper.js +++ b/utilities/speechHelper.js @@ -13,6 +13,7 @@ module.exports = function(msg, keys) { var PATH = msg.client.clientBaseDir + "assets/speech/" + msg.guildSettings.lang + "/" + category + ".js"; if (fs.existsSync(PATH) === false) { + msg.channel.send("Whoops! Looks like I'm missing a file or two. Please contact the bot owner."); throw new Error("Localization file is missing.\nLanguage: " + msg.guildSettings.lang + "\nCategory: " + category + "\nCommand: " + name); } @@ -22,5 +23,5 @@ module.exports = function(msg, keys) { for (var x = n; x < keys.length; x++) { t = t[keys[x]]; } var text = t[Math.floor(Math.random() * t.length)]; var prefix = msg.guildSettings.prefix || msg.client.config.prefix; - return text.replace("-prefix", prefix); + msg.channel.send(text.replace("-prefix", prefix)); }; \ No newline at end of file From 2c85ca14adad12c6bd996816c96132bec6cfa1b9 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Tue, 24 Dec 2019 01:48:44 -0500 Subject: [PATCH 26/38] Prototype Released! Began migration to the Klasa framework. All system commands and ~50% of general commands are migrated over. Info is broken into 3 different commands now. All utilities are migrated. Usersearch migrated to an argument. No other functions are migrated at this point. Permissions are rewritten. No old commands are effected at the moment since they won't load into the new client. prefixHelp monitor migrated. All events removed to be reevaluated in the new client. --- .gitignore | 1 - README.md | 18 +- TermsOfService.md | 29 +- arguments/userSearch.js | 32 + assets/localization.json | 28 +- assets/settingsExample.json | 38 +- assets/speech.json | 163 ---- assets/speech/en-CA/cooking.js | 62 ++ assets/speech/en-CA/economy.js | 69 ++ assets/speech/{en => en-CA}/fun.js | 0 assets/speech/en-CA/games.js | 40 + assets/speech/en-CA/general.js | 137 ++++ assets/speech/en-CA/intChecker.js | 61 ++ assets/speech/en-CA/lessCredit.js | 6 + assets/speech/{en => en-CA}/music.js | 84 +- assets/speech/en-CA/noRow.js | 9 + assets/speech/{en => en-CA}/transaction.js | 0 assets/speech/{en => en-CA}/userSearch.js | 5 + assets/speech/en/general.js | 117 --- assets/values/items.json | 91 ++- commands/General/anilist.js | 87 +-- commands/General/avatar.js | 41 +- commands/General/choose.js | 39 +- commands/General/emoji.js | 75 +- commands/General/info.js | 72 -- commands/General/mal.js | 176 ++--- commands/General/roleinfo.js | 37 + commands/General/serverinfo.js | 34 + commands/General/userinfo.js | 70 ++ commands/System/about.js | 48 +- commands/System/exit.js | 39 +- commands/System/invite.js | 35 +- commands/System/permlevel.js | 62 +- commands/System/ping.js | 34 +- events/guildCreate.js | 13 - events/guildDelete.js | 1 - events/guildMemberAdd.js | 10 - events/guildMemberRemove.js | 8 - events/ready.js | 22 - functions/userSearch.js | 52 -- index.js | 66 +- monitors/commandHelper.js | 26 - monitors/prefixHelp.js | 29 +- package-lock.json | 867 +++++---------------- package.json | 32 +- utilities/commandRemover.js | 11 - utilities/dataManager.js | 97 +++ utilities/envCheck.js | 15 +- utilities/speechHelper.js | 24 +- utilities/utilExport.js | 4 +- 50 files changed, 1447 insertions(+), 1669 deletions(-) create mode 100644 arguments/userSearch.js delete mode 100644 assets/speech.json create mode 100644 assets/speech/en-CA/cooking.js create mode 100644 assets/speech/en-CA/economy.js rename assets/speech/{en => en-CA}/fun.js (100%) create mode 100644 assets/speech/en-CA/games.js create mode 100644 assets/speech/en-CA/general.js create mode 100644 assets/speech/en-CA/intChecker.js create mode 100644 assets/speech/en-CA/lessCredit.js rename assets/speech/{en => en-CA}/music.js (54%) create mode 100644 assets/speech/en-CA/noRow.js rename assets/speech/{en => en-CA}/transaction.js (100%) rename assets/speech/{en => en-CA}/userSearch.js (91%) delete mode 100644 assets/speech/en/general.js delete mode 100644 commands/General/info.js create mode 100644 commands/General/roleinfo.js create mode 100644 commands/General/serverinfo.js create mode 100644 commands/General/userinfo.js delete mode 100644 events/guildCreate.js delete mode 100644 events/guildDelete.js delete mode 100644 events/guildMemberAdd.js delete mode 100644 events/guildMemberRemove.js delete mode 100644 events/ready.js delete mode 100644 functions/userSearch.js delete mode 100644 monitors/commandHelper.js delete mode 100644 utilities/commandRemover.js create mode 100644 utilities/dataManager.js diff --git a/.gitignore b/.gitignore index 25b2a45..3cb7343 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ node_modules/ .vs/ .vscode/ bwd/ -assets/data/ assets/settings.json \ No newline at end of file diff --git a/README.md b/README.md index 8cce68d..7bc08cc 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ -# MargarineBot - Version: Release 1.0 -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f0cfd83063a4469b8e40bcc824c2600d)](https://www.codacy.com/app/Butterstroke/MargarineBot?utm_source=github.com&utm_medium=referral&utm_content=Butterstroke/MargarineBot&utm_campaign=Badge_Grade) ![License](https://img.shields.io/github/license/Butterstroke/MargarineBot.svg?style=flat-square) +# MargarineBot - Version: Release 1.0 (Klasa Rewrite - Beta) +![License](https://img.shields.io/github/license/Butterstroke/MargarineBot.svg?style=flat-square) ![Support Server](https://discordapp.com/api/guilds/303253034551476225/widget.png) Dependencies -![discord.js](https://img.shields.io/badge/discord.js-v12.0.0--dev-brightgreen.svg) ![komada](https://img.shields.io/badge/Komada-v0.21.1-brightgreen.svg) ![node](https://img.shields.io/badge/Node-v8.0.0+-brightgreen.svg) +![discord.js](https://img.shields.io/badge/discord.js-v12.0.0--dev-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) -A Discord bot coded in Node.js using the Discord.js Library and the Komada framework. +A Discord bot coded in Node.js using the Discord.js Library and the Klasa framework. Introduction: -Created through part-desire, part-what can I do in Discord, part-I'm going to learn Javascript, and part-it's only 12 am thoughts, Margarine has been my personal project for several months now. For the amount of time and effort I've spent on developing him, I'm quite proud of the functionality and features that I've put into him. I have received plenty of support over the months of developing him and I can't thank those people enough as without that support, Margarine would have never been as big or as good as he is today. I hope that you enjoy either looking at/learning/using 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 12 am thoughts, Margarine has been my personal project for several years now. For the amount of time and effort I've spent on developing him, I'm quite proud of the functionality and features that I've put into him. I have received plenty of support over his development and I can't thank those people enough as without that support, Margarine would have never been as big or as good as he is today. I hope that you enjoy either looking at/learning/using Margarine as much as I do. *Name Origin:* My typical nickname is Butter, as in the stuff that you put on toast. His name comes from the artificial butter (I tends to call it 'Fake Butter') you can buy in stores called, Margarine. @@ -18,7 +19,12 @@ Created through part-desire, part-what can I do in Discord, part-I'm going to le - Fun, small games like Rock, Paper, Scissors - Server/User/role info commands - Economy system using a SQLite database -- Music commands (Play your favourite tunes through Youtube!) Invite me! Not available at the current moment as the bot is in development. + +Contact + +For issues, please use the issue tracker on this repository. + +For any thing else, either contact me by email katsurinstudios@protonmail.ch or through Discord at Butterstroke#7150. diff --git a/TermsOfService.md b/TermsOfService.md index f676327..bf41f83 100644 --- a/TermsOfService.md +++ b/TermsOfService.md @@ -1,32 +1,38 @@

Margarine's Terms of Service

The agreements for the users of Margarine due to Discord's Developer Terms of Service (Defined as Discord TOS). -**Last Updated:** 20 December, 2018 +**Last Updated:** 22 November 2019 **Usage:** By using Margarine, users agree to have their information usable and manipulated for improving and general use of Margarine. Any data collected will be collected anonymously and, in most cases, not stored. -There are two levels of data agreement in which users can interact with Margarine. The first level of data agreement is labeled as "having Margarine in the same Discord guild that the user is in". By inviting Margarine into the guild, all users within the guild agree to the first level. The only data stored at this first level is all of the guild configuration settings and a temporary cache of each user which is handled with the Discord.js library, a required package that allows Margarine to communicate with Discord's API. Margarine uses the "master" branch of this library and for further questions about the library can be directed appropriately on their GitHub page linked here: https://github.com/discordjs/discord.js. +There are two stages of data agreement in which users can interact with Margarine. -The second level of data agreement is labeled as "users who have used the daily command at least once". Since Margarine is not allowed to store user data without explicit permission from the user as part of Discord TOS, the daily command is a way for users to give such permission to store data. The daily command sets up a user profile which contains items such as: credits, reputation points, profile names, and similar items. Any profile names are stored with user's permission as they will set it to their own via a separate command. All user information will be stored under their unique Discord ID. Some commands like the daily and rep command will also store the timestamp in which the user used the command last for the sole purpose of validating a wait period. +By inviting Margarine into the guild, all users within the guild agree to the first stage. Data stored about the users on this stage is any guild configuration settings, any temporary data like a music queue provided by Margarine's own commands, and any temporary cache of the user handled by the Discord.js library. Discord.js is a required package which allows Margarine to communicate with Discord's API. Margarine uses the "master" branch of this library which can be seen and provided by through their Github page linked here: https://github.com/discordjs/discord.js. -All credits, reputation points, and inventory items are generated and hold no real monetary value. They are purely for entertainment and users who use credits, reputation points, or inventory items for real monetary sales and profits are to be reported and blacklisted. +Users who have used Margarine's daily command at least once agree to the second stage. As apart of Discord's TOS, users need to give Margarine explicit permission to store user data outside of Discord. The daily command is a way to ensure that the user agrees to such permissions. The daily command sets up a user profile with can contain items such as: virtual currency (credits), reputation points, usernames for other profiles, etc... Any usernames for other sites are stored with the user's permission via other appropriate commands. All user information is stored under their unique Discord ID. -The report command falls under a special category as Margarine takes the user's Discord ID and tag for feedback. Under Discord TOS, this doesn't require any other permission as feedback is sent from the user to Margarine's developer Discord guild where the developer can view, read, and act upon the feedback. Therefore, it stays within Discord and no other actions are required of the data. If abused, the user may be blacklisted from the command. +All credits, reputation points, and inventory items are generated and hold no real monetary value. They are purely for entertainment and users who use credits, reputation points, or inventory items for real monetary sales and profits are to be reported. -**Developer Usage:** -For users of the developer version of Margarine, a command may be reload with `console.log()` to check variables as they pass through the command. This data is not stored, however, users of the developer version are required to know and accept that their data maybe logged for developmental reason during fixes and improvements. +Users are generally asked to make reports about any issues or feedback of Margarine through its report command. Under Discord TOS, this doesn't require any permission from the user as all information is stored exclusively on Discord. + +**Developer Version Usage:** + +For users of the developer version of Margarine, a command may be reload with `console.log()` to check variables as they pass through the command. This data is not stored, however, users are required to know and accept that their data maybe logged for developmental reason during any fixes and/or improvements. **Data Requests and Removal:** -Users may contact the developer for the current user profile on Margarine at any time using the contact information defined in the contact section. The user's information will be sent to them in the most convenient way for both parties and decrypted for general viewing. After the profile has been received, the developer will delete the sent file 48-72 hours later and any leak from that file will be up to the user's responsibility and discretion. -If the user wants for their user profile to be deleted for whatever reason, they may message the people in the contact section below. However, once deleted, there is no way to recover the lost data. The exception to this rule is in cases of self-hosting, in which the user must send their request to the person responsible for the hosted instance. +Any users may contact the developer for their data on Margarine at any time using the contact information defined in the contact section. The user information will be sent to them in the most convenient way for both partied and decrypted for general viewing. After the data has been received, the developer will delete the sent file 48-72 hours later. The data received is up to the user's responsibility and discretion. + +For users who want their user profile deleted, they may message the developer in the contact section below. The data will be deleted with no questions asked. However, users should be warned that there is no way to recover the lost data once deleted. For self-hosted versions of Margarine, the user must send their request to the person responsible for the hosted instance. **Self-Hosting** + For any issues relating to a self-hosted instance of Margarine, the user must send their requests to the person responsible for the self-hosting. The developer is not responsible for any misuse conducted by the self-hosted instances of the program. However, if general questions about Margarine do arise, please see the Contact section of the terms for information on how to get in touch with the developer. **Disclaimer:** -If for any reason Margarine needs to store more data, these terms will change with notice in future releases. If users are using the developer version of Margarine, these terms may change overnight. The developer(s) will try to pass the news on quickly, however, cannot guarantee that the news will be current before the changes happen. Any questions based on recent changes, please refer to the Contact section of this file. + +If for any reason Margarine needs to store more data, these terms will change with notice in future releases. If users are using the developer version of Margarine, these terms may change overnight. The developer will try to pass the news on quickly, however, cannot guarantee that the news will be current before the changes happen. Any questions based on recent changes, please refer to the Contact section of this file. The developer of Margarine does not knowingly know of any stored data of users under the age of 13. If a user under the age of 13 is found with data on Margarine, the data will be deleted and the user will be reported to Discord. @@ -39,4 +45,5 @@ Users are aware and agree to the following terms defined above. They are also aw Users are aware and agree to the following terms defined above. They are also aware that changes in the Terms of Service can change overnight and will be notified of these changes as soon as humanly possible. Users are also aware of the potential of `console.log()` in which data will be logged for development purposes defined in the Developer Usage section. **Contact:** -For any questions, complaints, etc... either message Butterstroke#7150 via Discord or send me an email at konirosen@protonmail.ch. + +For any questions, complaints, etc... either message Butterstroke#7150 via Discord or send me an email at katsurinstudios@protonmail.ch. diff --git a/arguments/userSearch.js b/arguments/userSearch.js new file mode 100644 index 0000000..f0327bc --- /dev/null +++ b/arguments/userSearch.js @@ -0,0 +1,32 @@ +const { Argument, util: { regExpEsc } } = require("klasa"); +const IDRegex = /^((<@!)|())(\d{17,21})((>)|())$/; + +/* Possible user detection: + * <@!303236614623068161> (Mention) + * 303236614623068161 (User ID) + * Butterstroke (Username) + * Butter (Guild nickname) + */ + +module.exports = class extends Argument { + constructor(...args) { + super(...args, { aliases: ["usersearch"] }); + } + + async run(arg, possible, msg) { + if (arg === undefined) { return msg.author; } + if (IDRegex.test(arg)) { return this.client.users.get(/(\d{17,21})/.exec(arg)[0]); } + + var regex = new RegExp(regExpEsc(arg), "i"); + var results = msg.guild.members.filter(m => regex.test(m.user.username)); + + if (results.size == 0) { + msg.channel.send(this.client.speech(msg, ["func-userSearch", "default"])); + return null; + } + + return this.client.users.get(results.keys().next().value); + + //Check for bot user and if the command doesn't allow bots. + } +} \ No newline at end of file diff --git a/assets/localization.json b/assets/localization.json index e4dc85d..6cc7dcd 100644 --- a/assets/localization.json +++ b/assets/localization.json @@ -1,27 +1,9 @@ { - "permLevels": { - "general": [ - "Level 0: Everyone", - "Level 1: Placeholder", - "Level 2: Guild Moderators", - "Level 3: Guild Admins", - "Level 4: Guild Owners", - "Level 5: Placeholder", "Level 6: Placeholder", "Level 7: Placeholder", "Level 8: Placeholder", - "Level 9: Toast & Butter", - "Level 10: Bot Owner" - ], - "addPerms": [ - "with no additional permissions", - "Placeholder", - "with guild moderator permissions", - "with guild admin permissions", - "with guild owner permissions" - ] - }, "games": [ ["Playing around with Butterstroke", "play"], ["Hacking to the gate", "listen"], - ["Rewatching Occultic;Nine.", "watch"], + ["Rewatching Occultic;Nine", "watch"], + ["Rewatching Robotics;Notes", "watch"], ["Harvesting wild fruits", "play"], ["Partying to weeb tunes", "listen"], ["Breaking all of the code", "play"], @@ -31,6 +13,10 @@ ["Writing for Kiri Kiri Basara", "play"], ["Playing around with wires", "play"], ["Cooking up a fantastic meal!", "play"], - ["Crafting a brand new world", "play"] + ["Crafting a brand new world", "play"], + ["Having a romance comedy to myself!", "play"], + ["Reaching for the blue sky", "play"], + ["Someday, surely, for the sake of illuminating someone's path, I want to shine", "listen"], + ["Considering the possibilities of being an isekai protagonist", "play"] ] } \ No newline at end of file diff --git a/assets/settingsExample.json b/assets/settingsExample.json index d67ea48..ce70f02 100644 --- a/assets/settingsExample.json +++ b/assets/settingsExample.json @@ -1,15 +1,15 @@ { - "token": "", - "ownerID": "", - "prefix": "", + "token": "Token Key", + "ownerID": "User ID", + "prefix": "Prefix", "build": { - "version": "Release 1.0", - "releaseDate": "TBD" + "version": "Release 1.0 - Klasa Rewrite (Developer)", + "releaseDate": "December 24th, 2019" }, "owner": { "channels": { - "award": "", - "report": "" + "award": "Channel ID", + "report": "Channel ID" }, "awards": { "suggest": 250, @@ -18,9 +18,23 @@ "major": 2000 } }, - "database": { - "general": "./assets/data/general.sqlite", - "inv": "./assets/data/inventory.sqlite", - "user": "./assets/data/users.sqlite" + "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" + ] } -} +} \ No newline at end of file diff --git a/assets/speech.json b/assets/speech.json deleted file mode 100644 index fa74722..0000000 --- a/assets/speech.json +++ /dev/null @@ -1,163 +0,0 @@ -{ - "intChecker": { - "none": { - "credit": [ - "You didn't supply me with an amount of credits, baka!", - "Credits? Hello? I need an amount of credits!" - ], - "craft": [ - "You can't craft nothing, baka!", - "Wow. Crafting nothing, I see. Got nothing else to do?" - ], - "default": [ - "You didn't include a value here, baka!", - "No value, no results, baka!", - "A man once said you always have value in life. Apparently, you can't spread some of that wealth into your command." - ] - }, - "negative": { - "credit": [ - "You can't bet a negative amount of credits!", - "What are you trying to do? Steal someone's credits? That's illegal, you know.", - "Robbing a bank would reel you in more credits than gambling negative credits." - ], - "craft": [ - "You can't craft a negative number, baka!", - "You're better off selling your raw items than crafting a negative amount." - ], - "default": [ - "No negative values in this established command, baka!", - "Negatives? Here? HA! You're really funny!" - ] - }, - "zero": { - "credit": [ - "You can't use zero credits here! Bet some *actual* credits and then we'll talk.", - "...wow, I didn't know you were that oblivious to gambling credits. You don't bet **nothing**, baka!" - ], - "craft": [ - "Why are you even crafting, baka!", - "Tell me the answer of 0/0 and then I'll craft you 0 of that item." - ], - "default": [ - "We've divided by zero. It didn't go so well...", - "Zero is an evil number. Don't give me these evils to work with." - ] - }, - "noInteger": { - "credit": [ - "There is no decimal work in credits! Whole credits only.", - "You can't split a credit! Give me a whole number, baka!" - ], - "craft": [ - "You can't have a part of something, baka!", - "Uh... you want to craft half of an item? I don't think that will work out well for you." - ], - "default": [ - "Decimals? That's like giving me fraction work. No thanks!", - "Decimals: fun to look at, not possible with what you are trying to do.", - "The only decimals I like to look at is in human currency. My credits are not that so keep them away!" - ] - } - }, - "noRow": [ - "You haven't redeemed your first daily yet! :cry:", - "You haven't signed up and received your credits yet! D:", - "You need some credits to do this, baka! Get some with the daily command!", - "Credits speak a whole lot of value in these parts. Set yourself up with a daily command first!", - "Get yourself some credits first!", - "Where are your credits?! Oh. You haven't redeemed your first daily yet...", - "Oh... you didn't redeem your first daily yet..." - ], - "lessCredit": [ - "You don't have that many credits, baka!", - "A poor person like yourself could never afford that bet.", - "Try paying in dirt. It's worth more than your bank right now.", - "Try to pull a fast one on me? Too bad you can't afford it, baka!" - ], - "userSearch": { - "balance": [ - "Bots can't have any records!", - "Bots aren't allowed to have bank accounts. They could hack them easily at this point.", - "You are lucky I don't have one because then I'd show you the true power of business!" - ], - "daily": [ - "You can't give your credits to a bot user, baka!", - "Bots don't have records within our bank to take dailies!", - "What is the bot going to do with all of these credits? It's more useful not to take a daily at this point." - ], - "rep": [ - "You can't give rep to a bot user. However, as long as you keep interacting with them, I'm sure they will be happy! :smile:", - "Bots can't have rep, baka!", - "A bot's reputation is on how well you like it. It doesn't need points to show it." - ], - "exchange": [ - "You can't give your credits to a bot user!", - "Exchanging to a bot user is just not possible. They are known to do foul things with money from time to time.", - "Nope! No can do. Bots can't have credits." - ], - "award": [ - "Awarding a non-existant user? Wow, I think we've hit a new low here.", - "Fake users don't get awards, baka!", - "Are you trying to funnel some extra credits through a false user again?" - ], - "ecoedit": [ - "Trying to edit some credits on a fake account? Not on my watch, baka!", - "A fake account is a fake account. There is nothing else to do here." - ], - "default": [ - "Whatever you are trying to find, it's not typed right or it doesn't exist.", - "Where is the user? I don't know but not any location where I can find it!", - "I couldn't find the user! Give me a better thing to search with, baka!", - "Another non-existant user? Really?", - "... There isn't a user here, baka!", - "You say user, I say doesn't exist. Baka!" - ] - }, - "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!" - ], - "noRow": [ - "That user hasn't redeemed their first daily yet! :cry:", - "Sadly, that user does not like my games and didn't redeem their first daily yet." - ], - "badDaily": [ - "Nani?!?! You can't give other people credits if you haven't recieved your first daily yet!", - "You have not gotten your first daily yet!", - "You aren't in my records. You should redeem your first daily before giving to others.", - "Earn a bit yourself with the daily command before giving to others!" - ], - "multi": [ - "You are trying to cheat my daily command! Rude!", - "You've already redeemed a daily today, baka!", - "You have already redeemed your daily for today.", - "No stealing! I already payed your daily worth of credits today, baka!" - ] - }, - "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-." - ], - "fish": [ - "-user1-, you have caught -fish-.", - "Looks like -user1- just caught a -fish-.", - "Nice catch! You just caught yourself -fish-." - ], - "craft": [ - "You have crafted -num- -item-.", - "-num- -item- has been successfully crafted and added to your inventory.", - "-num- brand new -item- is now in your inventory." - ] -} \ No newline at end of file diff --git a/assets/speech/en-CA/cooking.js b/assets/speech/en-CA/cooking.js new file mode 100644 index 0000000..2eb637c --- /dev/null +++ b/assets/speech/en-CA/cooking.js @@ -0,0 +1,62 @@ +exports.craft = { + "noItem": [ + "You need to define an item to craft, baka!" + ], + "noRecipe": [ + "I couldn't find a recipe like that!" + ], + "noRow": [ + "You need to redeem your first daily before you can do this, baka!" + ], + "lackAmount": [ + "You do not have enough -item! Please refer to the crafting guide to find out how much you need." + ], + "success": [ + "Oh! You've crafted -amount of -item!" + ] +}; + +exports.fish = { + "noRow": [ + "It doesn't look like you've redeemed your first daily yet. You should do that and then come back." + ], + "noCredits": [ + "That's not enough credits to go fishing. Find some more and come back." + ], + "success": [ + "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." + ] +}; + +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 = [ + "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 = { + "noRow": [ + "You need to redeem your first daily before this!" + ], + "noAmount": [ + "You don't have enough of this to sell!" + ], + "success": [ + "Success! You've sold -amount of -item for -price!" + ] +}; \ No newline at end of file diff --git a/assets/speech/en-CA/economy.js b/assets/speech/en-CA/economy.js new file mode 100644 index 0000000..56903cc --- /dev/null +++ b/assets/speech/en-CA/economy.js @@ -0,0 +1,69 @@ +/*Speech for all commands in the general economy section*/ + +exports.balance = [ //Only case is when there is no user in the system + "Looks like this person has yet to redeem their first daily!", + "This person doesn't exist in my systems. Have they redeemed their first daily yet? Do they even like my games?", + "Oh... it looks like this person doesn't care for my games... they should redeem their first daily if they want to play.", +]; + +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!" + ], + "noRow": [ + "That user hasn't redeemed their first daily yet! :cry:", + "Sadly, that user does not like my games and didn't redeem their first daily yet." + ], + "noAccount": [ + "Nani?!?! You can't give other people credits if you haven't recieved your first daily yet!", + "You have not gotten your first daily yet!", + "You aren't in my records. You should redeem your first daily before giving to others.", + "Earn a bit yourself with the daily command before giving to others!" + ], + "multi": [ + "You are trying to cheat my daily command! Rude!", + "You've already redeemed a daily today, baka!", + "You have already redeemed your daily for today.", + "No stealing! I already payed your daily worth of credits today, baka!" + ] +}; + +exports.exchange = { + "self": [ + "Why are you trying to exchange credits to yourself? I doubt you are that lonely in life.", + "Oh? Trying to see if I would exchange your own credits? BAKA!" + ], + "default": [ + "-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 = { + "sameUser": [ + "You can't rep yourself! That's a bunch of nonsense!" + ], + "noSelfRow": [ + "Oh dear. You haven't redeemed your first daily yet..." + ], + "noCooldown": [ + "You can't rep someone yet! It hasn't been a full day yet!" + ], + "noTargetRow": [ + "Oh dear. That user hasn't redeemed their first daily yet..." + ], + "success": [ + "You have given -mention a reputation point!" + ] +}; diff --git a/assets/speech/en/fun.js b/assets/speech/en-CA/fun.js similarity index 100% rename from assets/speech/en/fun.js rename to assets/speech/en-CA/fun.js diff --git a/assets/speech/en-CA/games.js b/assets/speech/en-CA/games.js new file mode 100644 index 0000000..8658cba --- /dev/null +++ b/assets/speech/en-CA/games.js @@ -0,0 +1,40 @@ +exports.noRow = [ + "Oh no! You haven't redeemed your first daily yet! You should do that and then come back.", + "Seems like you haven't redeemed your first daily yet. Go and do that, you'll be able to play my games then." +]; + +exports.noCredits = [ + "You don't have enough credits to make that bet!", + "That's an awfully high bet for someone who can't afford it." +]; + +exports.chouhan = { + "win": [ + "**Sum:** -sum \n**Guess:** -guess \nYou have won -earning credits!" + ], + "lose": [ + "**Sum:** -sum \n**Guess:** -guess \nYou have lost -earning credits." + ] +}; + +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!" + ] +}; \ No newline at end of file diff --git a/assets/speech/en-CA/general.js b/assets/speech/en-CA/general.js new file mode 100644 index 0000000..76641c8 --- /dev/null +++ b/assets/speech/en-CA/general.js @@ -0,0 +1,137 @@ +exports.anilist = [ //Missing search term + "You forgot to include a search term!", + "Here is your result for nothing: \" \". Give me a search term next time, baka!" +]; + +exports.anime = { + "noSearch": [ + "You're missing a search term, baka!" + ], + "noResult": [ + "There's not an anime by that name!" + ], + "nsfw" : [ + "You can't search for hentai in a SFW channel!", + "Keep your porn out of the safe for work channels, baka!" + ] +}; + +exports.manga = { + "noSearch": [ + "You're missing a search term, baka!", + "I need a title or something, baka! Come back with one!", + "Searching for nothing... Oh wait. I don't have to. Give me a search term next time, baka!" + ], + "noResult": [ + "There's not a manga by that name!", + "Good news! You can use that for your next upcoming book! There isn't a manga by that name." + ], + "nsfw" : [ + "You can't search for hentai in a SFW channel!", + "Porn belongs in the porn channels. Not in a safe for work channel." + ] +}; + +exports.avatar = []; //Placeholder + +exports.award = { + "noType": [ + "BAKA! I need a type of an award!", + "But, what kind of award are you giving someone? You never provided me with one!" + ], + "noText": [ + "Explain yourself on giving the award!", + "Tell me a story. Express yourself. Or just explain why you are giving an award. That works too." + ], + "noRow": [ + "That user has not gotten their first daily yet!", + "That user doesn't seem to like my games. They haven't even claimed their first daily yet!", + "Looks like that user doesn't have a profile. Sad. No rewards for them." + ], + "success": [ //Parameter 1: User id, Parameter 2: Awarded Credits + "<@-id>, (-id) have been awarded -credits credits!", + "<@-param1>, (-param1) has been awarded -param2 credits!", + "Congratulations <@-param1> (-param1)! You've been awarded -param2 credits!" + ] +}; + +exports.calculate = []; + +exports.choose = { + "lackChoice": [ + "There's not a lot of options here, is there?", + "Choosing requires two or more options, baka!", + "Just pick the option that's not competing with any others! You only have one choice there, baka!" + ], + "success": [ + "-user, I think that **-result** would be the best choice!", + "Hmm... looks like **-result** is the best option", + "**-result** looks rather tempting. I'd pick that one.", + "Why did was it so hard to choose? **-result** is obviously the best choice, -user!" + ] +}; + +exports.emoji = { + "noName": [ + "You need a name of an emote to search with, baka!" + ], + "noID": [ + "You need to specify a message's ID so that I can find it!" + ], + "badName": [ + "Type the emote's name right and try again, baka!" + ] +}; + +exports.greet = { + "me": [ //Parameter 1: Username + "How rude, -param1! I'm not that lonely!", + "Trying to make me seem lonely. Bad -param1!" + ], + "success": [ //Parameter 1L Username + "Why hello there, -param1!", + "Hello, -param1! I hope you are doing well.", + "And good day to you, -param1!" + ] +}; + +exports.help = []; + +exports.serverinfo = []; //Placeholder +exports.userinfo = []; //Placeholder + +exports.roleinfo = [ + "Looks like I can't find the role. Be sure it is spelled correctly.", + "Are you sure that exists? I don't think it does." +]; + +exports.mal = []; //Placeholder + +exports.report = { + "start": [ + "I'm going to be asking a couple of questions so I'll be taking this into your DMs.", + "Time for a questionaire! I'll be asking a couple questions in your DMs." + ], + "q1": [ + "Alright. Let's get to the point. First question: What kind of issue is this?\nPlease answer `issue`, `bug`, `complaint`, or `suggestion`", + "What kind of issue are we talking about?\nPlease answer `issue`, `bug`, `complaint`, or `suggestion`" + ], + "q2": [ + "Next: Please provide a decently sized message explaining the issue.", + "Next, I'm going to need a decently sized message explaining the issue." + ], + "err1": [ + "You are not able to send todo reports. Only the bot owner can.", + "You found a secret command word! Too bad only the bot owner can go past this point. Try again with a different word." + ], + "timeout": { + "t1": [ + "You didn't provide me with a description in time. I recommend either making your report shorter or copy pasting so that you don't have to try and type it so quickly.", + "Looks like you timed out but don't worry. Take your time finishing your message and then try again. I recommending copy pasting so you don't have to speed type it." + ], + "t2": [ + "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." + ] + } +}; \ No newline at end of file diff --git a/assets/speech/en-CA/intChecker.js b/assets/speech/en-CA/intChecker.js new file mode 100644 index 0000000..ecae543 --- /dev/null +++ b/assets/speech/en-CA/intChecker.js @@ -0,0 +1,61 @@ +module.exports = { + "none": { + "credit": [ + "You didn't supply me with an amount of credits, baka!", + "Credits? Hello? I need an amount of credits!" + ], + "craft": [ + "You can't craft nothing, baka!", + "Wow. Crafting nothing, I see. Got nothing else to do?" + ], + "default": [ + "You didn't include a value here, baka!", + "No value, no results, baka!", + "A man once said you always have value in life. Apparently, you can't spread some of that wealth into your command." + ] + }, + "negative": { + "credit": [ + "You can't bet a negative amount of credits!", + "What are you trying to do? Steal someone's credits? That's illegal, you know.", + "Robbing a bank would reel you in more credits than gambling negative credits." + ], + "craft": [ + "You can't craft a negative number, baka!", + "You're better off selling your raw items than crafting a negative amount." + ], + "default": [ + "No negative values in this established command, baka!", + "Negatives? Here? HA! You're really funny!" + ] + }, + "zero": { + "credit": [ + "You can't use zero credits here! Bet some *actual* credits and then we'll talk.", + "...wow, I didn't know you were that oblivious to gambling credits. You don't bet **nothing**, baka!" + ], + "craft": [ + "Why are you even crafting, baka!", + "Tell me the answer of 0/0 and then I'll craft you 0 of that item." + ], + "default": [ + "We've divided by zero. It didn't go so well...", + "Zero is an evil number. Don't give me these evils to work with." + ] + }, + "noInteger": { + "credit": [ + "There is no decimal work in credits! Whole credits only.", + "You can't split a credit! Give me a whole number, baka!" + ], + "craft": [ + "You can't have a part of something, baka!", + "Uh... you want to craft half of an item? I don't think that will work out well for you." + ], + "default": [ + "Decimals? That's like giving me fraction work. No thanks!", + "Decimals: fun to look at, not possible with what you are trying to do.", + "The only decimals I like to look at is in human currency. My credits are not that so keep them away!" + ] + } +}; \ No newline at end of file diff --git a/assets/speech/en-CA/lessCredit.js b/assets/speech/en-CA/lessCredit.js new file mode 100644 index 0000000..9aa0720 --- /dev/null +++ b/assets/speech/en-CA/lessCredit.js @@ -0,0 +1,6 @@ +exports.lessCredit = [ + "You don't have that many credits, baka!", + "A poor person like yourself could never afford that bet.", + "Try paying in dirt. It's worth more than your bank right now.", + "Try to pull a fast one on me? Too bad you can't afford it, baka!" +]; \ No newline at end of file diff --git a/assets/speech/en/music.js b/assets/speech/en-CA/music.js similarity index 54% rename from assets/speech/en/music.js rename to assets/speech/en-CA/music.js index 994858e..c0e8bac 100644 --- a/assets/speech/en/music.js +++ b/assets/speech/en-CA/music.js @@ -1,19 +1,23 @@ exports.join = { "noConnect": [ - ":x: I do not have enough permissions to connect to your voice channel. I am missing the connect permission. (You may want to check if I can speak in that channel too :wink:)" + ":x: I do not have enough permissions to connect to your voice channel. I am missing the connect permission. (You may want to check if I can speak in that channel too :wink:)", + "Huh, looks like I do not have the permissions to connect to your voice channel. I'm currently missing the connect permission. (You should check if I can also speak in the channel too!)" ], "noSpeak": [ - "Wow. Invite me to play music for you, yet I can't speak in the channel. You are more heartless than my owner. Give me the channel permission to speak and then try again." + "Wow. Invite me to play music for you, yet I can't speak in the channel. You are more heartless than my owner. Give me the channel permission to speak and then try again.", + "Yikes. I've been given the silent treatment. I can't speak in your channel! Please give me the permission to speak and then try again!" ], - "success": [ - "Now tuned into: -channel. Ready and awaiting orders!", - "Preparing the DJ station in -channel. Now ready for your requested songs!" + "success": [ //Parameter 1: Voice channel name + "Now tuned into: -param1. Ready and awaiting orders!", + "Preparing the DJ station in -param1. Now ready for your requested songs!", + "-param1 is ready to receive your requested songs! All we need now is some music!" ] }; -exports.leave = [ - "I have left -channel.", - "The party is now over in -channel." +exports.leave = [ //Parameter 1: Voice channel name. + "I have left -param1.", + "The party is now over in -param1.", + "Thanks for the fun! I've cleaned up and have left -param1." ]; exports.nowplaying = { @@ -22,9 +26,10 @@ exports.nowplaying = { "The queue is as existant as your waifu right now. You should add some songs." ], "notPlay": [ - "Hmm... good question. None of the above. I am not playing anything right now!" - ], - "success": [/*Placeholder as this is not needed currently*/] + "Hmm... good question. None of the above. I am not playing anything right now!", + "There isn't any music playing right now.", + "But... it's silent. Nothing is playing!" + ] }; exports.pause = { @@ -33,7 +38,8 @@ exports.pause = { "The stream is already paused, baka!" ], "success": [ - "āø The mix is now paused." + "āø The mix is now paused.", + "Poof! Just like that, your tunes are paused! āø" ] }; @@ -48,14 +54,16 @@ exports.play = { "BAKA! There is no music in your queue!" ], //Nothing to play "allDone": [ - "Looks like my job is done. Add more songs or kick me out of the channel. It doesn't matter to me, baka." + "Looks like my job is done. Add more songs or kick me out of the channel. It doesn't matter to me, baka.", + "Job's done! Time to add more songs or kick me out." ], //No more to play - "nextSong": [ - "šŸ“» Playing -request's request: **-title**" + "nextSong": [ //Parameter 1: Requester, Parameter 2: Song title + "šŸ“» Playing -param1's request: **-param2**", + "šŸ“» Now listening to **-param2**, requested by -param1!" ] //Next song playing }; -exports.queue = [ +exports.queue = [ //Parameter 1: Page count "I can't show you that page for its page number is greater than my queue pages. There are currently -pgs", "Your number is higher than -pgs. So, there is nothing to see there." ]; @@ -63,36 +71,44 @@ exports.queue = [ exports.queueadd = { "noURL": [ "You must provide me with a valid Youtube URL, BAKA!", - "What is this? This is not a URL I requested!" + "What is this? This is not a URL I requested!", + "Wha- This isn't a Youtube URL! BAKA!" ], "listDetect": [ "Looks like you want a playlist. Hold tight, this may take awhile." ], - "success": [ - "šŸŽµ Added **-title** to the queue šŸŽ¶", - "šŸŽ§ **-title** has been added to the queue" + "errCatch": [ //Parameter 1: Youtube ID + "Whoops! Looks like I can't access this video. " ], - "multi": [ - "šŸŽµ Added **-number** songs to the queue šŸŽ¶", - "I've finished adding **-number** songs to the queue. Time for a break." + "success": [ //Parameter 1: Song title + "šŸŽµ Added **-param1** to the queue šŸŽ¶", + "šŸŽ§ **-param1** has been added to the queue" + ], + "multi": [ //Parameter 1: Number of songs + "šŸŽµ Added **-param1** songs to the queue šŸŽ¶", + "I've finished adding **-param1** songs to the queue. Time for a break." ] }; exports.remove = { "noInt": [ - "I only have songs queued in integers. Come back with a whole number, will you?" + "I only have songs queued in integers. Come back with a whole number, will you?", + "This isn't a number... Come back with a number, baka!" ], - "success": [ - "**-title** has been removed from the queue." + "success": [ //Parameter 1: Song title + "**-param1** has been removed from the queue.", + "Okay! **-param1** has been removed from the queue." ] }; exports.resume = { "noPause": [ - "The stream isn't paused at the moment." + "The stream isn't paused at the moment.", + "Huh? I'm playing music right now." ], "success": [ - "ā–¶ Now resuming your tunes. Keep partying!" + "ā–¶ Now resuming your tunes. Keep partying!", + "Time to start partying again! I've resumed your tunes." ] }; @@ -102,9 +118,9 @@ exports.skip = [ ]; exports.volume = { - "noArgs": [ - "šŸ“¢ Volume: -vol%", - "Currently playing at -vol%" + "noArgs": [ //Parameter 1: volume + "šŸ“¢ Volume: -param1%", + "Currently playing at -param1%" ], "zero": [ "You might as well mute me if you don't want any noise." @@ -115,9 +131,9 @@ exports.volume = { "notPlay": [ "Kind of hard to adjust the volume if I am not playing music." ], - "success": [ - "-action the volume! Volume: -vol%", - "-action the volume to -vol% as requested!" + "success": [ //Parameter 1: Action, Parameter 2: volume + "-param1 the volume! Volume: -param2%", + "-param1 the volume to -param2% as requested!" ] }; diff --git a/assets/speech/en-CA/noRow.js b/assets/speech/en-CA/noRow.js new file mode 100644 index 0000000..41595ba --- /dev/null +++ b/assets/speech/en-CA/noRow.js @@ -0,0 +1,9 @@ +exports.noRow = [ + "You haven't redeemed your first daily yet! :cry:", + "You haven't signed up and received your credits yet! D:", + "You need some credits to do this, baka! Get some with the daily command!", + "Credits speak a whole lot of value in these parts. Set yourself up with a daily command first!", + "Get yourself some credits first!", + "Where are your credits?! Oh. You haven't redeemed your first daily yet...", + "Oh... you didn't redeem your first daily yet..." +]; \ No newline at end of file diff --git a/assets/speech/en/transaction.js b/assets/speech/en-CA/transaction.js similarity index 100% rename from assets/speech/en/transaction.js rename to assets/speech/en-CA/transaction.js diff --git a/assets/speech/en/userSearch.js b/assets/speech/en-CA/userSearch.js similarity index 91% rename from assets/speech/en/userSearch.js rename to assets/speech/en-CA/userSearch.js index 78dfc60..e57a342 100644 --- a/assets/speech/en/userSearch.js +++ b/assets/speech/en-CA/userSearch.js @@ -40,4 +40,9 @@ exports.default = [ "Another non-existant user? Really?", "... There isn't a user here, baka!", "You say user, I say doesn't exist. Baka!" +]; + +exports.noGuild = [ + "B-baka! I can't find a user here with that term!", + "We're not in a guild right now... how do you expect me to find a user like that in here!" ]; \ No newline at end of file diff --git a/assets/speech/en/general.js b/assets/speech/en/general.js deleted file mode 100644 index 42382e6..0000000 --- a/assets/speech/en/general.js +++ /dev/null @@ -1,117 +0,0 @@ -exports.anilist = [ //Missing search term - "You forgot to include a search term!" -]; - -exports.anime = { - "noSearch": [ - "You're missing a search term, baka!" - ], - "noResult": [ - "There's not an anime by that name!" - ], - "nsfw" : [ - "You can't search for hentai in a SFW channel!" - ] -}; - -exports.manga = { - "noSearch": [ - "You're missing a search term, baka!", - "I need a title or something, baka! Come back with one!" - ], - "noResult": [ - "There's not a manga by that name!" - ], - "nsfw" : [ - "You can't search for hentai in a SFW channel!" - ] -}; - -exports.avatar = []; //Placeholder - -exports.award = { - "noType": [ - "BAKA! I need a type of an award!" - ], - "noText": [ - "Explain yourself on giving the award!" - ], - "noRow": [ - "That user has not gotten their first daily yet!", - "That user doesn't seem to like my games. They haven't even claimed their first daily yet!" - ], - "success": [ - "<@-id>, (-id) have been awarded -credits credits!" - ] -}; - -exports.calculate = []; - -exports.choose = [ - "-user, I think that **-result** would be the best choice!", - "Hmm... looks like **-result** is the best option", - "**-result** looks rather tempting. I'd pick that one." -]; - -exports.emoji = { - "noName": [ - "You need a name of an emote to search with, baka!" - ], - "noID": [ - "You need to specify a message's ID so that I can find it!" - ], - "badName": [ - "Type the emote's name right and try again, baka!" - ] -}; - -exports.greet = { - "me": [ - "How rude, -user! I'm not that lonely!" - ], - "success": [ - "Why hello there, -user!", - "Hello, -user! I hope you are doing well." - ] -}; - -exports.help = []; - -exports.info = { - "role": [ - "Looks like I can't find the role. Be sure it is spelled correctly." - ], - "server": [ - "You can't ask information about a server with additional stuff!" - ], - "noTerm": [ - "You didn't give a correct search term. Do either server, user, or role." - ] -}; - -exports.mal = []; //Placeholder - -exports.report = { - "start": [ - "I'm going to be asking a couple of questions so I'll be taking this into the DMs." - ], - "q1": [ - "Alright. Let's get to the point. First question: What kind of issue is this?\nPlease answer `issue`, `bug`, `complaint`, or `suggestion`" - ], - "q2": [ - "Next: Please provide a decently sized message explaining the item." - ], - "err1": [ - "You are not able to send todo reports. Only the bot owner can.", - "You found a secret command word! Too bad only the bot owner can go past this point. Try again with a different word." - ], - "timeout": { - "t1": [ - "You didn't provide me with a description in time. I recommend either making your report shorter or copy and pasting so that you don't have to try and type it so quickly." - ], - "t2": [ - "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." - ] - } -}; \ No newline at end of file diff --git a/assets/values/items.json b/assets/values/items.json index d0bbad4..566bf9a 100644 --- a/assets/values/items.json +++ b/assets/values/items.json @@ -1,126 +1,131 @@ { "info": { "item_structure": { - "price": ["buy", "sell"], + "sell": 0, "name": "item_name", "emote": "item_emote", - "category": ["item_major", "item_minor"] - }, - "material_names": ["info", "trash", "fish", "crab", "squid", "shark", "potato", "egg", "bread", "chocolate", "greenapple", "apple", "lemon", "sake", "rice"], - "product_names": ["fishcake", "cookie", "oden", "sushi", "recycle"] + "category": "Table in DB", + "subcategory": "Any subcategory of the table" + } }, "trash": { - "price": ["N/A", 0], + "sell": 0, "name": "trash", "emote": "šŸ—‘", - "category": ["material", "misc"] + "category": "fishing", + "subcategory": "misc" }, "fish": { - "price": ["N/A", 5], + "sell": 5, "name": "fish", "emote": "šŸŸ", - "category": ["material", "fishing"] + "category": "fishing" }, "crab": { - "price": ["N/A", 15], + "sell": 15, "name": "crab", "emote": "šŸ¦€", - "category": ["material", "fishing"] + "category": "fishing" }, "squid": { - "price": ["N/A", 25], + "sell": 25, "name": "squid", "emote": "šŸ¦‘", - "category": ["material", "fishing"] + "category": "fishing" }, "shark": { - "price": ["N/A", 75], + "sell": 75, "name": "shark", "emote": "šŸ¦ˆ", - "category": ["material", "fishing"] + "category": "fishing" }, "potato": { - "price": ["N/A", 15], + "sell": 15, "name": "potato", "emote": "šŸ„”", - "category": ["material", "harvest"] + "category": "harvest" }, "egg": { - "price": ["N/A", 5], + "sell": 5, "name": "egg", "emote": "šŸ„š", - "category": ["material", "harvest"] + "category": "harvest" }, "bread": { - "price": ["N/A", 15], + "sell": 15, "name": "bread", "emote": "šŸž", - "category": ["material", "harvest"] + "category": "harvest" }, "chocolate": { - "price": ["N/A", 15], + "sell": 15, "name": "chocolate", "emote": "šŸ«", - "category": ["material", "harvest"] + "category": "harvest" }, "greenapple": { - "price": ["N/A", 10], + "sell": 10, "name": "green apple", "emote": "šŸ", - "category": ["material", "harvest"] + "category": "harvest" }, "apple": { - "price": ["N/A", 10], + "sell": 10, "name": "apple", "emote": "šŸŽ", - "category": ["material", "harvest"] + "category": "harvest" }, "lemon": { - "price": ["N/A", 15], + "sell": 15, "name": "lemon", "emote": "šŸ‹", - "category": ["material", "harvest"] + "category": "harvest" }, "sake": { - "price": ["N/A", 25], + "sell": 25, "name": "sake", "emote": "šŸ¶", - "category": ["material", "harvest"] + "category": "harvest" }, "rice": { - "price": ["N/A", 10], + "sell": 10, "name": "rice", "emote": "šŸš", - "category": ["material", "harvest"] + "category": "harvest" }, "fishcake": { - "price": ["N/A", 30], + "sell": 30, "name": "fishcake", "emote": "šŸ„", - "category": ["product", "food"] + "category": "product", + "subcategory": "food" }, "cookie": { - "price": ["N/A", 25], + "sell": 25, "name": "cookie", "emote": "šŸŖ", - "category": ["product", "food"] + "category": "product", + "subcategory": "food" }, "oden": { - "price": ["N/A", 125], + "sell": 125, "name": "oden", "emote": "šŸ¢", - "category": ["product", "food"] + "category": "product", + "subcategory": "food" }, "sushi": { - "price": ["N/A", 75], + "sell": 75, "name": "sushi", "emote": "šŸ£", - "category": ["product", "food"] + "category": "product", + "subcategory": "food" }, "recycle": { - "price": ["N/A", 44], + "sell": 44, "name": "recycle", "emote": "ā™»", - "category": ["product", "misc"] + "category": "product", + "subcategory": "misc" } } \ No newline at end of file diff --git a/commands/General/anilist.js b/commands/General/anilist.js index 5f05816..90c37b7 100644 --- a/commands/General/anilist.js +++ b/commands/General/anilist.js @@ -1,51 +1,46 @@ -const fetch = require("node-fetch"); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); +const AnilistNode = require("anilist-node"); +const anilist = new AnilistNode(); -exports.run = async (client, msg, [term]) => { - if (!term) { return msg.channel.send(client.speech(msg, ["anilist"])); } - var options = { - method: "POST", - headers: { "Content-Type": "application/json", "Accept": "application/json" }, - body: JSON.stringify({ query: `query ($name: String) { User(name: $name) { avatar { large } siteUrl - stats { watchedTime chaptersRead animeListScores { meanScore } mangaListScores { meanScore } - animeStatusDistribution { amount } mangaStatusDistribution { amount } } - } }`, variables: { name: term } }) - }; - var response = await fetch("https://graphql.anilist.co", options); - var json = await response.json(); - if (!json.data.User.stats) { return msg.channel.send("Anilist profile by that user is not found!"); } - var data = json.data.User, - anime = data.stats.animeStatusDistribution, - manga = data.stats.mangaStatusDistribution; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "anilist", + enabled: true, + runIn: ["text"], + cooldown: 60, + aliases: [], + requiredPermissions: ["ATTACH_FILES"], + description: "Fetch a data's profile on AniList", + usage: "[term:str]", + extendedHelp: "There is a 60 second cooldown for each profile search to not spam the site." + }); + } - var animeL = ["šŸ’š Watching: " + anime[0].amount, "šŸ—“ Planned: " + anime[1].amount, "šŸ’™ Completed: " + anime[2].amount, "šŸ’” Dropped: " + anime[3].amount, "šŸ’› Paused: " + anime[4].amount]; - var mangaL = ["šŸ“— Reading: " + manga[0].amount, "šŸ—“ Planned: " + manga[1].amount, "šŸ“˜ Completed: " + manga[2].amount, "šŸ“• Dropped: " + manga[3].amount, "šŸ“™ Paused: " + manga[4].amount]; + async run(msg, [term]) { + if (!term) { return msg.channel.send(this.client.speech(msg, ["anilist"])); } - const embed = new client.methods.Embed() - .setTitle(term + "'s AniList Profile") - .setURL(data.siteUrl) - .setDescription("šŸ•“ Watch Days: " + Number(data.stats.watchedTime / 60 / 24).toFixed(1) + "\nšŸ”– Manga Chapters: " + data.stats.chaptersRead) - .addField("__Anime:__", "šŸ“Š Mean Score: " + data.stats.animeListScores.meanScore + "\n" + animeL.join("\n"), true) - .addField("__Manga:__", "šŸ“Š Mean Score: " + data.stats.mangaListScores.meanScore + "\n" + mangaL.join("\n"), true) - .setTimestamp() - .setColor(0x2E51A2) - .setThumbnail(data.avatar.large) - .setFooter("Requested by: " + msg.author.tag); + var data = await anilist.user.all(term); + + if (data.status === 404) { return msg.channel.send("Anilist profile by that user is not found!"); } + var anime = data.stats.animeStatusDistribution, + manga = data.stats.mangaStatusDistribution; + + var animeL = ["šŸ’š Watching: " + anime[0].amount, "šŸ—“ Planned: " + anime[1].amount, "šŸ’™ Completed: " + anime[2].amount, "šŸ’” Dropped: " + anime[3].amount, "šŸ’› Paused: " + anime[4].amount]; + var mangaL = ["šŸ“— Reading: " + manga[0].amount, "šŸ—“ Planned: " + manga[1].amount, "šŸ“˜ Completed: " + manga[2].amount, "šŸ“• Dropped: " + manga[3].amount, "šŸ“™ Paused: " + manga[4].amount]; + + const embed = new MessageEmbed() + .setTitle(term + "'s AniList Profile") + .setURL(data.siteUrl) + .setDescription("šŸ•“ Watch Days: " + Number(data.stats.watchedTime / 60 / 24).toFixed(1) + "\nšŸ”– Manga Chapters: " + data.stats.chaptersRead) + .addField("__Anime:__", "šŸ“Š Mean Score: " + data.stats.animeListScores.meanScore + "\n" + animeL.join("\n"), true) + .addField("__Manga:__", "šŸ“Š Mean Score: " + data.stats.mangaListScores.meanScore + "\n" + mangaL.join("\n"), true) + .setTimestamp() + .setColor(0x2E51A2) + .setThumbnail(data.avatar.large) + .setFooter("Requested by: " + msg.author.tag); - msg.channel.send({embed}); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: ["ATTACH_FILES"], - cooldown: 60 -}; - -exports.help = { - name: "anilist", - description: "Fetch a data's profile on AniList", - usage: "[term:str]", humanUse: "(AniList profile name)", - extendedHelp: "There is a 60 second cooldown for each profile search to not spam the site." + msg.channel.send({embed}); + } }; \ No newline at end of file diff --git a/commands/General/avatar.js b/commands/General/avatar.js index 976d95d..aceefce 100644 --- a/commands/General/avatar.js +++ b/commands/General/avatar.js @@ -1,22 +1,21 @@ -exports.run = async (client, msg, [user]) => { - client.funcs.userSearch(client, msg, user).then(data => { - if (data !== false) { - msg.channel.send("", { files: [data.user.displayAvatarURL()]}); - } - }); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: ["ATTACH_FILES"], - requiredFuncs: ["userSearch"] -}; - -exports.help = { - name: "avatar", - description: "Fetch a user's avatar!", - usage: "[user:str]" +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "avatar", + enabled: true, + runIn: ["text"], + cooldown: 0, + aliases: [], + requiredPermissions: ["ATTACH_FILES"], + description: "Fetch a user's avatar!", + usage: "[user:usersearch]", + }); + } + + async run(msg, [user]) { + if (user == null) { return; } + msg.channel.send("", { files: [user.displayAvatarURL()]}); + } }; \ No newline at end of file diff --git a/commands/General/choose.js b/commands/General/choose.js index 2c8004c..f546dca 100644 --- a/commands/General/choose.js +++ b/commands/General/choose.js @@ -1,19 +1,22 @@ -exports.run = async (client, msg, [...choice]) => { - var results = choice[(Math.ceil(Math.random() * choice.length) - 1)]; - msg.channel.send(client.speech(msg, ["choose"]).replace("-user", msg.author.username).replace("-result", results)); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["choice"], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "choose", - description: "The one stop picker for hard choices!", - usage: "[choice:str] [...]", usageDelim: " | ", - humanUse: "(choice)_(another one)_(etc...)" +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "choose", + enabled: true, + runIn: ["text"], + cooldown: 0, + aliases: ["choice"], + description: "The one stop picker for hard choices!", + usage: "[choice:str] [...]", usageDelim: " | " + }); + } + + async run(msg, [...choice]) { + if (choice.length < 2) { return msg.channel.send(client.speech(msg, ["choose", "lackChoice"])); } + + var numChoice = Math.floor(Math.random() * choice.length); + msg.channel.send(this.client.speech(msg, ["choose", "success"], [["-user", msg.author.username], ["-result", choice[numChoice]]])); + } }; \ No newline at end of file diff --git a/commands/General/emoji.js b/commands/General/emoji.js index 21b242f..5000098 100644 --- a/commands/General/emoji.js +++ b/commands/General/emoji.js @@ -1,39 +1,4 @@ -exports.run = async (client, msg, [Name, ID]) => { - const prefix = msg.guild.settings.prefix || client.config.prefix; - - if (msg.channel.permissionsFor(client.user).has("MANAGE_MESSAGES")) { msg.delete(); } - if (!Name) { return errMsg(msg, "noName"); } - if (msg.content.slice(prefix.length).startsWith("react") && (!ID)) { return errMsg(msg, "noID"); } - if (Name.startsWith("<")) { Name = Name.slice(2, -20); } - - let emotes = Array.from(client.emojis); - let emoji = emotes.filter((element) => { - if (element[1].name === Name) { return element; } - }); - - try { var type = emoji[0][1].animated === true ? "gif" : "png"; } - catch(err) { return errMsg(msg, "badName"); } - - if (msg.content.slice(prefix.length).startsWith("react")) { - msg.channel.messages.fetch(ID).then(msg => msg.react(client.emojis.get(emoji[0][0]))); - } else { msg.channel.send({files: [`https://cdn.discordapp.com/emojis/${emoji[0][0]}.${type}`]}); } -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["see", "emote", "react"], - permLevel: 0, - botPerms: ["ATTACH_FILES", "ADD_REACTIONS"] -}; - -exports.help = { - name: "emoji", - description: "Displays an enlargened emoji.", - usage: "[Name:str] [messageID:str]", usageDelim: " ", - extendedHelp: "Bring in your pool of emotes from other servers! Either use the big image or use the alias of react and add a message ID to react to a message instead!", - humanUse: "(name)_([If reacting] messageID)" -}; +const { Command } = require("klasa"); function errMsg(msg, type) { msg.channel.send(msg.client.speech(msg, ["emoji", type])).then(msg => { @@ -41,4 +6,40 @@ function errMsg(msg, type) { setTimeout(() => { msg.delete(); }, 4000); } }); -} \ No newline at end of file +} + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "emoji", + enabled: true, + runIn: ["text"], + cooldown: 0, + aliases: ["emote", "see", "react"], + requiredPermissions: ["ATTACH_FILES", "ADD_REACTIONS"], + description: "Bring in your pool of emotes from other servers! Either use the big image or use the alias of react and add a message ID to react to a message instead!", + usage: "[Name:str] [messageID:str]", usageDelim: " " + }); + } + + async run(msg, [Name, messageID]) { + const prefix = msg.guild.settings.prefix; + + if (msg.channel.permissionsFor(this.client.user).has("MANAGE_MESSAGES")) { msg.delete(); } + if (!Name) { return errMsg(msg, "noName"); } + if (msg.content.slice(prefix.length).startsWith("react") && (!ID)) { return errMsg(msg, "noID"); } + if (Name.startsWith("<")) { Name = Name.slice(2, -20); } + + let emotes = Array.from(this.client.emojis); + let emoji = emotes.filter((element) => { + if (element[1].name === Name) { return element; } + }); + + try { var type = emoji[0][1].animated === true ? "gif" : "png"; } + catch(err) { return errMsg(msg, "badName"); } + + if (msg.content.slice(prefix.length).startsWith("react")) { + msg.channel.messages.fetch(ID).then(msg => msg.react(this.client.emojis.get(emoji[0][0]))); + } else { msg.channel.send({files: [`https://cdn.discordapp.com/emojis/${emoji[0][0]}.${type}`]}); } + } +}; \ No newline at end of file diff --git a/commands/General/info.js b/commands/General/info.js deleted file mode 100644 index 639c0b4..0000000 --- a/commands/General/info.js +++ /dev/null @@ -1,72 +0,0 @@ -exports.run = async (client, message, [kind, search]) => { - let guild = message.guild; - let msg = (message.content.startsWith("<")) ? message.content.slice(client.user.id.length + 4).split(" ") : message.content.slice(2).split(" "); - - var x = (msg[0] === "info") ? 1 : 0; - var kind = msg[x]; var user = msg.slice(x + 1).join(" "); - - const embed = new client.methods.Embed() - .setTimestamp() - .setFooter(guild.name, guild.iconURL()); - - switch (kind) { - case "user": - user = await client.funcs.userSearch(client, message, user); - if (user === false) { return; } - - const statusList = { - online: "online", - idle: "idle", - dnd: "on do not disturb mode" - }; - - var Status = statusList[user.presence.status] || "offline"; - var activity = user.presence.activity !== null ? " while playing " + user.presence.activity.name: " "; - - embed.setThumbnail(user.user.displayAvatarURL()) - .setAuthor(user.user.tag + " | " + user.id) - .setDescription("Currently " + Status + activity) - .addField("Created:", user.user.createdAt.toLocaleString(), true) - .addField("Joined:", user.joinedAt.toLocaleString(), true) - .addField("Bot user:", user.bot ? "True": "False", true); break; - case "role": - var role; - guild.roles.forEach(element => { if (element.name.toLowerCase() === user.toLowerCase()) { role = element; } }); - if (!role) { return message.channel.send(client.speech(message, ["info", "role"])); } - - embed.addField("Role:", `${role.name} - ${role.id}`) - .addField("Position:", role.position, true) - .addField("Hex Colour:", role.hexColor, true) - .addField("Users:", role.members.size, true); break; - case "server": - if (user) { return message.reply(client.speech(message, ["info", "server"])); } - - embed.setThumbnail(guild.iconURL()) - .addField("Region:", guild.region, true) - .addField("Created:", guild.createdAt.toLocaleString(), true) - .addField("Owner:", `${guild.owner.user.tag} - ${guild.owner.id}`) - .addField("Members:", `${guild.memberCount - guild.members.filter(m => m.user.bot).size} (${guild.members.filter(m => m.user.bot).size} bots)`, true) - .addField("Roles:", guild.roles.size, true); break; - default: return message.channel.send(client.speech(message, ["info", "noTerm"])); - }; - - embed.setColor((kind === "role") ? role.hexColor : 0x04d5fd); - message.channel.send({embed}); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["server", "role", "user"], - permLevel: 0, - botPerms: [], - requiredFuncs: ["userSearch"] -}; - -exports.help = { - name: "info", - description: "Get the server, role, or user information.", - usage: "[server|user|role] [search:str]", usageDelim: " ", - extendedHelp: "Need Discord info? I got you covered with this command!", - humanUse: "([If not specified] server|user|role)_(search content)" -}; \ No newline at end of file diff --git a/commands/General/mal.js b/commands/General/mal.js index 1083e22..fbce407 100644 --- a/commands/General/mal.js +++ b/commands/General/mal.js @@ -1,103 +1,105 @@ +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); const cheerio = require("cheerio"); const request = require("request"); -exports.run = async (client, msg, [term]) => { - const url = "https://myanimelist.net/profile/"; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "mal", + enabled: true, + runIn: ["text"], + cooldown: 60, + aliases: ["choice"], + requiredPermissions: ["ATTACH_FILES"], + description: "Fetch a user's profile on MyAnimeList", + usage: "[term:str]", + extendedHelp: "There is a 60 second cooldown for each profile search to not spam the MAL site." + }); + } - request(url + term, function(err, res, body) { - $ = cheerio.load(body); - var text = $.text().split(" "); var x = 0; var info = { aStats: {}, mStats: {} }; + async run(msg, [term]) { + const url = "https://myanimelist.net/profile/"; - do { - var z = text[x].trim(); var y = text[x + 1] ? text[x + 1].trim() : ""; var zed = text[x + 2] ? text[x + 2].trim() : ""; - if (z + y + zed === "404NotFound") { return msg.channel.send("Whoops! Looks like a user by that name does not exist."); } - else if (z.length > 1) { - if (z.startsWith("Online")) { - if (zed.startsWith("ago")) { info.status = z.slice(6) + " " + y + " ago"; } - else if (z.startsWith("OnlineNow")) { info.status = z.slice(6, z.search("Gender")); } - else if (zed.includes(":")) { info.status = z.slice(6) + " " + y + " " + (new Date()).getFullYear(); } - else if (z.includes("Yesterday") || z.includes("Today") && zed.slice(1, 2) === "M") { - info.status = z.slice(6, -1) + " at " + y + zed.slice(0, 2); - } - else if (isNaN(zed) === false) { info.status = z.slice(6) + " " + y + " " + zed; } - } if (z.includes("Birthday") && !info.birthday) { - var num = (z.length - z.search("Birthday")) * (-1); - if (y.includes("Location")) { var baka = y.slice(0, y.search("Location")); } - else { var baka = y.slice(-1) === "," ? y + " " + zed.slice(0, 4) : y; } - info.birthday = z.slice(num + 8) + " " + baka; - } if (z.includes("Gender")) { - var amount = (z.search("Birthday")) ? z.search("Birthday") : null; + request(url + term, function(err, res, body) { + var loadBody = cheerio.load(body); + var text = loadBody.text().split(" "); var x = 0; 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() : ""; + if (z + y + zed === "404NotFound") { return msg.channel.send("Whoops! Looks like a user by that name does not exist."); } + else if (z.length > 1) { + if (z.startsWith("Online")) { + if (zed.startsWith("ago")) { info.status = z.slice(6) + " " + y + " ago"; } + else if (z.startsWith("OnlineNow")) { info.status = z.slice(6, z.search("Gender")); } + else if (zed.includes(":")) { info.status = z.slice(6) + " " + y + " " + (new Date()).getFullYear(); } + else if (z.includes("Yesterday") || z.includes("Today") && zed.slice(1, 2) === "M") { + info.status = z.slice(6, -1) + " at " + y + zed.slice(0, 2); + } + else if (isNaN(zed) === false) { info.status = z.slice(6) + " " + y + " " + zed; } + } if (z.includes("Birthday") && !info.birthday) { + var num = (z.length - z.search("Birthday")) * (-1); + if (y.includes("Location")) { var baka = y.slice(0, y.search("Location")); } + else { var baka = y.slice(-1) === "," ? y + " " + zed.slice(0, 4) : y; } + info.birthday = z.slice(num + 8) + " " + baka; + } if (z.includes("Gender")) { + var amount = (z.search("Birthday")) ? z.search("Birthday") : null; - if (z.startsWith("ago")) { var amount2 = 9; } - else if (z.startsWith("AM") || z.startsWith("PM")) { var amount2 = 8; } - else { var amount2 = 15; } + if (z.startsWith("ago")) { var amount2 = 9; } + else if (z.startsWith("AM") || z.startsWith("PM")) { var amount2 = 8; } + else { var amount2 = 15; } - info.gender = z.slice(amount2, amount); - } else if (z.startsWith("Watching") || z.startsWith("Reading")) { - if (!info.aStats.watch || !info.mStats.read) { - var num = [z.search("Completed"), z.search("On-Hold"), z.search("Dropped")]; + info.gender = z.slice(amount2, amount); + } else if (z.startsWith("Watching") || z.startsWith("Reading")) { + if (!info.aStats.watch || !info.mStats.read) { + var num = [z.search("Completed"), z.search("On-Hold"), z.search("Dropped")]; - var butter = !info.aStats.watch ? "aStats" : "mStats"; - info[butter].completed = z.slice(num[0] + 9, num[1]); - info[butter].hold = z.slice(num[1] + 7, num[2]); - info[butter].drop = z.slice(num[2] + 7, -4); + var butter = !info.aStats.watch ? "aStats" : "mStats"; + info[butter].completed = z.slice(num[0] + 9, num[1]); + info[butter].hold = z.slice(num[1] + 7, num[2]); + info[butter].drop = z.slice(num[2] + 7, -4); - if (butter === "aStats") { - info.aStats.watch = z.slice(8, num[0]); - info.aStats.plan = zed.slice(5, -5); - } else { - info.mStats.read = z.slice(7, num[0]); - info.mStats.plan = zed.slice(4, -5); + if (butter === "aStats") { + info.aStats.watch = z.slice(8, num[0]); + info.aStats.plan = zed.slice(5, -5); + } else { + info.mStats.read = z.slice(7, num[0]); + info.mStats.plan = zed.slice(4, -5); + } + } + } else if (z === "All" && !info.friends) { info.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; } } - } - } else if (z === "All" && !info.friends) { info.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); + x++; + } while (x < text.length); - var list = []; - if (info.gender) { list.push("šŸš» Gender: " + info.gender); } - if (info.birthday) { list.push("šŸŽ‚ Birthday: " + info.birthday); } - if (info.friends) { list.push("šŸ‘« Friends: " + info.friends); } + var list = []; + if (info.gender) { list.push("šŸš» Gender: " + info.gender); } + if (info.birthday) { list.push("šŸŽ‚ Birthday: " + info.birthday); } + if (info.friends) { list.push("šŸ‘« Friends: " + info.friends); } - const embed = new client.methods.Embed() - .setTitle(term + "'s MAL Profile") - .setURL(url + term) - .setDescription("Last online: " + info.status); - if (list.length > 0) { embed.addField("__General:__", list.join("\n")); } - embed.addField("__Anime:__", "šŸ•“ Days: " + info.aStats.days + " | šŸ“Š Mean: " + info.aStats.mean + "\nšŸ’š Watching: " + info.aStats.watch + "\nšŸ’™ Completed: " + info.aStats.completed + "\nšŸ’› On-Hold: " + info.aStats.hold + "\nšŸ’” Dropped: " + info.aStats.drop + "\nšŸ—“ Plan-to-Watch: " + info.aStats.plan, true) - .addField("__Manga:__", "šŸ•“ Days: " + info.mStats.days + " | šŸ“Š Mean: " + info.mStats.mean + "\nšŸ“— Reading: " + info.mStats.read + "\nšŸ“˜ Completed: " + info.mStats.completed + "\nšŸ“™ On-Hold: " + info.mStats.hold + "\nšŸ“• Dropped: " + info.mStats.drop + "\nšŸ—“ Plan-to-Read: " + info.mStats.plan, true) - .setTimestamp() - .setColor(0x2E51A2) - .setThumbnail($(".user-image").find("img")[0].attribs.src) - .setFooter("Requested by: " + msg.author.tag); + const embed = new MessageEmbed() + .setTitle(term + "'s MAL Profile") + .setURL(url + term) + .setDescription("Last online: " + info.status); + if (list.length > 0) { embed.addField("__General:__", list.join("\n")); } + embed.addField("__Anime:__", "šŸ•“ Days: " + info.aStats.days + " | šŸ“Š Mean: " + info.aStats.mean + "\nšŸ’š Watching: " + info.aStats.watch + "\nšŸ’™ Completed: " + info.aStats.completed + "\nšŸ’› On-Hold: " + info.aStats.hold + "\nšŸ’” Dropped: " + info.aStats.drop + "\nšŸ—“ Plan-to-Watch: " + info.aStats.plan, true) + .addField("__Manga:__", "šŸ•“ Days: " + info.mStats.days + " | šŸ“Š Mean: " + info.mStats.mean + "\nšŸ“— Reading: " + info.mStats.read + "\nšŸ“˜ Completed: " + info.mStats.completed + "\nšŸ“™ On-Hold: " + info.mStats.hold + "\nšŸ“• Dropped: " + info.mStats.drop + "\nšŸ—“ Plan-to-Read: " + info.mStats.plan, true) + .setTimestamp() + .setColor(0x2E51A2) + .setThumbnail(loadBody(".user-image").find("img")[0].attribs.src) + .setFooter("Requested by: " + msg.author.tag); - msg.channel.send({embed}); - }); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: ["ATTACH_FILES"], - cooldown: 30 -}; - -exports.help = { - name: "mal", - description: "Fetch a user's profile on MyAnimeList", - usage: "[term:str]", - extendedHelp: "There is a 30 second cooldown for each profile search to not spam the MAL site." + msg.channel.send({embed}); + }); + } }; \ No newline at end of file diff --git a/commands/General/roleinfo.js b/commands/General/roleinfo.js new file mode 100644 index 0000000..5cd879c --- /dev/null +++ b/commands/General/roleinfo.js @@ -0,0 +1,37 @@ +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "roleinfo", + enabled: true, + runIn: ["text"], + cooldown: 0, + aliases: ["role"], + description: "Get information on a role", + usage: "[rolesrc:str]", + extendedHelp: "Need Discord info on a specific role? I got you covered!" + }); + } + + async run(msg, [rolesrc]) { + var role; + msg.guild.roles.forEach(element => { if (element.name.toLowerCase() === rolesrc.toLowerCase()) { role = element; } }); + if (!role) { return this.client.speech(msg, ["roleinfo"]); } + + const embed = new MessageEmbed() + .setTimestamp() + .setAuthor(role.name + " | " + role.id) + .setColor(role.hexColor) + .addField("Position:", (msg.guild.roles.size - role.position), true) + .addField("Hex Colour:", role.hexColor, true) + .addField("User Count:", role.members.size, true) + .addField("Hoisted", role.hoist, true) + .addField("Managed", role.managed, true) + .addField("Mentionable", role.mentionable, true) + .setFooter(msg.guild.name, msg.guild.iconURL()); + + msg.channel.send({embed}); + } +}; \ No newline at end of file diff --git a/commands/General/serverinfo.js b/commands/General/serverinfo.js new file mode 100644 index 0000000..b45117a --- /dev/null +++ b/commands/General/serverinfo.js @@ -0,0 +1,34 @@ +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "serverinfo", + enabled: true, + runIn: ["text"], + cooldown: 0, + aliases: ["server"], + description: "Get your server's information", + extendedHelp: "Need Discord info on your server? I got you covered!" + }); + } + + async run(msg) { + let guild = msg.guild; + + const embed = new MessageEmbed() + .setTimestamp() + .setColor(0x04d5fd) + .setAuthor(guild.name + " | " + guild.id) + .setThumbnail(guild.iconURL()) + .addField("Region:", guild.region, true) + .addField("Created:", guild.createdAt.toLocaleString(), true) + .addField("Owner:", `${guild.owner.user.tag} - ${guild.owner.id}`) + .addField("Members:", `${guild.memberCount - guild.members.filter(m => m.user.bot).size} (${guild.members.filter(m => m.user.bot).size} bots)`, true) + .addField("Roles:", guild.roles.size, true) + .setFooter(msg.guild.name, msg.guild.iconURL()); + + msg.channel.send({embed}); + } +}; \ No newline at end of file diff --git a/commands/General/userinfo.js b/commands/General/userinfo.js new file mode 100644 index 0000000..3093d88 --- /dev/null +++ b/commands/General/userinfo.js @@ -0,0 +1,70 @@ +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "userinfo", + enabled: true, + runIn: ["text"], + cooldown: 0, + aliases: ["user"], + description: "Get a user's information", + usage: "[user:usersearch]", usageDelim: " ", + extendedHelp: "Need Discord info on a specific user? I got you covered!" + }); + } + + async run(message, [user]) { + if (user === null) { return; } + + let guild = message.guild; + user = guild.members.get(user.id); + + const embed = new MessageEmbed() + .setTimestamp() + .setFooter(guild.name, guild.iconURL()); + + const statusList = { + online: "online", + idle: "idle", + dnd: "in do not disturb" + }; + + var Status = statusList[user.presence.status] || "offline"; + + var activity; + if (user.presence.activity === null) { activity = " "; } + else if (user.presence.activity.name === "Custom Status") { + activity = " while doing " + user.presence.activity.state; + } else { + switch (user.presence.activity.type) { //All cases covered + case "PLAYING": + activity = " while playing "; + break; + case "LISTENING": + activity = " while listening to "; + break; + case "WATCHING": + activity = " while watching "; + break; + case "STREAMING": + activity = " while streaming "; + break; + } + activity += user.presence.activity.name; + } + + embed.setThumbnail(user.user.displayAvatarURL()) + .setAuthor(user.user.tag + " | " + user.id) + .setDescription("Currently " + Status + activity) + .addField("ID: ", user.id, true) + .addField("Bot user:", user.user.bot ? "True": "False", true) + .addBlankField(true) + .addField("Created:", user.user.createdAt.toLocaleString(), true) + .addField("Joined:", user.joinedAt.toLocaleString(), true) + .setColor(0x04d5fd); + + message.channel.send({embed}); + } +}; \ No newline at end of file diff --git a/commands/System/about.js b/commands/System/about.js index deb8626..8e90a28 100644 --- a/commands/System/about.js +++ b/commands/System/about.js @@ -1,39 +1,37 @@ -const moment = require("moment"); -require("moment-duration-format"); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); -exports.run = async (client, msg) => { - const prefix = msg.guildSettings.prefix || client.config.prefix; - const duration = moment.duration(client.uptime).format(" D [days], H [hours], m [minutes and] s [seconds]"); - - const embed = new client.methods.Embed() +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: 'about', + runIn: ['text', 'dm'], + aliases: ["stats", "dm"], + guarded: true, + description: 'General information', + usage: "" + }); + } + + async run(msg) { + const embed = new MessageEmbed() .setColor(0x37FDFC) .setTitle("About Me") .setDescription(`[Github](https://github.com/Butterstroke/MargarineBot) | [Terms Of Service](https://github.com/Butterstroke/MargarineBot/blob/master/TermsOfService.md) - \nI am a very helpful and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written with Discord.js and Komada, a Discord.js framework. - \n**Stats:** I have been online, helping out, for ${duration} using ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB of memory. ${client.users.size} users across ${client.guilds.size} guilds with ${client.channels.size.toLocaleString()} channels depend on my functions to be as reliable as possible! + \nI am a very helpful and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written with Discord.js and Klasa, a Discord.js framework. + \n**Stats:** I have been online, helping out, for ${client.funcs.timeStamp(client, client.uptime)} using ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB of memory. ${client.users.size} users across ${client.guilds.size} guilds with ${client.channels.size.toLocaleString()} channels depend on my functions to be as reliable as possible! \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 the ${dateMaker(client.user.createdAt)} by Butterstroke#7150.`) - .setThumbnail(client.user.displayAvatarURL()) + \n**Creation:** I was created on the ${dateMaker(this.client.user.createdAt)} by Butterstroke#7150.`) + .setThumbnail(this.client.user.displayAvatarURL()) .setFooter("Running on Margarine " + client.ownerSetting.get("build").version + " | Released on: " + client.ownerSetting.get("build").releaseDate); - msg.channel.send({embed}); -}; -exports.conf = { - enabled: true, - runIn: ["text", "dm"], - aliases: ["stats", "whoami"], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "about", - description: "General information.", usage: "" + msg.channel.send({embed}); + } }; function dateMaker(date) { var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var d = date.toLocaleString().split(" ")[0].split("-"); - return d[2] + " " + months[d[1]] + ", " + d[0]; + return d[2] + " " + months[d[1]] + " " + d[0]; } \ No newline at end of file diff --git a/commands/System/exit.js b/commands/System/exit.js index c819cc0..d123585 100644 --- a/commands/System/exit.js +++ b/commands/System/exit.js @@ -1,18 +1,21 @@ -exports.run = async (client, message) => { - await message.delete().catch(); - await message.channel.send(`Good night, ${client.owner.username}!`); - await process.exit().catch((e) => { console.error(e); }); -}; - -exports.conf = { - enabled: true, - runIn: ["text", "dm"], - aliases: ["sleep"], - permLevel: 10, - botPerms: [] -}; - -exports.help = { - name: "exit", - description: "Shuts down the bot.", usage: "" -}; \ No newline at end of file +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: 'exit', + runIn: ['text', 'dm'], + aliases: ["shutdown", "sleep"], + guarded: true, + permissionLevel: 10, + description: 'Shuts down the bot.', + usage: "" + }); + } + + async run(msg) { + await msg.delete().catch(); + await msg.channel.send("Good night, " + this.client.owner.username + "!"); + await process.exit().catch((e) => { console.error(e); }); + } +}; \ No newline at end of file diff --git a/commands/System/invite.js b/commands/System/invite.js index e386f23..e492e8d 100644 --- a/commands/System/invite.js +++ b/commands/System/invite.js @@ -1,18 +1,19 @@ -exports.run = async (client, message) => { - return message.send(`My Discord guild invite link: <${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:`); -}; - -exports.conf = { - enabled: true, - runIn: ["text", "dm"], - aliases: [], - permLevel: 0, - botPerms: [] -}; +const { Command } = require("klasa"); -exports.help = { - name: "invite", - description: "Displays the join server link of the bot.", - usage: "" -}; \ No newline at end of file +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: 'invite', + runIn: ['text', 'dm'], + aliases: [], + guarded: true, + description: "Displays the invite link for Margarine.", + usage: "" + }); + } + + 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:`); + } +} \ No newline at end of file diff --git a/commands/System/permlevel.js b/commands/System/permlevel.js index 5bb7966..7d3a30e 100644 --- a/commands/System/permlevel.js +++ b/commands/System/permlevel.js @@ -1,30 +1,40 @@ -exports.run = async (client, msg) => { - for (let i = 0; i < 10; i++) { - if (msg.author.id === client.owner.id) { - if (client.permStructure[4].check(client, msg)) { var addPerms = 4; } - else if (client.permStructure[3].check(client, msg)) { var addPerms = 3; } - else if (client.permStructure[2].check(client, msg)) { var addPerms = 2; } - else { var addPerms = 0; } - var permLevel = 10; - } - else if (client.permStructure[i].check(client, msg)) { var permLevel = i; } +const { Command } = require("klasa"); +const config = require("../../assets/settings.json"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "permlevel", + runIn: ['text'], + aliases: [], + guarded: true, + description: "Checks your permission level." + }); } - var info = addPerms ? client.ownerSetting.get("permLevel").addPerms[addPerms] : ""; + async run(msg) { + var permLevel = 0; + + if (msg.author === this.client.owner || msg.author.id === config.secondary) { + var guild = msg.guild; + var authorLvl = (msg.author === this.client.owner) ? 10 : 9; + var author = guild.members.get(msg.author.id); + + if (!guild) { permLevel = 0; } + else if (guild.owner.id === msg.author.id) { permLevel = 3; } + else if (author.permissions.has("ADMINISTRATOR")) { permLevel = 2; } + else if (author.roles.has(guild.settings.modRole)) { permLevel = 1; } + else { permLevel = 0; } - msg.channel.send(`Your permission level is ${client.ownerSetting.get("permLevel").general[permLevel]} ${info}`); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "permlevel", - description: "Check your permission level.", - usage: "" + 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); + } + + for (var i = 5; i < 8; i++) { + var check = await msg.hasAtLeastPermissionLevel(i); + if (check) { permLevel = i; } + } + + msg.channel.send("Your permission level is " + this.client.ownerSetting.get("permLevel").general[permLevel]); + } }; \ No newline at end of file diff --git a/commands/System/ping.js b/commands/System/ping.js index 5034b6a..382e5db 100644 --- a/commands/System/ping.js +++ b/commands/System/ping.js @@ -1,17 +1,19 @@ -exports.run = async (client, message) => { - const msg = await message.channel.send("Pinging..."); - await msg.edit(`šŸŽ‰ Pong! (Took: ${msg.createdTimestamp - message.createdTimestamp}ms.) šŸŽ‰`); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "ping", - description: "Ping/Pong command.", usage: "" +const { Command } = require('klasa'); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: 'ping', + runIn: ['text', 'dm'], + aliases: [], + guarded: true, + description: 'Ping/Pong command', + usage: "" + }); + } + + async run(message) { + const msg = await message.channel.send("Pinging..."); + await msg.edit(`šŸŽ‰ Pong! (Took: ${(msg.editedTimestamp || msg.createdTimestamp) - (message.editedTimestamp || message.createdTimestamp)}ms.) šŸŽ‰`) + } }; \ No newline at end of file diff --git a/events/guildCreate.js b/events/guildCreate.js deleted file mode 100644 index b5b7b81..0000000 --- a/events/guildCreate.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.run = async (client, guild) => { - const embed = new client.methods.Embed() - .setTimestamp() - .setColor(0xF1C40F) - .addField("To the users of " + guild.name, `Hello world! My name is ${client.user.username} and thank you for inviting me to your amazing guild! I am a somewhat helpful and fantastic bot created using Komada, a Discord.js framework. To see how I will be able to assist you, feel free to do ${client.config.prefix}help.` + "I will send you my help menu in which will provide you with some pretty awesome commands, if I do say so myself!\nIf you have any improvement ideas, found issues or bugs, or have any complaints, feel free to use my report command and let my creator know how to improve me! I do have a TOS that users will need to accept for some of my abilities. Please refer to [this link](https://github.com/Butterstroke/MargarineBot/blob/master/TermsOfService.md) for more information."); - - let channel = client.funcs.defaultChannel(client, guild.id); - if (guild.available) { client.settings.guilds.create(guild).catch(e => client.emit("log", e, "error")); } - - const msg = await channel.send({embed}); - var data = msg.channel.guild.members.find("id", client.owner.id); - if (data !== null) { channel.send(`Oh! 恓悓恫恔ćÆ <@${client.owner.id}>. I'm ready to work here! Watch me excel! :thumbsup:`); } -}; \ No newline at end of file diff --git a/events/guildDelete.js b/events/guildDelete.js deleted file mode 100644 index 8b421d6..0000000 --- a/events/guildDelete.js +++ /dev/null @@ -1 +0,0 @@ -exports.run = (client, guild) => { if (guild.available) { client.settings.guilds.destroy(guild).catch(e => client.emit("log", e, "error")); } }; \ No newline at end of file diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js deleted file mode 100644 index 0ae2257..0000000 --- a/events/guildMemberAdd.js +++ /dev/null @@ -1,10 +0,0 @@ -exports.run = (client, guild) => { - if (!client.settings.guilds.schema.welcomeChannel) { client.funcs.confAdd(client); } - - if (client.settings.guilds.schema.welcomeChannel === null) { var channel = client.funcs.defaultChannel(client, guild.id); } - else { var channel = guild.guild.channels.find("id", guild.guild.settings.welcomeChannel); } - - var perm = client.channels.get(channel.id).permissionsFor(client.user).has("SEND_MESSAGES"); - - if (perm === true) { client.channels.get(channel.id).send(`${guild.user.username} is buttered up and has joined the server!`); } -}; \ No newline at end of file diff --git a/events/guildMemberRemove.js b/events/guildMemberRemove.js deleted file mode 100644 index 7358ff3..0000000 --- a/events/guildMemberRemove.js +++ /dev/null @@ -1,8 +0,0 @@ -exports.run = (client, guild) => { - if (!client.settings.guilds.schema.welcomeChannel) { client.funcs.confAdd(client); } - - if (client.settings.guilds.schema.welcomeChannel === null) { var channel = client.funcs.defaultChannel(client, guild.guild); } - else { var channel = guild.guild.channels.find("id", guild.guild.settings.welcomeChannel); } - - client.channels.get(channel.id).send(`${guild.user.username} has left the server. Good luck out there!`); -}; \ No newline at end of file diff --git a/events/ready.js b/events/ready.js deleted file mode 100644 index 980469c..0000000 --- a/events/ready.js +++ /dev/null @@ -1,22 +0,0 @@ -const moment = require("moment"); -const fs = require("fs"); - -exports.run = async client => { - //Init storage areas. - if (!fs.existsSync("./assets/data")) { fs.mkdirSync("./assets/data"); } - - //Inits the databases - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.general); - let sql = new sqlite3.Database(client.database.inv); - - await db.get("SELECT * FROM users WHERE userId = 1", [], (err, row) => { if (err) { return client.funcs.sqlTables("-init"); } else { return; } }); - await db.close(); - await sql.get("SELECT * FROM material WHERE userId = 1", [], (err, row) => { if (err) { return; } else { return; }}); - await sql.close(); - - await console.log(`[${moment().format("YYYY-MM-DD HH:mm")}] This is ${client.user.username} speaking! Online and awaiting orders!`); - await console.log(`[${moment().format("YYYY-MM-DD HH:mm")}] Current status: Serving ${client.guilds.size} guilds and ${client.users.size} people.`); - - await client.funcs.presenceHelper(client, "-start"); //Inits the presence timer. -}; \ No newline at end of file diff --git a/functions/userSearch.js b/functions/userSearch.js deleted file mode 100644 index c80d557..0000000 --- a/functions/userSearch.js +++ /dev/null @@ -1,52 +0,0 @@ -module.exports = async (client, msg, user, tags) => { - if (!user || user.length < 1) { user = [null]; } - if (!tags || tags.length < 1) { tags = ["None"]; } - - if (typeof user === "object") { user = user[0]; } - - if (user === null) { user = msg.author.id; } - else if (msg.mentions.users.size > 1 && msg.content.startsWith("<")) { - var item = Array.from(msg.mentions.users); - user = item[0][1].toString().slice(2, -1); - } else if (msg.mentions.users.size > 0) { - if (msg.content.startsWith("<") === false) { user = msg.mentions.users.first().id; } - else if (msg.content.indexOf("<") !== msg.content.lastIndexOf("<")) { user = Array.from(msg.mentions.users)[0][1].toString().slice(2, -1); } - } - else if (/^(\d{17,21})$/.test(user)) { - user = await Promise.resolve(client.users.fetch(user)); - user = user.id; - } - - var members = Array.from(msg.guild.members); - if (/^(\d{17,21})$/.test(user) === false) { - for (var x = 0; x < members.length; x++) { - if (user.toLowerCase() === members[x][1].user.username.toLowerCase()) { - user = msg.guild.members.get(members[x][0]); - x = members.length; - } - else if (members[x][1].nickname && user.toLowerCase() === members[x][1].nickname.toLowerCase()) { - user = msg.guild.members.get(members[x][0]); - x = members.length; - } - else if (x + 1 === members.length) { user == null; } - } - } else { user = msg.guild.members.get(user); } - - if (user === null) { - client.speech(msg, ["func-userSearch", "default"]); - return false; - } else if (user.user.bot === true && tags.includes("bot")) { - client.speech(msg, ["func-userSearch", tags[0]]); - return false; - } - - return user; -}; - -module.exports.conf = { requiredModules: [] }; - -module.exports.help = { - name: "userSearch", - type: "functions", - description: "Searchs for a user with a mention, username, or a guild nickname.", -}; \ No newline at end of file diff --git a/index.js b/index.js index 0f899fb..baef6bf 100644 --- a/index.js +++ b/index.js @@ -1,50 +1,48 @@ -const Komada = require("komada"); +const { Client } = require("klasa"); const Discord = require("discord.js"); const config = require("./assets/settings.json"); -const localization = require("./assets/localization.json"); const util = require("./utilities/utilExport.js"); -util.envCheck(); //Checks for the proper enviroment. +util.envCheck(); //Checks to make sure Margarine is running in the right environment. -const client = new Komada.Client({ - ownerID: config.ownerID, +const client = new Client({ + fetchAllMembers: false, prefix: config.prefix, - clientOptions: { fetchAllMembers: false }, - cmdLogging: false, - permStructure: new Komada.PermLevels() - .addLevel(0, false, () => true) - .addLevel(2, false, (client, msg) => { - if (!msg.guild || !msg.guild.settings.modRole) { return false; } - const modRole = msg.guild.roles.get(msg.guild.settings.modRole); - return modRole && msg.member.roles.has(modRole.id); - }) - .addLevel(3, false, (client, msg) => { - if (!msg.guild || !msg.guild.settings.adminRole) { return false; } - const adminRole = msg.guild.roles.get(msg.guild.settings.adminRole); - return adminRole && msg.member.roles.has(adminRole.id); - }) - .addLevel(4, false, (client, msg) => msg.guild && msg.author.id === msg.guild.owner.id) - .addLevel(9, false, (client, msg) => msg.author.id === config.secondary) - .addLevel(10, false, (client, msg) => msg.author === client.owner) + commandEditing: true }); -util.remove(client); //Removes most default commands from the Komada directory so that there is absolutly no conflicts. +Client.defaultPermissionLevels + .add(5, ({ guild, member }) => guild && member.roles.has(guild.settings.modRole)) + .add(6, ({ guild, member }) => guild && member.permissions.has('ADMINISTRATOR')) + .add(9, ({ author, client }) => author === client.owner || author.id === config.secondary) + .add(10, ({ author, client }) => author === client.owner); + +client.gateways.guilds.schema + .add("modRole", "role") + .add("langSpeech", "language", { default: "en-CA" }); client.speech = util.speech; +client.dataManager = util.dataManager; client.ownerSetting = new Discord.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 "database": client.database = config.database; break; - case "build": client.ownerSetting.set("build", config.build); break; - } + 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("permLevel", localization.permLevels); -client.database.items = require("./assets/values/items.json"); -client.database.recipes = require("./assets/values/recipes.json"); -client.login(config.token); \ No newline at end of file +client.ownerSetting.set("permLevel", config.permLevels); + +client.database = { + "items": require("./assets/values/items.json"), + "recipes": require("./assets/values/recipes.json") +}; + +client.login(config.token).then(() => { + client.user.setPresence({ activity: { name: "m~help | Running the latest code!", type: "PLAYING" }, status: "online" }); +}); \ No newline at end of file diff --git a/monitors/commandHelper.js b/monitors/commandHelper.js deleted file mode 100644 index a5b78b7..0000000 --- a/monitors/commandHelper.js +++ /dev/null @@ -1,26 +0,0 @@ -exports.run = (client, msg) => { - switch (msg.content) { - case "/shrug": - msg.delete(); - msg.channel.send("*" + msg.author.tag + "* : ĀÆ\\_(惄)_/ĀÆ"); - break; - case "/tableflip": - msg.delete(); - msg.channel.send("*" + msg.author.tag + "* : (ā•ÆĀ°ā–”Ā°ļ¼‰ā•Æļøµ ā”»ā”ā”»"); - break; - case "/unflip": - msg.delete(); - msg.channel.send("*" + msg.author.tag + "* : ā”¬ā”€ā”¬ 惎( 悜-悜惎)"); - break; - case "/lenny": - msg.delete(); - msg.channel.send("*" + msg.author.tag + "* : ( Ķ”Ā° ĶœŹ– Ķ”Ā°)"); - break; - } -}; - -exports.conf = { - enabled: true, - ignoreBots: true, - ignoreSelf: true, -}; \ No newline at end of file diff --git a/monitors/prefixHelp.js b/monitors/prefixHelp.js index 5bb3e8e..2dc59ef 100644 --- a/monitors/prefixHelp.js +++ b/monitors/prefixHelp.js @@ -1,11 +1,22 @@ -exports.run = (client, msg) => { - if ((msg.content.startsWith(client.config.prefix)) && msg.channel.type === "text") { - if ((client.config.prefix !== msg.guild.settings.prefix) && (msg.content === (client.config.prefix + "help"))) { return msg.channel.send(`Whoops! Looks like you are thinking of my default prefix. That is not the case here. Please use: ${msg.guild.settings.prefix}`); } else { return; } - } -}; +const { Monitor } = require('klasa'); -exports.conf = { - enabled: true, - ignoreBots: true, - ignoreSelf: true +module.exports = class extends Monitor { + constructor(...args) { + super(...args, { + name: 'prefixHelp', + enabled: true, + ignoreEdits: false, + ignoreOthers: false + }); + } + + run(msg) { + var defaultPrefix = msg.client.gateways.guilds.schema.get("prefix").default; + + if (msg.content == defaultPrefix + "help") { + if (defaultPrefix !== msg.guild.settings.prefix) { + return msg.channel.send(`Whoops! Looks like you are thinking of my default prefix. That is not the case here. Please use: ${msg.guild.settings.prefix}`); + } + } + } }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ed4abb9..8c7a4dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,20 +4,28 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@discordjs/collection": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.3.tgz", + "integrity": "sha512-4ek19SmNcPI92942RkuBrZrBK8hg7nG+ae/skkNNDeOaUG+XvxTPkv/jPZVgXwVPDkU5EFsewsI+0n4dTwFvgA==" + }, "@types/node": { - "version": "6.0.88", - "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.88.tgz", - "integrity": "sha512-bYDPZTX0/s1aihdjLuAgogUAT5M+TpoWChEMea2p0yOcfn5bu3k6cJb9cp6nw268XeSNIGGr+4+/8V5K6BGzLQ==" + "version": "12.12.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.14.tgz", + "integrity": "sha512-u/SJDyXwuihpwjXy7hOOghagLEV1KdAST6syfnOk6QZAMzZuWZqXy5aYYZbh8Jdpd4escVFP0MvftHNDb9pruA==" }, - "abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + "abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "requires": { + "event-target-shim": "^5.0.0" + } }, "ajv": { - "version": "6.5.5", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.5.tgz", - "integrity": "sha512-7q7gtRQDJSyuEHjuVgHoUa2VuemFiCMrfQc9Tc08XTAc4Zj/5U1buQJ0HU6i7fKjXU09SVgSmxa4sLvuvS8Iyg==", + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", "requires": { "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", @@ -26,30 +34,11 @@ } }, "anilist-node": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/anilist-node/-/anilist-node-1.1.0.tgz", - "integrity": "sha512-l15B3hReXnT0dfmTfLdXlHBKus1sYuM0A7VlOs3Smb/smxiNwOtfv3wjEw9TDeL7f/AU43DrpV3kLM4N61e0iQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/anilist-node/-/anilist-node-1.2.2.tgz", + "integrity": "sha512-r7LZfcoyX/kzaGk0H0p2MqfKplabsjy7u53WXVuFrPTrM92L5JcpsQkmXsGPq9hzvCG0WV2Wz3pmdFdw28VxTw==", "requires": { - "node-fetch": "^2.2.0" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" - }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" - }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" + "node-fetch": "^2.6.0" } }, "asn1": { @@ -66,9 +55,9 @@ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, "async-limiter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" }, "asynckit": { "version": "0.4.0", @@ -81,14 +70,9 @@ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" }, "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.0.tgz", + "integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A==" }, "bcrypt-pbkdf": { "version": "1.0.2", @@ -105,25 +89,20 @@ } } }, - "bindings": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", - "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" + "better-sqlite3": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-5.4.3.tgz", + "integrity": "sha512-fPp+8f363qQIhuhLyjI4bu657J/FfMtgiiHKfaTsj3RWDkHlWC1yT7c6kHZDnBxzQVoAINuzg553qKmZ4F1rEw==", + "requires": { + "integer": "^2.1.0", + "tar": "^4.4.10" + } }, "boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, "capture-stack-trace": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz", @@ -135,12 +114,12 @@ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, "cheerio": { - "version": "1.0.0-rc.2", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz", - "integrity": "sha1-S59TqBsn5NXawxwP/Qz6A8xoMNs=", + "version": "1.0.0-rc.3", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz", + "integrity": "sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==", "requires": { "css-select": "~1.2.0", - "dom-serializer": "~0.1.0", + "dom-serializer": "~0.1.1", "entities": "~1.1.1", "htmlparser2": "^3.9.1", "lodash": "^4.15.0", @@ -148,38 +127,18 @@ } }, "chownr": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", - "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", + "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==" }, "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } }, - "commander": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", - "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -205,9 +164,9 @@ } }, "css-what": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.0.tgz", - "integrity": "sha1-lGfQMsOM+u+58teVASUwYvh/ob0=" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", + "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==" }, "dashdash": { "version": "1.14.1", @@ -217,81 +176,43 @@ "assert-plus": "^1.0.0" } }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "optional": true, - "requires": { - "ms": "2.0.0" - }, - "dependencies": { - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "optional": true - } - } - }, - "deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" - }, - "detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" - }, "discord.js": { - "version": "github:hydrabolt/discord.js#d92ee2ff999954899c891c093f5f107dd686b64f", - "from": "github:hydrabolt/discord.js", - "requires": { - "form-data": "^2.3.2", - "node-fetch": "^2.1.2", - "pako": "^1.0.0", - "prism-media": "github:amishshah/prism-media", + "version": "github:discordjs/discord.js#1b1289b35e2f8cd21341351549e6ac52fd08cb34", + "from": "github:discordjs/discord.js", + "requires": { + "@discordjs/collection": "^0.1.1", + "abort-controller": "^3.0.0", + "form-data": "^2.3.3", + "node-fetch": "^2.3.0", + "prism-media": "^1.0.0", "setimmediate": "^1.0.5", - "tweetnacl": "^1.0.0", - "ws": "^6.0.0" + "tweetnacl": "^1.0.1", + "ws": "^7.2.0" } }, "dom-serializer": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", - "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", "requires": { - "domelementtype": "~1.1.1", - "entities": "~1.1.1" - }, - "dependencies": { - "domelementtype": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", - "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=" - } + "domelementtype": "^1.3.0", + "entities": "^1.1.1" } }, "domelementtype": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", - "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=" + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" }, "domhandler": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.1.tgz", - "integrity": "sha1-iS5HAAqZvlW783dP/qBWHYh5wlk=", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", + "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", "requires": { "domelementtype": "1" } @@ -320,9 +241,14 @@ } }, "entities": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", - "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" + }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" }, "extend": { "version": "3.0.2", @@ -358,51 +284,31 @@ "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" }, "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", "requires": { "asynckit": "^0.4.0", - "combined-stream": "1.0.6", + "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, "fs-minipass": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", - "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", "requires": { - "minipass": "^2.2.1" + "minipass": "^2.6.0" } }, "fs-nextra": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/fs-nextra/-/fs-nextra-0.3.2.tgz", - "integrity": "sha512-ktFNusOmRFt1sWPaRRS3USAb4sFlZvERdG+rZ+VDzPBciC+0K0BhFBs5vMkJZZhhUMi6/gzGAvb7UePP/DLnzA==" - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/fs-nextra/-/fs-nextra-0.4.7.tgz", + "integrity": "sha512-N61ZytY7cF3VlPTQ+o90XK+TsdOaUPeX0cpwy5oOVbXaneSO6KorpsR2xSQr+GJbItkWzgu3h4ypSqCWjTeZKg==" }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "getpass": { @@ -413,22 +319,9 @@ "assert-plus": "^1.0.0" } }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, "got": { "version": "6.7.1", - "resolved": "http://registry.npmjs.org/got/-/got-6.7.1.tgz", + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", "requires": { "create-error-class": "^3.0.0", @@ -458,27 +351,22 @@ "har-schema": "^2.0.0" } }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" - }, "html-entities": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=" }, "htmlparser2": { - "version": "3.9.2", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.9.2.tgz", - "integrity": "sha1-G9+HrMoPP55T+k/M6w9LTLsAszg=", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", + "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", "requires": { - "domelementtype": "^1.3.0", + "domelementtype": "^1.3.1", "domhandler": "^2.3.0", "domutils": "^1.5.1", "entities": "^1.1.1", "inherits": "^2.0.1", - "readable-stream": "^2.0.2" + "readable-stream": "^3.1.1" } }, "http-signature": { @@ -491,48 +379,15 @@ "sshpk": "^1.7.0" } }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ignore-walk": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", - "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", - "requires": { - "minimatch": "^3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" - }, - "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", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } + "integer": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/integer/-/integer-2.1.0.tgz", + "integrity": "sha512-vBtiSgrEiNocWvvZX1RVfeOKa2mCHLZQ2p9nkQkQZ/BvEiY+6CcUz0eyjvIiewjJoeNidzg2I+tpPJvpyspL1w==" }, "is-redirect": { "version": "1.0.0", @@ -540,9 +395,9 @@ "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=" }, "is-retry-allowed": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", - "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz", + "integrity": "sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg==" }, "is-stream": { "version": "1.1.0", @@ -554,11 +409,6 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -595,28 +445,17 @@ "verror": "1.10.0" } }, - "komada": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/komada/-/komada-0.21.1.tgz", - "integrity": "sha512-Gbl2OiO1CYvjXrlzQ/rjS3MMvgPtZt0uCassh61QlLGRserdPjIvgRNPIduK1RgzNao1sbwDuIaItNGNO/A8FQ==", + "klasa": { + "version": "github:dirigeants/klasa#0e9174cab0df7d28f3a7b8ca78b6344fef2611c9", + "from": "github:dirigeants/klasa#master", "requires": { - "fs-nextra": "^0.3.0", - "moment": "^2.18.1", - "moment-duration-format": "^1.3.0", - "performance-now": "^2.1.0" - }, - "dependencies": { - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" - } + "fs-nextra": "^0.4.5" } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "lowercase-keys": { "version": "1.0.1", @@ -624,261 +463,103 @@ "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" }, "m3u8stream": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.6.2.tgz", - "integrity": "sha512-WsuM2bd5pPN80xvfrB+1DZqr4M7+kJl8byi6+ZCy6cmVjEiHhmr/desN53Ngsa6Hs13kYumeVgT4wL0oIJ+v6g==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.6.3.tgz", + "integrity": "sha512-HNUco8ef9kOvMRH7tYxJqbk9IuRA+AuZG8a/dQwqI+jfuEs1/DUaPbfTIlUDB4JmTZNkTOZHvZI5TvnQGR8nKA==", "requires": { - "miniget": "^1.4.0", + "miniget": "^1.6.1", "sax": "^1.2.4" } }, "mime-db": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", + "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==" }, "mime-types": { - "version": "2.1.18", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", + "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", "requires": { - "mime-db": "~1.33.0" + "mime-db": "1.42.0" } }, "miniget": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.5.1.tgz", - "integrity": "sha512-KJ3AyIVZ76QuWAq43BWjkK+jLdhxhy3s4tsdg9Je91+cIFkeOSW2VEj2lSeKw50CPu1eCCkSbiQEBKL36mpA5w==" - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { - "brace-expansion": "^1.1.7" - } + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.6.1.tgz", + "integrity": "sha512-I5oBwZmcaOuJrjQn7lpS29HM+aAZDbzKbX5ouxVyhFYdg6fA6YKOTwOCgzZQwlHuMek3FlCxz6eNrd4pOXbwOA==" }, "minimist": { "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - } } }, "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", "requires": { - "minipass": "^2.2.1" + "minipass": "^2.9.0" } }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" } }, "moment": { - "version": "2.22.2", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", - "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" }, "moment-duration-format": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/moment-duration-format/-/moment-duration-format-1.3.0.tgz", - "integrity": "sha1-VBdxtfh6BJzGVUBHXTrZZnN9aQg=" + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/moment-duration-format/-/moment-duration-format-2.3.2.tgz", + "integrity": "sha512-cBMXjSW+fjOb4tyaVHuaVE/A5TqkukDWiOfxxAjY+PEqmmBQlLwn+8OzwPiG3brouXKY5Un4pBjAeB6UToXHaQ==" }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" - }, - "nan": { - "version": "2.11.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", - "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==" - }, - "needle": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz", - "integrity": "sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==", - "requires": { - "debug": "^3.2.6", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - }, - "dependencies": { - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "requires": { - "ms": "^2.1.1" - } - } - } + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node-fetch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", - "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" - }, - "node-opus": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/node-opus/-/node-opus-0.3.1.tgz", - "integrity": "sha512-1Cb8OvHhdDspVfeKMjEgbedJabyE1Ib6OcN2BMEsRCU7FIsciuBpOErcie3y0qTf83nclPAY+kBU3Oj+U+oRlQ==", - "requires": { - "bindings": "~1.2.1", - "commander": "^2.9.0", - "nan": "^2.10.0", - "ogg-packet": "^1.0.0" - } - }, - "node-pre-gyp": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", - "integrity": "sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q==", - "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" - } - }, - "nopt": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", - "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, - "npm-bundled": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", - "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==" - }, - "npm-packlist": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.1.tgz", - "integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "nth-check": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.1.tgz", - "integrity": "sha1-mSms32KPwsQQmN6rgqxYDPFJquQ=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", + "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", "requires": { "boolbase": "~1.0.0" } }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" - }, - "ogg-packet": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ogg-packet/-/ogg-packet-1.0.0.tgz", - "integrity": "sha1-RbiFchrI991c8iOR1CEGrlM6xng=", - "optional": true, - "requires": { - "ref-struct": "*" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" - }, - "osenv": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", - "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "pako": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==" - }, "parse5": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.2.tgz", - "integrity": "sha1-Be/1fw70V3+xRKefi5qWemzERRA=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", + "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", "requires": { - "@types/node": "^6.0.46" + "@types/node": "*" } }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -890,18 +571,14 @@ "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=" }, "prism-media": { - "version": "github:amishshah/prism-media#1e336c9a20dd0928ef3bdc2075ab58d1521fb323", - "from": "github:amishshah/prism-media" - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.1.0.tgz", + "integrity": "sha512-W+oxjRyjtd7hw3pefNZuc7YEZ6VICORJvVNfCPs0+7CsJ43CqMjGAYGjPL3hQ82vw03EVra+CiX4zisqOBUUGw==" }, "psl": { - "version": "1.1.29", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", - "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.5.0.tgz", + "integrity": "sha512-4vqUjKi2huMu1OJiLhi3jN6jeeKvMZdI1tYgi/njW5zV52jNLgSAZSdN16m9bJFe61/cT8ulmw4qFitV9QRsEA==" }, "punycode": { "version": "2.1.1", @@ -918,57 +595,14 @@ "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" }, - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } - } - }, "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.0.3", - "util-deprecate": "~1.0.1" - } - }, - "ref": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ref/-/ref-1.3.5.tgz", - "integrity": "sha512-2cBCniTtxcGUjDpvFfVpw323a83/0RLSGJJY5l5lcomZWhYpU2cuLdsvYqMixvsdLJ9+sTdzEkju8J8ZHDM2nA==", - "optional": true, + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", "requires": { - "bindings": "1", - "debug": "2", - "nan": "2" - } - }, - "ref-struct": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ref-struct/-/ref-struct-1.1.0.tgz", - "integrity": "sha1-XV7mWtQc78Olxf60BYcmHkee3BM=", - "optional": true, - "requires": { - "debug": "2", - "ref": "1" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" } }, "request": { @@ -998,38 +632,22 @@ "uuid": "^3.3.2" }, "dependencies": { - "mime-db": { - "version": "1.37.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", - "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" - }, - "mime-types": { - "version": "2.1.21", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", - "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "requires": { - "mime-db": "~1.37.0" + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" } } }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "requires": { - "glob": "^7.1.3" - } - }, "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" }, "safer-buffer": { "version": "2.1.2", @@ -1041,52 +659,20 @@ "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" - }, "setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" - }, "snekfetch": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-4.0.4.tgz", "integrity": "sha512-dyycG9fvwtSJqKPfMVOpXt+60qvMGe7vWLwOJDiSJaiAx+hs2EnFChG2bXCWn7ulz+zGzrHdN9/yeEb0YqEPww==" }, - "sqlite3": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-4.0.8.tgz", - "integrity": "sha512-kgwHu4j10KhpCHtx//dejd/tVQot7jc3sw+Sn0vMuKOw0X00Ckyg9VceKgzPyGmmz+zEoYue9tOLriWTvYy0ww==", - "requires": { - "nan": "^2.12.1", - "node-pre-gyp": "^0.11.0", - "request": "^2.87.0" - }, - "dependencies": { - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" - } - } - }, "sshpk": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz", - "integrity": "sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA==", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", "requires": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", @@ -1106,56 +692,26 @@ } } }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "requires": { - "ansi-regex": "^2.0.0" + "safe-buffer": "~5.2.0" } }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" - }, "tar": { - "version": "4.4.9", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.9.tgz", - "integrity": "sha512-xisFa7Q2i3HOgfn+nmnWLGHD6Tm23hxjkx6wwGmgxkJFr6wxwXnJOdJYcZjL453PSdF0+bemO03+flAzkIdLBQ==", + "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.3.5", + "minipass": "^2.8.6", "minizlib": "^1.2.1", "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", "yallist": "^3.0.3" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - } } }, "timed-out": { @@ -1188,9 +744,9 @@ } }, "tweetnacl": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz", - "integrity": "sha1-cT2LgY2kIGh0C/aDhtBHnmb8ins=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.1.tgz", + "integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==" }, "unzip-response": { "version": "2.0.1", @@ -1219,9 +775,9 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", + "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" }, "verror": { "version": "1.10.0", @@ -1238,31 +794,18 @@ "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=" }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, "ws": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.2.tgz", - "integrity": "sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", "requires": { "async-limiter": "~1.0.0" } }, "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" }, "youtube-playlist": { "version": "1.0.2", @@ -1274,13 +817,13 @@ } }, "ytdl-core": { - "version": "0.28.3", - "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.28.3.tgz", - "integrity": "sha512-PbUEY7viwO6mJjsZN3vpnjNfpB747rNva3YbOJ9iTM9MtDt2CFcZov4K3Agf22pt/EuPc4zKnk/97K7TeS04yw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-1.0.3.tgz", + "integrity": "sha512-sBOVokjrAigKTEn248MJ+JpS5ifay/vBzYGMDeZhG61xmgthev6yHXBgEgm+M8ySDQXXVjOTmUtY3GHbX988KA==", "requires": { "html-entities": "^1.1.3", - "m3u8stream": "^0.6.2", - "miniget": "^1.4.0", + "m3u8stream": "^0.6.3", + "miniget": "^1.6.0", "sax": "^1.1.3" } } diff --git a/package.json b/package.json index 50ff024..f54d742 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,24 @@ { "name": "margarine", "version": "1.0.0", - "description": "Javascript bot using the Komada framework", + "description": "Javascript bot using the Klasa framework", "main": "index.js", "dependencies": { - "anilist-node": "^1.1.0", - "cheerio": "^1.0.0-rc.2", - "discord.js": "github:hydrabolt/discord.js", + "anilist-node": "^1.2.2", + "better-sqlite3": "^5.4.3", + "cheerio": "^1.0.0-rc.3", + "discord.js": "github:discordjs/discord.js", "ffmpeg": "0.0.4", - "komada": "^0.21.1", - "moment": "^2.22.2", - "moment-duration-format": "^1.3.0", - "ms": "^2.0.0", - "node-fetch": "^2.3.0", - "node-opus": "^0.3.1", + "klasa": "github:dirigeants/klasa#master", + "moment": "^2.24.0", + "moment-duration-format": "^2.3.2", + "ms": "^2.1.2", + "node-fetch": "^2.6.0", "querystring": "^0.2.0", "request": "^2.88.0", "snekfetch": "^4.0.4", - "sqlite3": "^4.0.8", "youtube-playlist": "^1.0.2", - "ytdl-core": "^0.28.3" + "ytdl-core": "^1.0.0" }, "devDependencies": {}, "repository": { @@ -27,9 +26,12 @@ "url": "git+https://github.com/butterstroke/MargarineBot" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "node index.js" + "start": "node index.js", + "envCheck": "node ./utilities/envCheck.js" + }, + "author": { + "name": "Frederick Katsura", + "email": "katsurinstudios@protonmail.ch" }, - "author": "Butterstroke", "license": "Apache-2.0" } diff --git a/utilities/commandRemover.js b/utilities/commandRemover.js deleted file mode 100644 index 5147855..0000000 --- a/utilities/commandRemover.js +++ /dev/null @@ -1,11 +0,0 @@ -const fs = require("fs"); - -module.exports = function(client) { - var files = ["stats", "download", "info", "ping", "invite", "reboot", "help"]; - - for(var x = 0; x < files.length; x++) { - if (fs.existsSync(client.clientBaseDir + "/node_modules/komada/src/commands/System/" + files[x] + ".js")) { - fs.unlinkSync(client.clientBaseDir + "/node_modules/komada/src/commands/System/" + files[x] + ".js"); - } - } -}; \ No newline at end of file diff --git a/utilities/dataManager.js b/utilities/dataManager.js new file mode 100644 index 0000000..72c8a02 --- /dev/null +++ b/utilities/dataManager.js @@ -0,0 +1,97 @@ +const sqlite = require("better-sqlite3"); +const dbDir = require("../assets/settings.json")["database"]; + +module.exports = (args, values, table) => { + let db = new sqlite(dbDir); + + switch (args) { + case "init": + const tableCheck = db.prepare("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='users';").get(); + + if(tableCheck["count(*)"]) return console.log("Check passed!"); + + db.prepare('CREATE TABLE users (userID TEXT, credits INTEGER, rep INTEGER, cooldowns TEXT, profiles TEXT)').run(); + db.prepare("CREATE TABLE awards (userID TEXT, suggest INTEGER, bugs INTEGER, minor INTEGER, major INTEGER)").run(); + db.prepare("CREATE TABLE stats (statName TEXT, count INTEGER)").run(); + + db.prepare("INSERT INTO awards (userID, suggest, bugs, minor, major) VALUES (?, ?, ?, ?, ?)").run("Overall", 0, 0, 0, 0); + db.prepare("INSERT INTO stats (statName, count) VALUES (?, ?)").run("report", 0); + + 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(); + return; + case "add": + data = db.prepare("SELECT * FROM users WHERE userID=?").get(values); + 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 awards (userID) VALUES (?)").run(values); + + db.prepare("INSERT INTO fishing (userID) VALUES (?)").run(values); + db.prepare("INSERT INTO harvest (userID) VALUES (?)").run(values); + db.prepare("INSERT INTO product (userID) VALUES (?)").run(values); + break; + case "select": + switch (table) { + case "users": + data = db.prepare("SELECT * FROM users WHERE userID=?").get(values); + break; + case "awards": + data = db.prepare("SELECT * FROM awards WHERE userID=?").get(values); + break; + case "fishing": + data = db.prepare("SELECT * FROM fishing WHERE userID=?").get(values); + break; + case "harvest": + data = db.prepare("SELECT * FROM harvest WHERE userID=?").get(values); + break; + case "product": + data = db.prepare("SELECT * FROM product WHERE userID=?").get(values); + break; + default: + console.log("ERROR: Table not found."); + return false; + } + + return data; + case "update": + switch (table) { + case "users": + db.prepare("UPDATE users SET " + values[0] + " WHERE userID=?").run(values[1]); + break; + case "awards": + db.prepare("UPDATE awards SET" + values[0] + " WHERE userID=?").run(values[1]); + break; + case "fishing": + db.prepare("UPDATE fishing SET " + values[0] + " WHERE userID=?").run(values[1]); + break; + case "harvest": + db.prepare("UPDATE harvest SET" + values[0] + " WHERE userID=?").run(values[1]); + break; + case "product": + db.prepare("UPDATE product SET " + values[0] + " WHERE userID=?").run(values[1]); + break; + default: + console.log("ERROR: Table not found."); + return false; + } + break; + case "delete": + data = db.prepare("SELECT * FROM users WHERE userID=?").get(values); + if (!data) return console.log("ERROR: This user doesn't exists"); + + db.prepare("DELETE FROM users WHERE userID=?").run(values); + db.prepare("DELETE FROM awards WHERE userID=?").run(values); + + db.prepare("DELETE FROM fishing WHERE userID=?").run(values); + db.prepare("DELETE FROM harvest WHERE userID=?").run(values); + db.prepare("DELETE FROM product WHERE userID=?").run(values); + break; + } +}; + +module.exports.help = { + name: "dataManager", + description: "Manages the SQLite database." +} \ No newline at end of file diff --git a/utilities/envCheck.js b/utilities/envCheck.js index 2a53402..7697a44 100644 --- a/utilities/envCheck.js +++ b/utilities/envCheck.js @@ -1,6 +1,6 @@ module.exports = () => { const { version: djsVersion } = require("discord.js"); - const { version: kVersion } = require("komada"); + const { version: kVersion } = require("klasa"); var missingDep = []; @@ -8,11 +8,14 @@ module.exports = () => { nVersion = Number(nVersion[0] + "." + nVersion[1]); if (djsVersion != "12.0.0-dev") { missingDep.push("You are not using the right discord.js package! Required version: v12.0.0-dev"); } - if (kVersion != "0.21.1") { missingDep.push("You are not using the right Komada version! Required version: v0.21.1"); } - if (nVersion < 8.0) { missingDep.push("You are not using the right node.js version! Required version: v8.5.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+"); } - var correctEnv = (missingDep.length > 0) ? false : true; - - if (correctEnv === false) { console.log(missingDep.join("\n")); process.exit(); } + if (missingDep.length > 0) { console.log(missingDep.join("\n")); process.exit(); } else { return; } +}; + +module.exports.help = { + name: "envCheck", + description: "Verifies the enviroment before running Margarine." }; \ No newline at end of file diff --git a/utilities/speechHelper.js b/utilities/speechHelper.js index be06772..9daf41b 100644 --- a/utilities/speechHelper.js +++ b/utilities/speechHelper.js @@ -1,27 +1,37 @@ const fs = require("fs"); -module.exports = function(msg, keys) { +module.exports = function(msg, keys, replace=[]) { if (!keys) { throw new Error("Keys missing in function call!"); } var name = keys[0]; if (name.startsWith("func-")) { var category = name.slice(5); } else { - var category = msg.client.commands.get(name).help.fullCategory; + var category = msg.client.commands.get(name).fullCategory; category = category[category.length - 1].toLowerCase(); } - var PATH = msg.client.clientBaseDir + "assets/speech/" + msg.guildSettings.lang + "/" + category + ".js"; + var PATH = msg.client.userBaseDirectory + "/assets/speech/" + msg.guild.settings.langSpeech + "/" + category + ".js"; if (fs.existsSync(PATH) === false) { - msg.channel.send("Whoops! Looks like I'm missing a file or two. Please contact the bot owner."); - throw new Error("Localization file is missing.\nLanguage: " + msg.guildSettings.lang + "\nCategory: " + category + "\nCommand: " + name); + throw new Error("Localization file is missing.\nLanguage: " + msg.guild.settings.langSpeech + "\nCategory: " + category + "\nCommand: " + name + "\n" + PATH); } var t = require(PATH); var n; if (name.startsWith("func-") === false) { t = t[name]; n = 1; } else { t = t[keys[1]]; n = 2; } for (var x = n; x < keys.length; x++) { t = t[keys[x]]; } - var text = t[Math.floor(Math.random() * t.length)]; var prefix = msg.guildSettings.prefix || msg.client.config.prefix; + var text = t[Math.floor(Math.random() * t.length)]; - msg.channel.send(text.replace("-prefix", prefix)); + if (replace.length > 0) { + for (var x = 0; x < replace.length; x++) { + text = text.replace(replace[x][0], replace[x][1]); + } + } + + return text.replace("-prefix", msg.guild.settings.prefix); +}; + +module.exports.help = { + name: "speechHelper", + description: "Picks a random speech line and sends it to the channel." }; \ No newline at end of file diff --git a/utilities/utilExport.js b/utilities/utilExport.js index f20dbd0..02f7079 100644 --- a/utilities/utilExport.js +++ b/utilities/utilExport.js @@ -1,3 +1,3 @@ exports.speech = require("./speechHelper.js"); -exports.remove = require("./commandRemover.js"); -exports.envCheck = require("./envCheck.js"); \ No newline at end of file +exports.envCheck = require("./envCheck.js"); +exports.dataManager = require("./dataManager.js"); \ No newline at end of file From 6348db92f00d9b01a1ac22d89326a9182ae4a78e Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Tue, 31 Dec 2019 21:13:30 -0500 Subject: [PATCH 27/38] More Utilities + Ready Event - Migrated presenceHelper and defaultChannel to Klasa - Added timekeeper utility - Migrated anime, greet, and report command - Report command moved into System category. - Added Ready event (Now can change presence every 15 minutes again) - Updated about command with the new utilities so time displays properly. --- commands/General/anime.js | 101 ++++++++++++++++++++---------------- commands/General/greet.js | 39 +++++++------- commands/General/report.js | 63 ---------------------- commands/System/about.js | 24 ++++----- commands/System/report.js | 61 ++++++++++++++++++++++ events/ready.js | 14 +++++ index.js | 19 ++++--- package-lock.json | 26 ++++------ package.json | 4 +- utilities/defaultChannel.js | 26 ++++++++++ utilities/presenceHelper.js | 33 ++++++++++++ utilities/timekeeper.js | 36 +++++++++++++ utilities/utilExport.js | 8 ++- 13 files changed, 289 insertions(+), 165 deletions(-) delete mode 100644 commands/General/report.js create mode 100644 commands/System/report.js create mode 100644 events/ready.js create mode 100644 utilities/defaultChannel.js create mode 100644 utilities/presenceHelper.js create mode 100644 utilities/timekeeper.js diff --git a/commands/General/anime.js b/commands/General/anime.js index 9b3895a..8bc51d1 100644 --- a/commands/General/anime.js +++ b/commands/General/anime.js @@ -1,54 +1,67 @@ -const AniListNode = require("anilist-node"); -const anilist = new AniListNode(); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); +const AnilistNode = require("anilist-node"); +const anilist = new AnilistNode(); -exports.run = async (client, msg, [term]) => { - if (!term) { return msg.channel.send(client.speech(msg, ["anime", "noSearch"])); } - var data = await anilist.search("anime", term, 1, 3); - data = await anilist.media.anime(data.media[0].id); - - if (!msg.channel.nsfw && data.isAdult) { return msg.channel.send(client.speech(msg, ["anime, nsfw"])); } +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "anime", + enabled: true, + runIn: ["text"], + cooldown: 30, + aliases: [], + requiredPermissions: ["ATTACH_FILES"], + description: "Search for anime on AniList", + usage: "[term:str]", + extendedHelp: "There is a 60 second cooldown for each search to not spam the site." + }); + } - title = data.title.romaji + " "; + async run(msg, [term]) { + if (!term) { return msg.channel.send(this.client.speech(msg, ["anime", "noSearch"])); } - if (data.title.english) { title = title + "| " + data.title.english; } + var data = await anilist.search("anime", term, 1, 3); + if (!data || !data.media) { return msg.channel.send(this.client.speech(msg, ["anime", "searchErr"])); } + data = await anilist.media.anime(data.media[0].id); - const embed = new client.methods.Embed() - .setTitle(title) - .setColor(0x2E51A2) - .setTimestamp() - .setThumbnail(data.coverImage.medium) - .setFooter("Data pulled from AniList"); + if (!msg.channel.nsfw && data.isAdult) { return this.client.speech(msg, ["anime, nsfw"]); } - desc = `[Anilist](${data.siteUrl}) | [MyAnimeList](https://myanimelist.net/anime/${data.idMal})\n\n**Format:** `; - time = data.season.charAt(0) + data.season.substring(1).toLowerCase() + " " + data.startDate.year; + var title = data.title.romaji; + if (data.title.english) { title = title + " | " + data.title.english; } - if (data.format === "MOVIE") { - desc = desc + data.format.charAt(0) + data.format.substring(1).toLowerCase() + `\n**Released:** ${time}\n**Runtime:** ${data.duration} minutes\n`; - } - else { - desc = desc + `${data.format}\n**Season:** ${time}\n**Episodes:** ${data.episodes} (${data.duration} minutes per episode)\n`; - } + var desc = `[Anilist](${data.siteUrl}) | [MyAnimeList](https://myanimelist.net/anime/${data.idMal})\n\n**Format:** `; + var time = data.season.charAt(0) + data.season.substring(1).toLowerCase() + " " + data.startDate.year; - desc = desc + `**Status:** ${data.status.charAt(0) + data.status.substring(1).toLowerCase()} - **Average Score:** ${data.meanScore} out of 100\n\n${data.description.replace(/
/g, "")}`; + if (data.format === "TV_SHORT") { data.format = "TV Short"; } + if (data.format === "SPECIAL") { data.format = "Special"; } + if (data.episodes === null) { data.episodes === "No episode count found"; } - embed.setDescription(desc); + var duration = (data.duration === null) ? "" : data.duration + " minutes"; + + if (data.format === "MOVIE") { + desc = desc + `Movie \n**Released:** ${time}\n**Runtime:** ${duration}\n`; + } else { + desc = desc + `${data.format}\n**Season:** ${time}\n**Episodes:** ${data.episodes}`; + if (duration.length > 1) { desc = desc + " (" + duration + " per episode)"; } + desc = desc + "\n"; + } + + if (data.status === "NOT_YET_RELEASED") { + desc = desc + `**Status:** Not yet released\n\n${data.description.replace(/
/g, "").replace(/<(i|\/i)>/g, "")}`; + } else { + desc = desc + `**Status:** ${data.status.charAt(0) + data.status.substring(1).toLowerCase()} + **Average Score:** ${data.meanScore} out of 100\n\n${data.description.replace(/
/g, "").replace(/<(i|\/i)>/g, "")}`; + } + + const embed = new MessageEmbed() + .setTitle(title) + .setColor(0x2E51A2) + .setTimestamp() + .setDescription(desc) + .setThumbnail(data.coverImage.medium) + .setFooter("Data pulled from AniList"); - msg.channel.send({embed}); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: ["ATTACH_FILES"], - cooldown: 30 -}; - -exports.help = { - name: "anime", - description: "Search for anime on AniList.", - usage: "[term:str]", humanUse: "(Search term)", - extendedHelp: "There is a 30 second cooldown for searches to not spam the site." + msg.channel.send({embed}); + } }; \ No newline at end of file diff --git a/commands/General/greet.js b/commands/General/greet.js index c5cf1c0..c1df3a1 100644 --- a/commands/General/greet.js +++ b/commands/General/greet.js @@ -1,23 +1,24 @@ -exports.run = async (client, msg, user) => { - var data = await client.funcs.userSearch(client, msg, user); - if (data === false) { return; } - if (data.id === client.user.id) { return msg.channel.send(client.speech(msg, ["greet", "me"]).replace("-user", msg.author.username)); } +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); +const AnilistNode = require("anilist-node"); +const anilist = new AnilistNode(); - var name = data.nickname || data.user.username; - msg.channel.send(client.speech(msg, ["greet", "success"]).replace("-user", name)); -}; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "greet", + enabled: true, + runIn: ["text"], + aliases: [], + description: "Have Margarine greet you or someone with a hello!", + usage: "[user:usersearch]" + }); + } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: ["userSearch"] -}; + async run(msg, [user]) { + if (user === null) { return; } + if (user.id === this.client.user.id) { return msg.send(this.client.speech(msg, ["greet", "me"], [["-param1", msg.author.username]])); } -exports.help = { - name: "greet", - description: "Have Margarine greet you or someone with a hello!", - usage: "[user:str]" + msg.send(this.client.speech(msg, ["greet", "success"], [["-param1", user.username]])); + } }; \ No newline at end of file diff --git a/commands/General/report.js b/commands/General/report.js deleted file mode 100644 index 30b23dc..0000000 --- a/commands/General/report.js +++ /dev/null @@ -1,63 +0,0 @@ -exports.run = async (client, msg) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.general); - - const reportTypes = { - issue: ["Issue", 0xFF0000], - bug: ["Bug", 0xFFFF00], - suggestion: ["Suggestion", 0xFFA500], - complaint: ["Complaint", 0xDB3E17], - todo: ["Todo", 0x04d5fd] - }; - - const filter = m => Object.keys(reportTypes).includes(m.content.toLowerCase()); - - await msg.reply(client.speech(msg, ["report", "start"])); - await msg.author.send(client.speech(msg, ["report", "q1"])).then(() => { - msg.author.dmChannel.awaitMessages(filter, { max: 1, time: 160000, errors: ["time"], }).then((collected) => { - var type = collected.first().content.toLowerCase(); - if (type === "todo" && msg.author.id !== client.owner.id) { return msg.author.send(client.speech(msg, ["report", "err1"])); } - - type = reportTypes[type]; - msg.author.send(client.speech(msg, ["report", "q2"])).then(() => { - msg.author.dmChannel.awaitMessages(m => m.content, { max: 1, time: 130000, errors: ["time"], }).then((desc) => { - db.get("SELECT reportNumber FROM stats WHERE statName = 'report'", [], (err, row) => { - if (err) { return console.log(err); } - - const embed = new client.methods.Embed() - .setTimestamp() - .setColor(type[0][1]) - .setTitle(`${type[0][0]} Report: ${row.reportNumber}`) - .setDescription(desc.first().content) - .setFooter(`Reported by: ${msg.author.tag} from ${msg.channel.guild.name}`, msg.author.displayAvatarURL()); - - const DMembed = new client.methods.Embed() - .setColor(0x00AE86) - .setTimestamp() - .setDescription(`**Report number:** ${row.reportNumber} \n**Issue:** ${desc.first().content} - \nYour report has been sent! Any more questions, please ask ${client.owner.tag}!`); - - db.run(`UPDATE stats SET reportNumber = ${row.reportNumber + 1} WHERE statName ="report"`); - client.channels.get(client.ownerSetting.get("channels").report).send({embed}); - msg.author.send({embed: DMembed}); - }); - db.close(); - }).catch(() => { msg.author.send(client.speech(msg, ["report", "timeout", "t2"])); }); - }); - }).catch(() => { msg.author.send(client.speech(msg, ["report", "timeout", "t1"])); }); - }); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "report", - description: "File a report to the bot developer. (ie: Bug, issue, complaint)", usage: "", - extendedHelp: "Margarine will be sliding into your DMs for a few questions. Be sure to have DMs open and ready to answer some questions!" -}; \ No newline at end of file diff --git a/commands/System/about.js b/commands/System/about.js index 8e90a28..39c1e15 100644 --- a/commands/System/about.js +++ b/commands/System/about.js @@ -1,12 +1,13 @@ const { Command } = require("klasa"); const { MessageEmbed } = require("discord.js"); +const { serverLink } = require("../../assets/settings.json"); module.exports = class extends Command { constructor(...args) { super(...args, { name: 'about', runIn: ['text', 'dm'], - aliases: ["stats", "dm"], + aliases: ["stats", "whoami"], guarded: true, description: 'General information', usage: "" @@ -14,24 +15,19 @@ module.exports = class extends Command { } async run(msg) { + var support = (serverLink && serverLink.length > 1) ? "| [Support Server](" + serverLink + ")" : ""; + const embed = new MessageEmbed() .setColor(0x37FDFC) .setTitle("About Me") - .setDescription(`[Github](https://github.com/Butterstroke/MargarineBot) | [Terms Of Service](https://github.com/Butterstroke/MargarineBot/blob/master/TermsOfService.md) - \nI am a very helpful and amazing bot! Doing ${prefix}help is great for finding ways I can assist you. I was written with Discord.js and Klasa, a Discord.js framework. - \n**Stats:** I have been online, helping out, for ${client.funcs.timeStamp(client, client.uptime)} using ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB of memory. ${client.users.size} users across ${client.guilds.size} guilds with ${client.channels.size.toLocaleString()} channels depend on my functions to be as reliable as possible! + .setDescription(`[Github](https://github.com/Butterstroke/MargarineBot) | [Terms Of Service](https://github.com/Butterstroke/MargarineBot/blob/master/TermsOfService.md) ${support} + \nI am a very helpful and amazing bot! Doing ${msg.guild.settings.prefix}help is great for finding ways I can assist you. I was written with Discord.js and Klasa, a Discord.js framework. + \n**Stats:** I have been online, helping out, for ${this.client.util.timekeeper.elapsedTime(this.client.uptime)} using ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB of memory. ${this.client.users.size} users across ${this.client.guilds.size} guilds with ${this.client.channels.size.toLocaleString()} channels depend on my functions to be as reliable as possible! \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 the ${dateMaker(this.client.user.createdAt)} by Butterstroke#7150.`) + \n**Creation:** I was created on the ${this.client.util.timekeeper.dateMaker(this.client.user.createdAt)} by Butterstroke#7150.`) .setThumbnail(this.client.user.displayAvatarURL()) - .setFooter("Running on Margarine " + client.ownerSetting.get("build").version + " | Released on: " + client.ownerSetting.get("build").releaseDate); + .setFooter("Running on Margarine " + this.client.ownerSetting.get("build").version + " | Released on: " + this.client.ownerSetting.get("build").releaseDate); msg.channel.send({embed}); } -}; - -function dateMaker(date) { - var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; - var d = date.toLocaleString().split(" ")[0].split("-"); - - return d[2] + " " + months[d[1]] + " " + d[0]; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/commands/System/report.js b/commands/System/report.js new file mode 100644 index 0000000..8f5f0cb --- /dev/null +++ b/commands/System/report.js @@ -0,0 +1,61 @@ +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "report", + enabled: true, + runIn: ["text"], + aliases: [], + requiredPermissions: ["EMBED_LINKS"], + description: "File a report to the bot owner. (ie: Bug, issue, complaint)", + usage: "", + extendedHelp: "Margarine will be sliding into your DMs for a few questions. Be sure to have DMs open and ready to answer some questions!" + }); + } + + async run(msg) { + const reportTypes = { + issue: ["Issue", 0xFF0000], + bug: ["Bug", 0xFFFF00], + suggestion: ["Suggestion", 0xFFA500], + complaint: ["Complaint", 0xDB3E17], + todo: ["Todo", 0x04d5fd] + }; + + const filter = m => Object.keys(reportTypes).includes(m.content.toLowerCase()); + + 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) => { + var type = collected.first().content.toLowerCase(); + if (type === "todo" && msg.author.id !== this.client.owner.id) { return msg.author.send(this.client.speech(msg, ["report", "err1"])); } + + type = reportTypes[type]; + msg.author.send(this.client.speech(msg, ["report", "q2"])).then(() => { + msg.author.dmChannel.awaitMessages(m => m.content, { max: 1, time: 130000, errors: ["time"], }).then((desc) => { + var reportNumber = this.client.dataManager("select", "report", "stats").count + 1; + + const embed = new MessageEmbed() + .setTimestamp() + .setColor(type[1]) + .setTitle(`${type[0]} Report: ${reportNumber}`) + .setDescription(desc.first().content) + .setFooter(`Reported by: ${msg.author.tag} from ${msg.channel.guild.name}`, msg.author.displayAvatarURL()); + + const DMembed = new MessageEmbed() + .setColor(0x00AE86) + .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); + msg.author.send({embed: DMembed}); + this.client.dataManager("update", ["count=" + reportNumber, "report"], "stats"); + }).catch(() => { msg.author.send(this.client.speech(msg, ["report", "timeout", "t2"])); }); + }); + }).catch(() => { msg.author.send(this.client.speech(msg, ["report", "timeout", "t1"])); }); + }); + } +}; \ No newline at end of file diff --git a/events/ready.js b/events/ready.js new file mode 100644 index 0000000..3292bc4 --- /dev/null +++ b/events/ready.js @@ -0,0 +1,14 @@ +const { Event } = require('klasa'); + +module.exports = class extends Event { + constructor(...args) { + super(...args, { + once: true, + event: 'klasaReady' + }); + } + + async run() { + this.client.util.presenceHelper(this.client, "-start"); //Initialize presence + } +}; \ No newline at end of file diff --git a/index.js b/index.js index baef6bf..b0bc360 100644 --- a/index.js +++ b/index.js @@ -2,13 +2,15 @@ const { Client } = require("klasa"); const Discord = require("discord.js"); const config = require("./assets/settings.json"); const util = require("./utilities/utilExport.js"); +const fs = require("fs"); -util.envCheck(); //Checks to make sure Margarine is running in the right environment. +util.envCheck(); //Checks to make sure Margarine is running in the right enviroment. const client = new Client({ fetchAllMembers: false, prefix: config.prefix, - commandEditing: true + commandEditing: true, + readyMessage: (client) => `This is ${client.user.username} speaking! Online and awaiting orders!\nI'm currently serving ${client.guilds.size} guilds and ${client.users.size} people!` }); Client.defaultPermissionLevels @@ -19,10 +21,16 @@ Client.defaultPermissionLevels client.gateways.guilds.schema .add("modRole", "role") - .add("langSpeech", "language", { default: "en-CA" }); + .add("langSpeech", "language", { default: "en-CA" }) + .add("defaultChannel", "channel"); client.speech = util.speech; client.dataManager = util.dataManager; +client.util = util.util; //All utility functions and extra search functions + +if (!fs.existsSync(config.database)) { //Init the SQLite Database + util.dataManager("init"); +} client.ownerSetting = new Discord.Collection(); @@ -37,12 +45,11 @@ for (var x = 0; keys.length > x; x++) { } client.ownerSetting.set("permLevel", config.permLevels); +client.ownerSetting.set("globalPrefix", config.prefix); client.database = { "items": require("./assets/values/items.json"), "recipes": require("./assets/values/recipes.json") }; -client.login(config.token).then(() => { - client.user.setPresence({ activity: { name: "m~help | Running the latest code!", type: "PLAYING" }, status: "online" }); -}); \ No newline at end of file +client.login(config.token); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8c7a4dd..7a0062a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,11 +54,6 @@ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, - "async-limiter": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", - "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -182,8 +177,8 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "discord.js": { - "version": "github:discordjs/discord.js#1b1289b35e2f8cd21341351549e6ac52fd08cb34", - "from": "github:discordjs/discord.js", + "version": "github:hydrabolt/discord.js#45b89710008d207da22000dcb633c0c0236db17e", + "from": "github:hydrabolt/discord.js", "requires": { "@discordjs/collection": "^0.1.1", "abort-controller": "^3.0.0", @@ -193,6 +188,13 @@ "setimmediate": "^1.0.5", "tweetnacl": "^1.0.1", "ws": "^7.2.0" + }, + "dependencies": { + "ws": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.1.tgz", + "integrity": "sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A==" + } } }, "dom-serializer": { @@ -447,7 +449,7 @@ }, "klasa": { "version": "github:dirigeants/klasa#0e9174cab0df7d28f3a7b8ca78b6344fef2611c9", - "from": "github:dirigeants/klasa#master", + "from": "github:dirigeants/klasa", "requires": { "fs-nextra": "^0.4.5" } @@ -794,14 +796,6 @@ "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=" }, - "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", - "requires": { - "async-limiter": "~1.0.0" - } - }, "yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/package.json b/package.json index f54d742..5882421 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "anilist-node": "^1.2.2", "better-sqlite3": "^5.4.3", "cheerio": "^1.0.0-rc.3", - "discord.js": "github:discordjs/discord.js", + "discord.js": "github:hydrabolt/discord.js", "ffmpeg": "0.0.4", - "klasa": "github:dirigeants/klasa#master", + "klasa": "github:dirigeants/klasa", "moment": "^2.24.0", "moment-duration-format": "^2.3.2", "ms": "^2.1.2", diff --git a/utilities/defaultChannel.js b/utilities/defaultChannel.js new file mode 100644 index 0000000..f2193fa --- /dev/null +++ b/utilities/defaultChannel.js @@ -0,0 +1,26 @@ +function locate(cList, name) { + var channelList = Array.from(cList); + for (var x = 0; x < channelList.length; x++) { + if (name.includes(channelList[x][1].name) && channelList[x][1].type === "text") { x = channelList.length; return channelList[x][1].id; } + if (x + 1 === channelList.length) { return false; } + } +} + +module.exports = (guild, args="default") => { + if (guild.settings.defaultChannel !== null && args === "default") { return guild.channels.get(guild.settings.defaultChannel); } + else if (guild.settings.modlog !== null && args === "mod") { return guild.channels.get(guild.settings.modlog); } + + var channelID = locate(Array.from(guild.channels), ["general", "general-chat", "off-topic"]); + if (channelID === false) { + var channels = Array.from(guild.channels.sort((e1, e2) => e1.rawPosition - e2.rawPosition)); + for (var x = 0; x < channels.length; x++) { + var currChannel = channels[x][1]; + if (currChannel.type === "text" && currChannel.permissionsFor(guild.members.get(this.client.user.id)).has("SEND_MESSAGES")) { + channelID = currChannel.id; + x = channels.length; + } + } + } + + return guild.channels.get(channelID); +}; \ No newline at end of file diff --git a/utilities/presenceHelper.js b/utilities/presenceHelper.js new file mode 100644 index 0000000..f47a3c1 --- /dev/null +++ b/utilities/presenceHelper.js @@ -0,0 +1,33 @@ +let games = require("../assets/localization.json")["games"]; + +module.exports = (client, name, type, status) => { + if (status === null) { status = "online"; } + if (type === null) { type = 0; } //A.K.A => play + + if (name === "-start" || name === "-reset") { + Presence(client, "play", "Playing around with " + client.owner.username, "online"); + client.timer = setInterval(function() { + do { //No duplicate statuses, Margarine. K thx. + var items = games[Math.floor(Math.random() * games.length)]; + } while (client.user.presence.activity.name !== null && items[0] === client.user.presence.activity.name.slice(9)); + + Presence(client, items[1], items[0], status); + }, 900000); + } else { + Presence(client, type, name, status); + clearInterval(client.timer); + } +}; + +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; + + client.user.setPresence({ activity: { name, type }, status }); +} + +module.exports.help = { + name: "presenceHelper", + description: "Sets and manages the bot's presence" +} \ No newline at end of file diff --git a/utilities/timekeeper.js b/utilities/timekeeper.js new file mode 100644 index 0000000..34ab19e --- /dev/null +++ b/utilities/timekeeper.js @@ -0,0 +1,36 @@ +function properLabel(time, label) { + if (time === 0) { return null; } + if (time === 1) { return " " + time + " " + label; } + + return " " + time + " " + label + "s"; +} + +module.exports = { + elapsedTime: (time) => { + var second = Math.floor(time / 1000); + var minute = Math.floor(second / 60); + var hour = Math.floor(minute / 60); + var day = Math.floor(hour / 24); + + //Time and display correction. + lblTime = [properLabel(second % 60, "second"), properLabel(minute % 60, "minute"), properLabel(hour % 24, "hour"), properLabel(day, "day")]; + lblTime = lblTime.filter(function(t) { return t; }); + if (lblTime.length > 1) { lblTime[0] = " and" + lblTime[0]; } //Adds an "and" to sound better in the display + lblTime.reverse(); + + if (lblTime.length === 2) { return lblTime.join(""); } //Commas for two items is bad English. + return lblTime.join(); + }, + + dateMaker: (date) => { + var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; + var d = date.toLocaleString().split(" ")[0].split("/"); + + return months[d[0]] + " " + d[1]+ ", " + d[2].slice(0, -1); + } +}; + +module.exports.help = { + name: "timekeeper", + description: "Creates a human readable time display out of timestamps.", +}; \ No newline at end of file diff --git a/utilities/utilExport.js b/utilities/utilExport.js index 02f7079..a8b4dc3 100644 --- a/utilities/utilExport.js +++ b/utilities/utilExport.js @@ -1,3 +1,9 @@ exports.speech = require("./speechHelper.js"); exports.envCheck = require("./envCheck.js"); -exports.dataManager = require("./dataManager.js"); \ No newline at end of file +exports.dataManager = require("./dataManager.js"); + +exports.util = { + defaultChannel: require("./defaultChannel.js"), + timekeeper: require("./timekeeper.js"), + presenceHelper: require("./presenceHelper.js") +} \ No newline at end of file From 9dc970eb486758362be2219d61df20ed5fd948a0 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Thu, 9 Jan 2020 22:01:35 -0400 Subject: [PATCH 28/38] Economy Commands + Additional Speech - Migrated all general economy commands - Removed old calulator commands - Added new owner command to change the avatar - Removed old functions that were migrated already - Removed a few speech files in favour of a singular file. - Added a few more lines of dialogue across a couple of commands and presence. - Moved report command's speech to the appropriate speech category file. --- assets/localization.json | 4 +- assets/speech/en-CA/cooking.js | 2 + assets/speech/en-CA/dataCheck.js | 36 +++++++++ assets/speech/en-CA/economy.js | 67 ++++------------ assets/speech/en-CA/general.js | 55 +++++-------- assets/speech/en-CA/lessCredit.js | 6 -- assets/speech/en-CA/noRow.js | 9 --- assets/speech/en-CA/system.js | 28 +++++++ commands/Economy/balance.js | 72 ++++++++--------- commands/Economy/daily.js | 102 +++++++++++------------- commands/Economy/exchange.js | 68 +++++++--------- commands/Economy/rep.js | 79 +++++++++--------- commands/General/Calculator/add.js | 28 ------- commands/General/Calculator/divide.js | 29 ------- commands/General/Calculator/multiply.js | 28 ------- commands/General/Calculator/subtract.js | 28 ------- commands/Owner/setAvatar.js | 21 +++++ functions/confAdd.js | 14 ---- functions/defaultChannel.js | 38 --------- functions/presenceHelper.js | 28 ------- functions/sqlTables.js | 37 --------- index.js | 8 +- 22 files changed, 271 insertions(+), 516 deletions(-) create mode 100644 assets/speech/en-CA/dataCheck.js delete mode 100644 assets/speech/en-CA/lessCredit.js delete mode 100644 assets/speech/en-CA/noRow.js create mode 100644 assets/speech/en-CA/system.js delete mode 100644 commands/General/Calculator/add.js delete mode 100644 commands/General/Calculator/divide.js delete mode 100644 commands/General/Calculator/multiply.js delete mode 100644 commands/General/Calculator/subtract.js create mode 100644 commands/Owner/setAvatar.js delete mode 100644 functions/confAdd.js delete mode 100644 functions/defaultChannel.js delete mode 100644 functions/presenceHelper.js delete mode 100644 functions/sqlTables.js diff --git a/assets/localization.json b/assets/localization.json index 6cc7dcd..c88efad 100644 --- a/assets/localization.json +++ b/assets/localization.json @@ -17,6 +17,8 @@ ["Having a romance comedy to myself!", "play"], ["Reaching for the blue sky", "play"], ["Someday, surely, for the sake of illuminating someone's path, I want to shine", "listen"], - ["Considering the possibilities of being an isekai protagonist", "play"] + ["Considering the possibilities of being an isekai protagonist", "play"], + ["Wakarimasen", "watch"], + ["At the end of a certain world, what runs through is real force", "listen"] ] } \ No newline at end of file diff --git a/assets/speech/en-CA/cooking.js b/assets/speech/en-CA/cooking.js index 2eb637c..ebe5692 100644 --- a/assets/speech/en-CA/cooking.js +++ b/assets/speech/en-CA/cooking.js @@ -1,3 +1,5 @@ +/* Speech for cooking specific commands */ + exports.craft = { "noItem": [ "You need to define an item to craft, baka!" diff --git a/assets/speech/en-CA/dataCheck.js b/assets/speech/en-CA/dataCheck.js new file mode 100644 index 0000000..1251956 --- /dev/null +++ b/assets/speech/en-CA/dataCheck.js @@ -0,0 +1,36 @@ +exports.noUser = [ //For when the target user does not exist in the database + "That user hasn't redeemed their first daily yet! :cry:", + "Sadly, that user does not like my games and didn't redeem their first daily yet.", + "Looks like this person has yet to redeem their first daily!", + "This person doesn't exist in my systems. Have they redeemed their first daily yet? Do they even like my games?", + "Oh... it looks like this person doesn't care for my games... they should redeem their first daily if they want to play.", +]; + +exports.noAccount = [ //When the user does not exist in the database + "You haven't redeemed your first daily yet! :cry:", + "You haven't signed up and received your credits yet! D:", + "You need some credits to do this, baka! Get some with the daily command!", + "Credits speak a whole lot of value in these parts. Set yourself up with a daily command first!", + "Get yourself some credits first!", + "Where are your credits?! Oh. You haven't redeemed your first daily yet...", + "Oh... you didn't redeem your first daily yet..." +]; + +exports.sameUser = [ //When the target is the user but command can't have the same + "Hey! You can't select yourself with this command!", + "Stop! Select someone else if you want to use this command!" +]; + +exports.cooldown = [ //When the user is too early to use a command. + "Trying to cash in early? I'm not having it! Wait it out, baka!", + "Trying to cheat and get something you already got today, are we now? Rude!", + "You've already redeemed yours today! Come back tomorrow!" +]; + +exports.lackCredits = [ //When the user doesn't have enough credits + "Looks like you don't have enough credits for that kind of spending.", + "You don't have that many credits, baka!", + "A poor person like yourself could never afford that bet.", + "Try paying in dirt. It's worth more than your bank right now.", + "Try to pull a fast one on me? Too bad you can't afford it, baka!" +]; \ No newline at end of file diff --git a/assets/speech/en-CA/economy.js b/assets/speech/en-CA/economy.js index 56903cc..35c1cf1 100644 --- a/assets/speech/en-CA/economy.js +++ b/assets/speech/en-CA/economy.js @@ -1,10 +1,6 @@ /*Speech for all commands in the general economy section*/ -exports.balance = [ //Only case is when there is no user in the system - "Looks like this person has yet to redeem their first daily!", - "This person doesn't exist in my systems. Have they redeemed their first daily yet? Do they even like my games?", - "Oh... it looks like this person doesn't care for my games... they should redeem their first daily if they want to play.", -]; +exports.balance = []; //Placeholder exports.daily = { "self": [ @@ -15,55 +11,20 @@ exports.daily = { "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!" - ], - "noRow": [ - "That user hasn't redeemed their first daily yet! :cry:", - "Sadly, that user does not like my games and didn't redeem their first daily yet." - ], - "noAccount": [ - "Nani?!?! You can't give other people credits if you haven't recieved your first daily yet!", - "You have not gotten your first daily yet!", - "You aren't in my records. You should redeem your first daily before giving to others.", - "Earn a bit yourself with the daily command before giving to others!" - ], - "multi": [ - "You are trying to cheat my daily command! Rude!", - "You've already redeemed a daily today, baka!", - "You have already redeemed your daily for today.", - "No stealing! I already payed your daily worth of credits today, baka!" + "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 = { - "self": [ - "Why are you trying to exchange credits to yourself? I doubt you are that lonely in life.", - "Oh? Trying to see if I would exchange your own credits? BAKA!" - ], - "default": [ - "-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.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 = { - "sameUser": [ - "You can't rep yourself! That's a bunch of nonsense!" - ], - "noSelfRow": [ - "Oh dear. You haven't redeemed your first daily yet..." - ], - "noCooldown": [ - "You can't rep someone yet! It hasn't been a full day yet!" - ], - "noTargetRow": [ - "Oh dear. That user hasn't redeemed their first daily yet..." - ], - "success": [ - "You have given -mention a reputation point!" - ] -}; +exports.rep = [ + "You have given -mention a reputation point!", + "One new, shiny reputation point for -mention has been given!" +]; diff --git a/assets/speech/en-CA/general.js b/assets/speech/en-CA/general.js index 76641c8..b9e2540 100644 --- a/assets/speech/en-CA/general.js +++ b/assets/speech/en-CA/general.js @@ -7,6 +7,9 @@ exports.anime = { "noSearch": [ "You're missing a search term, baka!" ], + "searchErr": [ + "Looks like AniList is having a bit of trouble right now. Come back and try again later." + ], "noResult": [ "There's not an anime by that name!" ], @@ -88,7 +91,7 @@ exports.greet = { "How rude, -param1! I'm not that lonely!", "Trying to make me seem lonely. Bad -param1!" ], - "success": [ //Parameter 1L Username + "success": [ //Parameter 1 Username "Why hello there, -param1!", "Hello, -param1! I hope you are doing well.", "And good day to you, -param1!" @@ -97,41 +100,19 @@ exports.greet = { exports.help = []; -exports.serverinfo = []; //Placeholder -exports.userinfo = []; //Placeholder - -exports.roleinfo = [ - "Looks like I can't find the role. Be sure it is spelled correctly.", - "Are you sure that exists? I don't think it does." -]; - -exports.mal = []; //Placeholder - -exports.report = { - "start": [ - "I'm going to be asking a couple of questions so I'll be taking this into your DMs.", - "Time for a questionaire! I'll be asking a couple questions in your DMs." +exports.info = { + "role": [ + "Looks like I can't find the role. Be sure it is spelled correctly.", + "Are you sure that exists? I don't think it does." ], - "q1": [ - "Alright. Let's get to the point. First question: What kind of issue is this?\nPlease answer `issue`, `bug`, `complaint`, or `suggestion`", - "What kind of issue are we talking about?\nPlease answer `issue`, `bug`, `complaint`, or `suggestion`" + "server": [ + "You can't ask information about a server with additional stuff!", + "I don't need these extra words. Leave out the extra words and ask for the server info." ], - "q2": [ - "Next: Please provide a decently sized message explaining the issue.", - "Next, I'm going to need a decently sized message explaining the issue." - ], - "err1": [ - "You are not able to send todo reports. Only the bot owner can.", - "You found a secret command word! Too bad only the bot owner can go past this point. Try again with a different word." - ], - "timeout": { - "t1": [ - "You didn't provide me with a description in time. I recommend either making your report shorter or copy pasting so that you don't have to try and type it so quickly.", - "Looks like you timed out but don't worry. Take your time finishing your message and then try again. I recommending copy pasting so you don't have to speed type it." - ], - "t2": [ - "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." - ] - } -}; \ No newline at end of file + "noTerm": [ + "You didn't give a correct search term. Do either server, user, or role.", + "Looks like you provided me with an incorrect search term. I need either server, user, or role." + ] +}; + +exports.mal = []; //Placeholder \ No newline at end of file diff --git a/assets/speech/en-CA/lessCredit.js b/assets/speech/en-CA/lessCredit.js deleted file mode 100644 index 9aa0720..0000000 --- a/assets/speech/en-CA/lessCredit.js +++ /dev/null @@ -1,6 +0,0 @@ -exports.lessCredit = [ - "You don't have that many credits, baka!", - "A poor person like yourself could never afford that bet.", - "Try paying in dirt. It's worth more than your bank right now.", - "Try to pull a fast one on me? Too bad you can't afford it, baka!" -]; \ No newline at end of file diff --git a/assets/speech/en-CA/noRow.js b/assets/speech/en-CA/noRow.js deleted file mode 100644 index 41595ba..0000000 --- a/assets/speech/en-CA/noRow.js +++ /dev/null @@ -1,9 +0,0 @@ -exports.noRow = [ - "You haven't redeemed your first daily yet! :cry:", - "You haven't signed up and received your credits yet! D:", - "You need some credits to do this, baka! Get some with the daily command!", - "Credits speak a whole lot of value in these parts. Set yourself up with a daily command first!", - "Get yourself some credits first!", - "Where are your credits?! Oh. You haven't redeemed your first daily yet...", - "Oh... you didn't redeem your first daily yet..." -]; \ No newline at end of file diff --git a/assets/speech/en-CA/system.js b/assets/speech/en-CA/system.js new file mode 100644 index 0000000..0bdc0f3 --- /dev/null +++ b/assets/speech/en-CA/system.js @@ -0,0 +1,28 @@ +exports.report = { + "start": [ + "I'm going to be asking a couple of questions so I'll be taking this into your DMs.", + "Time for a questionaire! I'll be asking a couple questions in your DMs." + ], + "q1": [ + "Alright. Let's get to the point. First question: What kind of issue is this?\nPlease answer `issue`, `bug`, `complaint`, or `suggestion`", + "What kind of issue are we talking about?\nPlease answer `issue`, `bug`, `complaint`, or `suggestion`" + ], + "q2": [ + "Next: Please provide a decently sized message explaining the issue.", + "Next, I'm going to need a decently sized message explaining the issue." + ], + "err1": [ + "You are not able to send todo reports. Only the bot owner can.", + "You found a secret command word! Too bad only the bot owner can go past this point. Try again with a different word." + ], + "timeout": { + "t1": [ + "You didn't provide me with a description in time. I recommend either making your report shorter or copy pasting so that you don't have to try and type it so quickly.", + "Looks like you timed out but don't worry. Take your time finishing your message and then try again. I recommending copy pasting so you don't have to speed type it." + ], + "t2": [ + "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." + ] + } +}; \ No newline at end of file diff --git a/commands/Economy/balance.js b/commands/Economy/balance.js index 08213c3..95ba9bc 100644 --- a/commands/Economy/balance.js +++ b/commands/Economy/balance.js @@ -1,50 +1,44 @@ -exports.run = async (client, msg, [user]) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.general); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); - var data = await client.funcs.userSearch(client, msg, {user: [user], tags:["bot"], name: this.help.name}); - if (data.valid === false) { return; } +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "balance", + enabled: true, + runIn: ["text"], + cooldown: 0, + aliases: ["bal", "credits", "profile"], + requiredPermissions: ["EMBED_LINKS"], + description: "Check credit amounts and cooldowns", + usage: "[user:usersearch]" + }); + } + + async run(msg, [user]) { + if (user === null) { return; } - db.get(`SELECT credits, dailies, rep FROM users WHERE userID = "${data.user[0].id}"`, [], (err, row) => { - if (err) { return console.log(err); } - if (!row) { return msg.reply(client.speech(["noRow"], msg)); } - var cooldown = JSON.parse(row.dailies); + var data = this.client.dataManager("select", user.id, "users"); + if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noUser"])); } + var cooldown = JSON.parse(data.cooldowns); let time = [((Date.now() - cooldown.credit) / 86400000), ((Date.now() - cooldown.rep) / 86400000)]; + for (var x = 0; x < 2; x++) { if (time[x] >= 14) { time.push((time[x]/7).toFixed(2) + " weeks"); } else if (time[x] >= 1) { time.push(time[x].toFixed(2) + " days"); } else { time.push((time[0] * 24).toFixed(2) + " hours"); } } - - client.users.fetch(data.user[0].id).then(avatar => { - const embed = new client.methods.Embed() - .setTimestamp() - .setFooter(msg.guild.name, msg.guild.iconURL()) - .setThumbnail(avatar.displayAvatarURL()) - .setColor(0x04d5fd) - .setAuthor(`User: ${data.user[0].username}`, avatar.displayAvatarURL()) - .setDescription(`ID: ${data.user[0].id}`) - .addField("Credits:", (row.credits).toLocaleString() + " (Last redeem: " + time[2] + " ago)") - .addField("Reputation:", row.rep + " (Last Rep: " + time[3] + " ago)"); - - msg.channel.send({embed}); - }); - }); - db.close(); -}; -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["bal", "credits", "profile"], - permLevel: 0, - botPerms: [], - requiredFuncs: ["userSearch"] -}; - -exports.help = { - name: "balance", - description: "Check credit amount and the last time the user recieved their daily.", - usage: "[user:str]", humanUse: "(user)" + const embed = new MessageEmbed() + .setTimestamp() + .setFooter(msg.guild.name, msg.guild.iconURL()) + .setThumbnail(user.displayAvatarURL()) + .setColor(0x04d5fd) + .setAuthor(`${user.username} | ${user.id}`) + .addField("Credits:", (data.credits).toLocaleString() + " (Last redeem: " + time[2] + " ago)") + .addField("Reputation:", data.rep + " (Last Rep: " + time[3] + " ago)"); + + msg.channel.send(embed); + } }; \ No newline at end of file diff --git a/commands/Economy/daily.js b/commands/Economy/daily.js index 7f737f5..8a9cf35 100644 --- a/commands/Economy/daily.js +++ b/commands/Economy/daily.js @@ -1,58 +1,48 @@ -const sqlite3 = require("sqlite3").verbose(); -let db = new sqlite3.Database("./assets/data/score.sqlite"); -let talk = require("../../assets/speech.json"); - -exports.run = async (client, msg, [user]) => { - var data = await client.funcs.userSearch(client, msg, {user: [user], tags:["bot"], name: this.help.name}); - if (data.valid === false) { return; } - user = data.user[0]; - - var type = (user.id === msg.author.id) ? "self" : "other"; - - var info = []; var talk1 = talk; - db.serialize(function() { - db.each(`SELECT daily, credits FROM scores WHERE userId IN ("${msg.author.id}", "${user.id}")`, [], function (err, row) { - if (err) { return console.log(err); } - if (row) { - if (Number(row.daily) + 86400000 > Date.now()) { info.push("multi"); } - else { info.push(type); } - } - info.push(row.credits); - }, function() { - if (info.length < 1) { - if (type === "self") { - client.funcs.sqlTables(user, "add"); - info.push(...["self", 100]); - } else if (type === "other") { info.push("noRow"); } - } - - if (info[2] !== "noRow") { talk1 = talk1["daily"]; } - var valid = (type !== info[0]) ? false : true; var x = 0; - - if (valid === true) { - var credit = (type === "other") ? Number((100 * (1 + Math.random())).toFixed(0)) : 100; - if (info[2] === "multi" || info[2] === "noRow") { var x = 2; } - else { - db.run(`UPDATE scores SET daily = ${Date.now()} WHERE userId = ${msg.author.id}`); - db.run(`UPDATE scores SET credits = ${info[1] + credit} WHERE userId = ${user.id}`); - } - } - msg.channel.send(talk1[info[x]][Math.floor(Math.random() * talk1[info[x]].length)].replace("-user-", user.prefered).replace("-credit-", credit)); +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "daily", + enabled: true, + runIn: ["text"], + cooldown: 0, + aliases: [], + description: "Get a daily amount of credits or give them to someone else.", + usage: "[user:usersearch]", }); - }); -}; - -exports.conf = { - enabled: true, - runIn: ["text", "dm"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: ["sqlTables", "userSearch"] -}; - -exports.help = { - name: "daily", - description: "Get a daily amount of credits or give them to someone else.", - usage: "[user:str]", humanUse: "(user)" + } + + async run(msg, [user]) { + if (user == null) { return; } + + var data = this.client.dataManager("select", msg.author.id, "users"); + if (!data && user.id != msg.author.id) { return msg.channel.send(this.client.speech(msg, ["daily", "noAccount"])); } + + if (!data) { + this.client.dataManager("add", msg.author.id); + return msg.channel.send(this.client.speech(msg, ["daily", "self"])); + } + + var cooldown = JSON.parse(data.cooldowns); + if ((cooldown.credit + 86400000) > Date.now()) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "cooldown"])); } + + 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"); + + return msg.channel.send(this.client.speech(msg, ["daily", "self"])); + } + + var tarData = this.client.dataManager("select", user.id, "users"); + if (!tarData) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noUser"])); } + + cooldown.credit = Date.now(); + + 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]])); + } }; \ No newline at end of file diff --git a/commands/Economy/exchange.js b/commands/Economy/exchange.js index 065b45f..447dc64 100644 --- a/commands/Economy/exchange.js +++ b/commands/Economy/exchange.js @@ -1,47 +1,35 @@ -exports.run = async (client, msg, [user, credit]) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/score.sqlite"); +const { Command } = require("klasa"); - var data = await client.funcs.userSearch(client, msg, {user: [null, user], tags:["bot"], name: this.help.name}); - if (data.valid === false) { return; } - user = data.user[1]; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "exchange", + enabled: true, + runIn: ["text"], + cooldown: 10, + aliases: [], + description: "Give someone some of your credits", + usage: "[user:usersearch] [credit:int]", usageDelim: " " + }); + } - if (user.id === msg.author.id) { return msg.channel.send("Why are you trying to exchange credits to yourself? I doubt you are that lonely in life."); } + async run(msg, [user, credit]) { + if (user == null) { return; } + if (user.id === msg.author.id) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "sameUser"])); } - db.get(`SELECT credits FROM scores WHERE userId = "${msg.author.id}"`, [], (err, row) => { - if (err) { return console.log(err); } - if (!row) { return msg.reply(client.speech(["noRow"])); } - if (row.credits < credit) { return msg.reply(client.speech(["lessCredit"])); } - - db.get(`SELECT credits FROM scores WHERE userId = "${user.id}"`, [], (err, row) => { - if (!row) { return msg.reply("That user has not gotten their first daily yet!"); } - db.run(`UPDATE scores SET credits = ${Number(row.credits) + credit} WHERE userId = ${user.id}`); - }); + 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 < credit) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "lackCredits"]))} + + var tarData = this.client.dataManager("select", user.id, "users"); + if (!tarData) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noUser"])); } - db.run(`UPDATE scores SET credits = ${Number(row.credits) - credit} WHERE userId = ${msg.author.id}`); - }); - db.close(); + data.credits -= credit; + tarData.credits += credit; - msg.channel.send(client.speech(["exchange"]) - .replace("-user1-", data.user[0].ping) - .replace("-user2-", user.prefered) - .replace("-credit-", credit) - ); -}; + this.client.dataManager("update", ["credits=" + tarData.credits, user.id], "users"); + this.client.dataManager("update", ["credits=" + data.credits, msg.author.id], "users"); -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: ["userSearch"], - cooldown: 10 -}; - -exports.help = { - name: "exchange", - description: "Give someone some of your credits.", - usage: "[user:str] [credit:int]", usageDelim: " ", - humanUse: "(Required: User)_(Required: Credit)" + msg.channel.send(this.client.speech(msg, ["exchange"], [["-user1", msg.author.username], ["-user2", "<@" + user.id + ">"], ["-credit", credit]])); + } }; \ No newline at end of file diff --git a/commands/Economy/rep.js b/commands/Economy/rep.js index fcbfd25..c9d3ea8 100644 --- a/commands/Economy/rep.js +++ b/commands/Economy/rep.js @@ -1,44 +1,41 @@ -const sqlite3 = require("sqlite3").verbose(); -let db = new sqlite3.Database("./assets/data/score.sqlite"); +const { Command } = require("klasa"); -exports.run = async (client, msg, [user, ...note]) => { - var data = await client.funcs.userSearch(client, msg, {user: [user], tags:["bot"], name: this.help.name}); - if (data.valid == false) { return; } - - user = data.user[0]; - if (user.id === msg.author.id) { return msg.channel.send("You can't give rep to yourself! That's like saying hire me for your nuclear plant because I'm a high school student!"); } - var mention = note ? user.tag : user.ping; - - db.get(`SELECT repDaily, rep FROM scores WHERE userId = "${msg.author.id}"`, [], (err, row) => { - if (err) { return console.log(err); } - if (!row) { return msg.reply(client.speech(["noRow"])); } - if ((Number(row.repDaily) + 86400000) > Date.now()) { return msg.reply("You've already have given someone else rep today!"); } - - db.get(`SELECT rep FROM scores WHERE userId = "${user.id}"`, [], (err, row) => { - if (!row) { return msg.channel.send("That user has not gotten their first daily to start off with so you can not give them any rep at the moment. :cry:"); } - - db.run(`UPDATE scores SET rep = ${row.rep + 1} WHERE userId = ${user.id}`); - db.run(`UPDATE scores SET repDaily = ${Date.now()} WHERE userId = ${msg.author.id}`); - if (note.trim().length > 0) { user.send("Delivery here! Someone has included a note with your rep!\n\n" + note.join(" ") + "\n-" + msg.author.tag); } - msg.channel.send("You have given " + mention + " a reputation point!"); +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "rep", + enabled: true, + runIn: ["text"], + aliases: [], + description: "Give someone a reputation point!", + usage: "[user:usersearch] [note:str]", usageDelim: "|" }); - }); - db.close(); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: ["userSearch"] -}; - -exports.help = { - name: "rep", - description: "Give someone a reputation point!", - usage: "[user:str] [note:str][...]", - usageDelim: " ", - humanUse: "(Required: User)_(Note)" + } + + async run(msg, [user, note]) { + if (user == null) { return; } + if (user.id === msg.author.id) { return msg.channel.send(this.client.speech(msg, ["func-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"])); } + + var tarData = this.client.dataManager("select", user.id, "users"); + if (!tarData) { return msg.channel.send(this.client.speech(msg, ["func-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"])); + } + + cooldown.rep = Date.now(); + + this.client.dataManager("update", ["rep=" + (tarData.rep + 1), user.id], "users"); + this.client.dataManager("update", ["cooldowns='" + JSON.stringify(cooldown) + "'", msg.author.id], "users"); + + if (note && note.trim().length > 0) { + 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 + ">"]])); + } }; \ No newline at end of file diff --git a/commands/General/Calculator/add.js b/commands/General/Calculator/add.js deleted file mode 100644 index f6c78b7..0000000 --- a/commands/General/Calculator/add.js +++ /dev/null @@ -1,28 +0,0 @@ -exports.run = async (client, message, [x, y, z]) => { - if (!x || !y) { return message.channel.send("You need two numbers to add, baka!"); } - x === client.funcs.constantMath(client, message, x); - y === client.funcs.constantMath(client, message, y); - - if (!z) { z = "0"; } - else { z = client.funcs.constantMath(client, message, z); } - - if ((x === null) || (y === null) || (z === null)) { return message.reply("You are trying to add things that aren't numbers or imaginary, baka!"); } - - message.channel.send(`Total: ${Number(x) + Number(y) + Number(z)}`); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: [], -}; - -exports.help = { - name: "add", - description: "Add up to three numbers together.", - usage: "[x:str] [y:str] [z:str]", - usageDelim: " ", -}; \ No newline at end of file diff --git a/commands/General/Calculator/divide.js b/commands/General/Calculator/divide.js deleted file mode 100644 index fb07dc5..0000000 --- a/commands/General/Calculator/divide.js +++ /dev/null @@ -1,29 +0,0 @@ -exports.run = async (client, message, [x, y, z]) => { - if (!x || !y) { return message.channel.send("You need two numbers to divide, baka!"); } - x === client.funcs.constantMath(client, message, x); - y === client.funcs.constantMath(client, message, y); - - if (!z) { z = "1"; } - else { z = client.funcs.constantMath(client, message, z); } - - if ((x === null) || (y === null) || (z === null)) { return message.reply("You are trying to divide things that aren't numbers or imaginary, baka!"); } - if ((y === 0) || (z === 0)) { return message.channel.send("Total: Undefined. Error: Divided by zero."); } - - message.channel.send(`Total: ${Number(x) / Number(y) / Number(z)}`); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: [], -}; - -exports.help = { - name: "divide", - description: "Divide up to three numbers together.", - usage: "[x:str] [y:str] [z:str]", - usageDelim: " ", -}; \ No newline at end of file diff --git a/commands/General/Calculator/multiply.js b/commands/General/Calculator/multiply.js deleted file mode 100644 index 9770055..0000000 --- a/commands/General/Calculator/multiply.js +++ /dev/null @@ -1,28 +0,0 @@ -exports.run = async (client, message, [x, y, z]) => { - if (!x || !y) { return message.channel.send("You need two numbers to multiply, baka!"); } - x === client.funcs.constantMath(client, message, x); - y === client.funcs.constantMath(client, message, y); - - if (!z) { z = "1"; } - else { z = client.funcs.constantMath(client, message, z); } - - if ((x === null) || (y === null) || (z === null)) { return message.reply("You are trying to multiply things that aren't numbers or imaginary, baka!"); } - - message.channel.send(`Total: ${Number(x) * Number(y ) * Number(z)}`); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: [], -}; - -exports.help = { - name: "multiply", - description: "Multiply up to three numbers together.", - usage: "[x:str] [y:str] [z:str]", - usageDelim: " ", -}; \ No newline at end of file diff --git a/commands/General/Calculator/subtract.js b/commands/General/Calculator/subtract.js deleted file mode 100644 index 82eb60e..0000000 --- a/commands/General/Calculator/subtract.js +++ /dev/null @@ -1,28 +0,0 @@ -exports.run = async (client, message, [x, y, z]) => { - if (!x || !y) { return message.channel.send("You need two numbers to subtract, baka!"); } - x === client.funcs.constantMath(client, message, x); - y === client.funcs.constantMath(client, message, y); - - if (!z) { z = "0"; } - else { z = client.funcs.constantMath(client, message, z); } - - if ((x === null) || (y === null) || (z === null)) { return message.reply("You are trying to subtract things that aren't numbers or imaginary, baka!"); } - - message.channel.send(`Total: ${Number(x) - Number(y) - Number(z)}`); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: [], -}; - -exports.help = { - name: "subtract", - description: "Subtract up to three numbers together. Note: (X-Y-Z)", - usage: "[x:str] [y:str] [z:str]", - usageDelim: " ", -}; \ No newline at end of file diff --git a/commands/Owner/setAvatar.js b/commands/Owner/setAvatar.js new file mode 100644 index 0000000..2fb652f --- /dev/null +++ b/commands/Owner/setAvatar.js @@ -0,0 +1,21 @@ +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "setavatar", + enabled: true, + runIn: ["text", "dm"], + aliases: [], + permissionLevel: 9, + description: "Set Margarine's avatar", + usage: "[image:str]" + }); + } + + async run(msg, [image]) { + this.client.user.setAvatar(image); + + msg.channel.send("I've updated my avatar image to the one you sent me."); + } +}; \ No newline at end of file diff --git a/functions/confAdd.js b/functions/confAdd.js deleted file mode 100644 index 5c5d9ae..0000000 --- a/functions/confAdd.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = async client => { - if (!client.settings.guilds.schema.modlog) { await client.settings.guilds.add("modlog", { type: "TextChannel" }); } - if (!client.settings.guilds.schema.defaultChannel) { await client.settings.guilds.add("defaultChannel", { type: "TextChannel"}); } - if (!client.settings.guilds.schema.lang) { await client.settings.guilds.add("lang", { type: "string", value: "en" }); } - if (!client.settings.guilds.schema.muteRole) { await client.settings.guilds.add("muteRole", {type: "role"}); } -}; - -module.exports.conf = { requiredModules: [] }; - -module.exports.help = { - name: "confAdd", - type: "functions", - description: "Adds all configurations nessessary.", -}; \ No newline at end of file diff --git a/functions/defaultChannel.js b/functions/defaultChannel.js deleted file mode 100644 index 67ba666..0000000 --- a/functions/defaultChannel.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = (client, guild, args) => { - if (!args) { args === "default"; } - - var channelID = schemaCheck(client, guild, args); - - if (channelID === false) { - channelID = locate(Array.from(guild.channels), ["general", "general-chat", "off-topic"]); - if (channelID === false) { - var channels = Array.from(guild.channels.sort((e1, e2) => e1.rawPosition - e2.rawPosition)); - for (var x = 0; x < channels.length; x++) { - var currChannel = channels[x][1]; - if (currChannel.type === "text" && currChannel.permissionsFor(guild.members.get(client.user.id)).has("SEND_MESSAGES")) { - channelID = currChannel.id; - x = channels.length; - } - } - } - } - - return guild.channels.get(channelID); -}; - -function schemaCheck(client, guild, args) { - var schema = client.settings.guilds.get(guild.id); - if(!schema.defaultChannel || !schema.modlog) { client.funcs.confAdd(client); } - - if(schema.defaultChannel !== null && args === "default") { return schema.defaultChannel; } - else if(schema.modlog !== null && args === "mod") { return schema.modlog; } - else { return false; } -}; - -function locate(cList, name) { - var channelList = Array.from(cList); - for (var x = 0; x < channelList.length; x++) { - if (name.includes(channelList[x][1].name) && channelList[x][1].type === "text") { x = channelList.length; return channelList[x][1].id; } - if (x + 1 === channelList.length) { return false; } - } -} \ No newline at end of file diff --git a/functions/presenceHelper.js b/functions/presenceHelper.js deleted file mode 100644 index eb09614..0000000 --- a/functions/presenceHelper.js +++ /dev/null @@ -1,28 +0,0 @@ -let games = require("../assets/localization.json")["games"]; - -module.exports = (client, name, type, status) => { - if (status === null) { status = "online"; } - if (type === null) { type = 0; } //A.K.A => play - - if (name === "-start" || name === "-reset") { - Presence(client, "play", "Playing around with " + client.owner.username, "online"); - client.timer = setInterval(function() { - do { //No duplicate statuses, Margarine. K thx. - var items = games[Math.floor(Math.random() * games.length)]; - } while (client.user.presence.activity.name !== null && items[0] === client.user.presence.activity.name.slice(9)); - - Presence(client, items[1], items[0], status); - }, 900000); - } else { - Presence(client, type, name, status); - clearInterval(client.timer); - } -}; - -function Presence(client, type, name, status) { - const tList = { "play": "PLAYING", "stream": "STREAMING", "listen": "LISTENING", "watch": "WATCHING" }; - type = tList[type]; - name = (name !== "-null") ? "m~help | " + name : null; - - client.user.setPresence({ activity: { name, type }, status }); -} \ No newline at end of file diff --git a/functions/sqlTables.js b/functions/sqlTables.js deleted file mode 100644 index cecaafe..0000000 --- a/functions/sqlTables.js +++ /dev/null @@ -1,37 +0,0 @@ -module.exports = (user, client) => { - const sqlite3 = require("sqlite3").verbose(); - let sql = new sqlite3.Database(client.database.inv); - let db = new sqlite3.Database(client.database.general); - - if (user == "-init") { - db.run("CREATE TABLE IF NOT EXISTS users (userID TEXT, credits INTEGER, level INTEGER, profiles TEXT, dailies TEXT, rep INTEGER)"); - db.run("CREATE TABLE IF NOT EXISTS awards (userID TEXT, suggest INTEGER, bugs INTEGER, minor INTEGER, major INTEGER)", [], (err, row) => { - if (err) { return console.log(err); } - db.run("INSERT INTO awards (userID, suggest, bugs, minor, major) VALUES (?, ?, ?, ?, ?)", ["Overall", 0, 0, 0, 0]); - }); - db.run("CREATE TABLE IF NOT EXISTS stats (statName TEXT, reportNumber INTEGER)", [], (row) => { - db.run("INSERT INTO stats (statName, count) VALUES (?, ?)", ["report", 0]); - }); - db.close(); - - sql.run("CREATE TABLE IF NOT EXISTS material (userID TEXT, trash INTEGER, fish INTEGER, crab INTEGER, squid INTEGER, shark INTERGER, potato INTERGER, egg INTERGER, bread INTERGER, chocolate INTERGER, greenapple INTERGER, apple INTERGER, lemon INTERGER, sake INTERGER, rice INTERGER)"); - sql.run("CREATE TABLE IF NOT EXISTS product (userID TEXT, fishcake INTEGER, cookie INTEGER, oden INTEGER, sushi INTEGER, recycle INTEGER)"); - sql.close(); - } else { - db.run("INSERT INTO users (userID, credits, level, dailies, rep) VALUES (?, ?, ?, ?, ?)", [user.id, 100, 0, JSON.stringify({ credit: Date.now(), rep: null }), 0]); - db.run("INSERT INTO awards (userID) VALUES (?)", [user.id]); - db.close(); - - sql.run("INSERT INTO material (userID) VALUES (?)", [user.id]); - sql.run("INSERT INTO product (userID) VALUES (?)", [user.id]); - sql.close(); - } -}; - -module.exports.conf = { requiredModules: [] }; - -module.exports.help = { - name: "sqlTables", - type: "functions", - description: "Creates a table if there is no table to store data on." -}; \ No newline at end of file diff --git a/index.js b/index.js index b0bc360..f268534 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,8 @@ const { Client } = require("klasa"); -const Discord = require("discord.js"); +const { Collection } = require("discord.js"); const config = require("./assets/settings.json"); const util = require("./utilities/utilExport.js"); -const fs = require("fs"); +const { existsSync } = require("fs"); util.envCheck(); //Checks to make sure Margarine is running in the right enviroment. @@ -28,11 +28,11 @@ client.speech = util.speech; client.dataManager = util.dataManager; client.util = util.util; //All utility functions and extra search functions -if (!fs.existsSync(config.database)) { //Init the SQLite Database +if (!existsSync(config.database)) { //Init the SQLite Database util.dataManager("init"); } -client.ownerSetting = new Discord.Collection(); +client.ownerSetting = new Collection(); var keys = Object.keys(config); for (var x = 0; keys.length > x; x++) { From cf436e2237f612594a1d87feccbef9c8a9abc530 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Fri, 10 Jan 2020 23:28:53 -0400 Subject: [PATCH 29/38] Cooking Module Migration - All cooking commands are migrated - Combined items and recipes JSON files and moved them up to the assets folder. - Fixed an issue with MAL profile images not showing up. - Edited some utility functions with documentation - Added a new utility function, toTitleCase --- assets/{values => }/items.json | 37 ++++++-- assets/speech/en-CA/cooking.js | 35 ++------ assets/speech/en-CA/dataCheck.js | 8 ++ assets/values/recipes.json | 25 ------ commands/Economy/Cooking/craft.js | 111 +++++++++++------------- commands/Economy/Cooking/fish.js | 86 +++++++++--------- commands/Economy/Cooking/harvest.js | 66 +++++++------- commands/Economy/Cooking/inventory.js | 120 +++++++++++++------------- commands/Economy/Cooking/sell.js | 59 ++++++------- commands/Economy/balance.js | 12 +-- commands/Economy/daily.js | 12 ++- commands/Economy/exchange.js | 10 +-- commands/Economy/rep.js | 10 +-- commands/General/avatar.js | 5 +- commands/General/mal.js | 28 +++--- index.js | 19 ++-- utilities/dataManager.js | 46 ++++++---- utilities/envCheck.js | 12 +-- utilities/speechHelper.js | 24 +++--- utilities/utilExport.js | 14 ++- 20 files changed, 363 insertions(+), 376 deletions(-) rename assets/{values => }/items.json (77%) delete mode 100644 assets/values/recipes.json diff --git a/assets/values/items.json b/assets/items.json similarity index 77% rename from assets/values/items.json rename to assets/items.json index 566bf9a..322fa6e 100644 --- a/assets/values/items.json +++ b/assets/items.json @@ -5,7 +5,10 @@ "name": "item_name", "emote": "item_emote", "category": "Table in DB", - "subcategory": "Any subcategory of the table" + "subcategory": "Any subcategory of the table", + "recipe": [ + ["material_name", "amount"] + ] } }, "trash": { @@ -98,34 +101,56 @@ "name": "fishcake", "emote": "šŸ„", "category": "product", - "subcategory": "food" + "subcategory": "food", + "recipe": [ + ["fish", 1], + ["potato", 1] + ] }, "cookie": { "sell": 25, "name": "cookie", "emote": "šŸŖ", "category": "product", - "subcategory": "food" + "subcategory": "food", + "recipe": [ + ["egg", 1], + ["bread", 1], + ["chocolate", 2] + ] }, "oden": { "sell": 125, "name": "oden", "emote": "šŸ¢", "category": "product", - "subcategory": "food" + "subcategory": "food", + "recipe": [ + ["sake", 1], + ["egg", 5], + ["squid", 1] + ] }, "sushi": { "sell": 75, "name": "sushi", "emote": "šŸ£", "category": "product", - "subcategory": "food" + "subcategory": "food", + "recipe": [ + ["fish", 1], + ["squid", 1], + ["rice", 2] + ] }, "recycle": { "sell": 44, "name": "recycle", "emote": "ā™»", "category": "product", - "subcategory": "misc" + "subcategory": "misc", + "recipe": [ + ["trash", 10] + ] } } \ No newline at end of file diff --git a/assets/speech/en-CA/cooking.js b/assets/speech/en-CA/cooking.js index ebe5692..df2feb1 100644 --- a/assets/speech/en-CA/cooking.js +++ b/assets/speech/en-CA/cooking.js @@ -1,36 +1,20 @@ /* Speech for cooking specific commands */ exports.craft = { - "noItem": [ - "You need to define an item to craft, baka!" - ], "noRecipe": [ "I couldn't find a recipe like that!" ], - "noRow": [ - "You need to redeem your first daily before you can do this, baka!" - ], - "lackAmount": [ - "You do not have enough -item! Please refer to the crafting guide to find out how much you need." - ], "success": [ "Oh! You've crafted -amount of -item!" ] }; -exports.fish = { - "noRow": [ - "It doesn't look like you've redeemed your first daily yet. You should do that and then come back." - ], - "noCredits": [ - "That's not enough credits to go fishing. Find some more and come back." - ], - "success": [ - "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." - ] -}; +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": [ @@ -46,16 +30,13 @@ exports.harvest = { ] }; -exports.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 = { - "noRow": [ - "You need to redeem your first daily before this!" - ], - "noAmount": [ + "notEnough": [ "You don't have enough of this to sell!" ], "success": [ diff --git a/assets/speech/en-CA/dataCheck.js b/assets/speech/en-CA/dataCheck.js index 1251956..7c0dfbf 100644 --- a/assets/speech/en-CA/dataCheck.js +++ b/assets/speech/en-CA/dataCheck.js @@ -33,4 +33,12 @@ exports.lackCredits = [ //When the user doesn't have enough credits "A poor person like yourself could never afford that bet.", "Try paying in dirt. It's worth more than your bank right now.", "Try to pull a fast one on me? Too bad you can't afford it, baka!" +]; + +exports.noItems = [ //When an item does not exist in the items.json file. + "Hmm... nope. Not finding that item here." +]; + +exports.noZero = [ //When a command requires a nonzero amount. + "Hey! You don't have any of this!" ]; \ No newline at end of file diff --git a/assets/values/recipes.json b/assets/values/recipes.json deleted file mode 100644 index 05cef97..0000000 --- a/assets/values/recipes.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "recipe_name": [ - ["material_name", "amount"] - ], - "fishcake": [ - ["fish", 1], - ["potato", 1] - ], - "cookie": [ - ["egg", 1], - ["bread", 1], - ["chocolate", 2] - ], - "oden": [ - ["sake", 1], - ["egg", 5], - ["squid", 1] - ], - "sushi": [ - ["fish", 1], - ["squid", 1], - ["rice", 2] - ], - "recycle": [ ["trash", 10] ] -} \ No newline at end of file diff --git a/commands/Economy/Cooking/craft.js b/commands/Economy/Cooking/craft.js index e35506f..b2a5a42 100644 --- a/commands/Economy/Cooking/craft.js +++ b/commands/Economy/Cooking/craft.js @@ -1,73 +1,66 @@ -exports.run = async (client, msg, [item, amount]) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.inv); - let items = client.database.items, - recipe = client.database.recipes; +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); - if (!item) { return msg.channel.send("You need to define an item to craft, baka!"); } - var product = items[item.toLowerCase()]; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "craft", + enabled: true, + runIn: ["text"], + aliases: ["cook"], + cooldown: 30, + description: "Make items", + usage: "[item:str] [amount:str]", usageDelim: " " + }); + } - recipe = recipe[item.toLowerCase()]; - if (!recipe) { return msg.channel.send("I couldn't find a recipe like that!"); } + async run(msg, [item=item.toLowerCase(), amount=1]) { + const itemDB = this.client.itemData; + let tarItem = itemDB[item]; + if (!tarItem) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noItems"])); } + if (!tarItem.recipe) { return msg.channel.send(this.client.speech(msg, ["craft", "noRecipe"])); } - if (amount === "help") { - var recipeList = []; - recipe.forEach(element => { recipeList.push(element[1] + " " + items[element[0]].emote); }); + if (amount === "help") { + var recipeList = []; + tarItem.recipe.forEach(element => { recipeList.push(`${element[1]} ${itemDB[element[0]].emote}`); }); + + const embed = new MessageEmbed() + .setTitle(`${this.client.util.toTitleCase(tarItem.name)} ${tarItem.emote}`) + .addField(`Category: ${this.client.util.toTitleCase(tarItem.category)}`, true) + .addField("Price:", `Buy: ${(tarData.buy || "N/A")} - Sell: ${tarData.sell}`, true) + .addField("Required items:", recipeList.join(", ")) + .setTimestamp() + .setFooter(msg.guild.name, msg.guild.iconURL()); - const embed = new client.methods.Embed() - .setTitle(client.funcs.toTitleCase(product.name) + " " + product.emote) - .addField("Type: " + client.funcs.toTitleCase(product.category[0]), "Subtype: " + client.funcs.toTitleCase(product.category[1]), true) - .addField("Price:", "Buy: " + product.price[0] + " - Sell: " + product.price[1], true) - .addField("Required items:", recipeList.join(", ")) - .setTimestamp() - .setFooter(msg.guild.name, msg.guild.iconURL()); + return msg.channel.send({embed}); + } - return msg.channel.send({embed}); - } else { - amount = amount ? Number(amount) : 1; + var prodData = this.client.dataManager("select", msg.author.id, "product"); + if (!prodData) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } + + var fishData = this.client.dataManager("select", msg.author.id, "fishing"); + var harvData = this.client.dataManager("select", msg.author.id, "harvest"); - client.funcs.validator({credit: amount, tags:["craft"]}, function(data) { - if (data.valid === false) { return msg.channel.send(data.msg); } + var rList = []; + tarItem.recipe.forEach(element => rList.push(itemDB[element[0]])); - let names = []; - recipe.forEach(element => { names.push(element[0]); }); + amount = amount ? Number(amount) : 1; - db.get(`SELECT ${names} FROM material WHERE userId = "${msg.author.id}"`, [], (err, row) => { - if (err) { return console.log(err); } - if (!row) { return msg.reply(client.speech(["noRow"], msg)); } - let invAmount = Object.values(row); + for (var x = 0; x < rList.length; x++) { + var catData = rList[x].category === "fishing" ? fishData : harvData; - for (var x = 0; x < recipe.length; x++) { - if ((amount * recipe[x][1]) > invAmount[x]) { return msg.channel.send("You do not have enough " + names[x] + "! Please refer to the crafting guide to find out how much you need."); } - } + if ((amount * tarItem.recipe[x][1]) > rList.category) { + return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noItems"], [["-item", rList[x].emote]])); + } - for (var x = 0; x < (recipe.length - 1); x++) { - db.run(`UPDATE material SET ${names[0]} = ${invAmount[x] - (amount * recipe[x][1])} WHERE userId = ${msg.author.id}`); - } + rList[x]["newAmount"] = catData[tarItem.recipe[x][0]] - (amount * tarItem.recipe[x][1]); + } - db.get(`SELECT ${product.name} FROM product WHERE userId ="${msg.author.id}"`, [], (err, row) => { - db.run(`UPDATE product SET ${product.name} = ${Object.values(row)[0] + amount} WHERE userId = ${msg.author.id}`); - }); + for (var x = 0; x < rList.length; x++) { + this.client.dataManager("update", [`${rList[x].name}=${rList[x].newAmount}`, msg.author.id], rList[x].category); + } - msg.channel.send(client.speech(["craft"], msg).replace("-num-", amount).replace("-item-", product.emote)); - }); - db.close(); - }); + this.client.dataManager("update", [`${tarItem.name}=${(prodData[tarItem.name] + amount)}`, msg.author.id], "product"); + msg.channel.send(this.client.speech(msg, ["craft", "success"], [["-amount", amount], ["-item", tarItem.emote]])); } -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["cook"], - permLevel: 0, - botPerms: [], - cooldown: 30 -}; - -exports.help = { - name: "craft", - description: "Make items!", - usage: "[item:str] [amount:str]", usageDelim: " ", - humanUse: "(item name)_(amount|help)" }; \ No newline at end of file diff --git a/commands/Economy/Cooking/fish.js b/commands/Economy/Cooking/fish.js index 0503bf5..8566b9d 100644 --- a/commands/Economy/Cooking/fish.js +++ b/commands/Economy/Cooking/fish.js @@ -1,48 +1,42 @@ -exports.run = async (client, msg) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.inv); - const items = client.database.items; - - client.funcs.transactions(msg, {credit: [1, "-", 11]}, function(data) { - if (data.valid === false) { return; } - - db.get(`SELECT * FROM material WHERE userId = "${msg.author.id}"`, [], (err, row) => { - if (err) { return console.log(err); } - var die = Math.random(); - - const Fisher = [ - ["trash", "fish", "crab", "squid", "shark"], - [0, row.fish, row.crab, row.squid, row.shark] - ]; - - if (die < .5) { var results = 0; } - else if (die < .75) { var results = 1; } - else if (die < .88) { var results = 2; } - else if (die < .98) { var results = 3; } - else { var results = 4; } - - var kind = Fisher[0][results]; - var result = (kind === "trash") ? "You have lost 10 credits" : "You have placed the fish in your inventory"; - - if (kind !== "trash") { db.run(`UPDATE material SET ${kind} = ${Number(Fisher[1][results]) + 1} WHERE userId = ${msg.author.id}`); } - msg.channel.send(client.speech(["fish"], msg).replace("-user1-", msg.author.username).replace("-fish-", items[kind].emote) + " " + result); +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "fish", + enabled: true, + runIn: ["text"], + aliases: [], + cooldown: 30, + description: "Fish and try to turn your credits into a fortune!", + extendedHelp: "Spend 10 credits to fish and catch yourself a fortune! (30 second cooldown)" }); - db.close(); - }); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - cooldown: 30 -}; - -exports.help = { - name: "fish", - description: "Fish and try to turn your credits into a fortune!", - usage: "", - extendedHelp: "Spend 10 credits to fish and catch yourself a fortune!" + } + + async run(msg) { + const items = this.client.itemData; + + 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 < 10) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "lackCredits"])); } + + const fishType = ["trash", "fish", "crab", "squid", "shark"]; + + var die = Math.random(); + + if (die < .5) { var results = 0; } + else if (die < .75) { var results = 1; } + else if (die < .88) { var results = 2; } + else if (die < .98) { var results = 3; } + else { var results = 4; } + + var kind = fishType[results]; + + var fishData = this.client.dataManager("select", msg.author.id, "fishing"); + + this.client.dataManager("update", [`${kind}=${(fishData[kind] + 1)}`, msg.author.id], "fishing"); + this.client.dataManager("update", [`credits=${(data.credits - 10)}`, msg.author.id], "users"); + + msg.channel.send(this.client.speech(msg, ["fish"], [["-kind", items[kind].emote]])); + } }; \ No newline at end of file diff --git a/commands/Economy/Cooking/harvest.js b/commands/Economy/Cooking/harvest.js index 35e2b3d..acf5b11 100644 --- a/commands/Economy/Cooking/harvest.js +++ b/commands/Economy/Cooking/harvest.js @@ -1,19 +1,28 @@ -exports.run = async (client, msg) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.inv); - const items = client.database.items; +const { Command } = require("klasa"); - client.funcs.transactions(msg, {credit: [1, "-", 11]}, function(data) { - if (data.valid === false) { return; } - }); +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "harvest", + enabled: true, + runIn: ["text"], + aliases: [], + cooldown: 30, + description: "Harvest fruits and other foods for cooking!", + extendedHelp: "Spend 10 credits to gather materials! (30 second cooldown)" + }); + } - db.get(`SELECT * FROM material WHERE userId = "${msg.author.id}"`, [], (err, row) => { - var die = Math.random(); + async run(msg) { + const items = this.client.itemData; + + 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 < 10) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "lackCredits"])); } - const itemName = [ - ["greenapple", "apple", "lemon", "potato", "bread", "rice", "egg", "chocolate"], - [row.greenapple, row.apple, row.lemon, row.potato, row.rice, row.egg, row.bread, row.chocolate] - ]; + const harvType = ["greenapple", "apple", "lemon", "potato", "bread", "rice", "egg", "chocolate"]; + + var die = Math.random(); if (die < .06) { var results = 0; } else if (die < .12) { var results = 1; } @@ -24,26 +33,13 @@ exports.run = async (client, msg) => { else if (die < .80) { var results = 6; } else { var results = 7; } - var item = items[itemName[0][results]]; - var name = (item.name === "green apple") ? "greenapple" : item.name; - - db.run(`UPDATE material SET ${name} = ${Number(itemName[1][results]) + 1} WHERE userId = ${msg.author.id}`); - - msg.channel.send(`${msg.author.username}, you have found ${item.emote}. The item has been placed in your inventory.`); - }); - db.close(); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - cooldown: 30 -}; - -exports.help = { - name: "harvest", - description: "Harvest fruits and other foods for cooking!", usage: "" + var item = harvType[results]; + + var harvData = this.client.dataManager("select", msg.author.id, "harvest"); + + this.client.dataManager("update", [`${item}=${(harvData[item] + 1)}`, msg.author.id], "harvest"); + this.client.dataManager("update", [`credits=${(data.credits - 10)}`, msg.author.id], "users"); + + msg.channel.send(this.client.speech(msg, ["harvest"], [["-kind", items[item].emote]])); + } }; \ No newline at end of file diff --git a/commands/Economy/Cooking/inventory.js b/commands/Economy/Cooking/inventory.js index b849e43..391e86e 100644 --- a/commands/Economy/Cooking/inventory.js +++ b/commands/Economy/Cooking/inventory.js @@ -1,67 +1,71 @@ -exports.run = async (client, msg) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.inv); - const items = client.database.items; +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); - const embed = new client.methods.Embed() - .setTimestamp() - .setColor(0x04d5fd) - .setFooter(msg.author.username + "'s Inventory", msg.author.avatarURL()); +function listMaker(data, items) { + var keys = Object.keys(data); + var result = []; - db.get(`SELECT * FROM material WHERE userId = "${msg.author.id}"`, [], (err, row) => { - if (err) { return console.log(err); } - if (!row) { return msg.channel.send(client.speech(["noRow"], msg)); } - - var amounts = Object.values(row); - var material = [[], [], []]; + for (var x = 1; x < keys.length; x++) { + if (data[keys[x]] > 0) { + result.push(`${data[keys[x]]} ${items[keys[x]].emote}`); + } + } + + if (result.length === 0) { return "You do not have any items in this category."; } + return result.join(", "); +} + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "inventory", + enabled: true, + runIn: ["text"], + aliases: ["inv"], + description: "Check your inventory for materials, produced goods, and more!" + }); + } + + async run(msg) { + const items = this.client.itemData; + const embed = new MessageEmbed() + .setTimestamp() + .setColor(0x04d5fd) + .setFooter(`${msg.author.username}'s Inventory`, msg.author.avatarURL()); + + var fishData = this.client.dataManager("select", msg.author.id, "fishing"); + if (!fishData) { return msg.channel.send(this.client.speech(msg, ["inventory"])); } - for (var x = 1; x < items.info.material_names.length; x++) { - var y = items.info.material_names[x]; - if (amounts[x] !== null && amounts[x] > 0) { - switch (items[y].category[1]) { - case "fishing": material[0].push(amounts[x] + items[y].emote); break; - case "harvest": material[1].push(amounts[x] + items[y].emote); break; - case "misc": material[2].push(amounts[x] + items[y].emote); break; - } - } + var harvData = this.client.dataManager("select", msg.author.id, "harvest"); + var prodData = this.client.dataManager("select", msg.author.id, "product"); + var materials = { "misc": [] }; + + if (fishData.trash > 0) { + materials["misc"].push(`${fishData.trash} ${items.trash.emote}`); + } + if (prodData.recycle > 0) { + materials["misc"].push(`${prodData.recycle} ${items.recycle.emote}`); } - if (material[0].length === 0) { material[0].push("You do not have any fish."); } - if (material[1].length === 0) { material[1].push("You do not have any harvest materials."); } - if (material[2].length === 0) { material[2].push("You do not have any misc materials."); } - embed.addField("Materials:", `__Fishing__\n${material[0].join(", ")}\n__Harvest__\n${material[1].join(", ")}\n__Misc__\n${material[2].join(", ")}`); - db.get(`SELECT * FROM product WHERE userId = "${msg.author.id}"`, [], (err, row) => { - var amount = Object.values(row); - var product = [[], []]; + if (!materials.misc || materials.misc.length === 0) { + materials.misc = "You do not have any items in this category."; + } else if (materials.misc.length === 1) { + materials.misc = materials.misc[0]; + } else { + materials.misc = materials.misc.join(", "); + } - for (var x = 1; x < items.info.product_names.length; x++) { - var y = items.info.product_names[x]; - if (amount[x] !== null && amount[x] > 0) { - switch (items[y].category[1]) { - case "food": product[0].push(amount[x] + items[y].emote); break; - case "material[2]": product[1].push(amount[x] + items[y].emote); break; - } - } - } - if (product[0].length === 0) { product[0].push("You do not have any food items."); } - if (product[1].length === 0) { product[1].push("You do not have any material[2] materials."); } - embed.addField("**Products:**", `__Food__\n${product[0].join(", ")}\n__material[2]__\n${product[1].join(", ")}`); + delete fishData.trash; //Remove for loop to process others + delete prodData.trash; - msg.channel.send({embed}); - }); - }); - db.close(); -}; + materials.fishing = listMaker(fishData, items); + materials.harvest = listMaker(harvData, items); + materials.product = listMaker(prodData, items); + + embed.addField("Materials:", `__Fishing__\n${materials.fishing}\n__Harvest__\n${materials.harvest}`); + embed.addField("Products:", materials.product); + embed.addField("Miscellaneous:", materials.misc); -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["inv"], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "inventory", - description: "Check your inventory for materials, produced goods, and more!", usage: "" + msg.channel.send({embed}); + } }; \ No newline at end of file diff --git a/commands/Economy/Cooking/sell.js b/commands/Economy/Cooking/sell.js index 8c75340..3e2aaed 100644 --- a/commands/Economy/Cooking/sell.js +++ b/commands/Economy/Cooking/sell.js @@ -1,35 +1,32 @@ -exports.run = async (client, msg, [item, amount]) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.inv); - let object = client.database.items[item.toLowerCase()]; - if (!object) { return msg.channel.send("That item does not exist."); } - - db.get(`SELECT ${object.name} FROM ${object.category[0]} WHERE userId = "${msg.author.id}"`, [], (err, row) => { - if (err) { return console.log(err); } - if (!row) { return msg.reply(client.speech(["noRow"], msg)); } - amount = (amount === undefined) ? Object.values(row)[0] : amount; - if (amount > row) { return msg.channel.send("You don't have that much " + object.name + ", baka!"); } - - db.run(`UPDATE ${object.category[0]} SET ${object.name} = ${Object.values(row)[0] - amount} WHERE userId = "${msg.author.id}"`); +const { Command } = require("klasa"); - client.funcs.transactions(msg, {credit: [1, "+", (object.price[1] * amount)]}, function(data) { - if (data.valid === false) { return; } - - msg.channel.send("You have sold " + amount + " " + object.name + " for " + data.earnings + " credits."); +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "sell", + enabled: true, + runIn: ["text"], + aliases: [], + description: "Sell your items!", + usage: " [amount:int]", usageDelim: " " }); - }); -}; + } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], -}; - -exports.help = { - name: "sell", - description: "Sell your items!", - usage: " [amount:int]", usageDelim: " " + async run(msg, [item=item.toLowerCase(), amount]) { + const itemDB = this.client.itemData[item]; + if (!itemDB) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noItems"])); } + + var data = this.client.dataManager("select", msg.author.id, "users"); + if (!data) { return this.client.speech(msg, ["func-dataCheck", "noAccount"]); } + + var itemData = this.client.dataManager("select", msg.author.id, itemDB.category); + if (!amount) { amount = itemData[item]; } + if (amount === 0 || !amount) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noZero"])); } + if (itemData[item] < amount) { return msg.channel.send(this.client.speech(msg, ["sell", "notEnough"])); } + + this.client.dataManager("update", [`credits=${(data.credits + (itemDB.sell * amount))}`, msg.author.id], "users"); + this.client.dataManager("update", [`${item}=${(itemData[item] - amount)}`, msg.author.id], itemDB.category); + + msg.channel.send(this.client.speech(msg, ["sell", "success"], [["-item", itemDB.emote], ["-amount", amount], ["-price", (itemDB.sell * amount)]])); + } }; \ No newline at end of file diff --git a/commands/Economy/balance.js b/commands/Economy/balance.js index 95ba9bc..6a4a65e 100644 --- a/commands/Economy/balance.js +++ b/commands/Economy/balance.js @@ -19,15 +19,15 @@ module.exports = class extends Command { if (user === null) { return; } var data = this.client.dataManager("select", user.id, "users"); - if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noUser"])); } + if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } var cooldown = JSON.parse(data.cooldowns); let time = [((Date.now() - cooldown.credit) / 86400000), ((Date.now() - cooldown.rep) / 86400000)]; for (var x = 0; x < 2; x++) { - if (time[x] >= 14) { time.push((time[x]/7).toFixed(2) + " weeks"); } - else if (time[x] >= 1) { time.push(time[x].toFixed(2) + " days"); } - else { time.push((time[0] * 24).toFixed(2) + " hours"); } + if (time[x] >= 14) { time.push(`${(time[x]/7).toFixed(2)} weeks`); } + else if (time[x] >= 1) { time.push(`${time[x].toFixed(2)} days`); } + else { time.push(`${(time[0] * 24).toFixed(2)} hours`); } } const embed = new MessageEmbed() @@ -36,8 +36,8 @@ module.exports = class extends Command { .setThumbnail(user.displayAvatarURL()) .setColor(0x04d5fd) .setAuthor(`${user.username} | ${user.id}`) - .addField("Credits:", (data.credits).toLocaleString() + " (Last redeem: " + time[2] + " ago)") - .addField("Reputation:", data.rep + " (Last Rep: " + time[3] + " ago)"); + .addField("Credits:", `${(data.credits).toLocaleString()} (Last redeem: ${time[2]} ago)`) + .addField("Reputation:", `${data.rep} (Last Rep: ${time[3]} ago)`); msg.channel.send(embed); } diff --git a/commands/Economy/daily.js b/commands/Economy/daily.js index 8a9cf35..f761802 100644 --- a/commands/Economy/daily.js +++ b/commands/Economy/daily.js @@ -6,7 +6,6 @@ module.exports = class extends Command { name: "daily", enabled: true, runIn: ["text"], - cooldown: 0, aliases: [], description: "Get a daily amount of credits or give them to someone else.", usage: "[user:usersearch]", @@ -14,10 +13,10 @@ module.exports = class extends Command { } async run(msg, [user]) { - if (user == null) { return; } + if (user === null) { return; } var data = this.client.dataManager("select", msg.author.id, "users"); - if (!data && user.id != msg.author.id) { return msg.channel.send(this.client.speech(msg, ["daily", "noAccount"])); } + if (!data && user.id !== msg.author.id) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } if (!data) { this.client.dataManager("add", msg.author.id); @@ -30,8 +29,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 + 100)}, cooldowns='${JSON.stringify(cooldown)}'`, msg.author.id], "users"); return msg.channel.send(this.client.speech(msg, ["daily", "self"])); } @@ -40,8 +38,8 @@ module.exports = class extends Command { cooldown.credit = Date.now(); - this.client.dataManager("update", ["credits=" + (tarData.credits + 100), user.id], "users"); - this.client.dataManager("update", ["cooldowns='" + JSON.stringify(cooldown) + "'", msg.author.id], "users"); + 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]])); } diff --git a/commands/Economy/exchange.js b/commands/Economy/exchange.js index 447dc64..7451f4b 100644 --- a/commands/Economy/exchange.js +++ b/commands/Economy/exchange.js @@ -14,12 +14,12 @@ module.exports = class extends Command { } async run(msg, [user, credit]) { - if (user == null) { return; } + if (user === null) { return; } if (user.id === msg.author.id) { return msg.channel.send(this.client.speech(msg, ["func-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.credits < credit) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "lackCredits"]))} + if (data.credits < credit) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "lackCredits"])); } var tarData = this.client.dataManager("select", user.id, "users"); if (!tarData) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noUser"])); } @@ -27,9 +27,9 @@ module.exports = class extends Command { data.credits -= credit; tarData.credits += credit; - this.client.dataManager("update", ["credits=" + tarData.credits, user.id], "users"); - this.client.dataManager("update", ["credits=" + data.credits, 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.channel.send(this.client.speech(msg, ["exchange"], [["-user1", msg.author.username], ["-user2", `<@${user.id}>`], ["-credit", credit]])); } }; \ No newline at end of file diff --git a/commands/Economy/rep.js b/commands/Economy/rep.js index c9d3ea8..96c66bf 100644 --- a/commands/Economy/rep.js +++ b/commands/Economy/rep.js @@ -13,7 +13,7 @@ module.exports = class extends Command { } async run(msg, [user, note]) { - if (user == null) { return; } + if (user === null) { return; } if (user.id === msg.author.id) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "sameUser"])); } var data = this.client.dataManager("select", msg.author.id, "users"); @@ -29,13 +29,13 @@ module.exports = class extends Command { cooldown.rep = Date.now(); - this.client.dataManager("update", ["rep=" + (tarData.rep + 1), user.id], "users"); - this.client.dataManager("update", ["cooldowns='" + JSON.stringify(cooldown) + "'", msg.author.id], "users"); + this.client.dataManager("update", [`rep=${(tarData.rep + 1)}`, user.id], "users"); + this.client.dataManager("update", [`cooldowns='${JSON.stringify(cooldown)}'`, msg.author.id], "users"); if (note && note.trim().length > 0) { - user.send("Delivery here! Someone has included a note with your rep!\n\n" + note.join(" ") + "\n-" + msg.author.tag); + 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.channel.send(this.client.speech(msg, ["rep"], [["-mention", `<@${user.id}>`]])); } }; \ No newline at end of file diff --git a/commands/General/avatar.js b/commands/General/avatar.js index aceefce..15a15cb 100644 --- a/commands/General/avatar.js +++ b/commands/General/avatar.js @@ -6,16 +6,15 @@ module.exports = class extends Command { name: "avatar", enabled: true, runIn: ["text"], - cooldown: 0, aliases: [], requiredPermissions: ["ATTACH_FILES"], description: "Fetch a user's avatar!", - usage: "[user:usersearch]", + usage: "[user:usersearch]" }); } async run(msg, [user]) { - if (user == null) { return; } + if (user === null) { return; } msg.channel.send("", { files: [user.displayAvatarURL()]}); } }; \ No newline at end of file diff --git a/commands/General/mal.js b/commands/General/mal.js index fbce407..004ff14 100644 --- a/commands/General/mal.js +++ b/commands/General/mal.js @@ -30,18 +30,18 @@ module.exports = class extends Command { if (z + y + zed === "404NotFound") { return msg.channel.send("Whoops! Looks like a user by that name does not exist."); } else if (z.length > 1) { if (z.startsWith("Online")) { - if (zed.startsWith("ago")) { info.status = z.slice(6) + " " + y + " ago"; } + if (zed.startsWith("ago")) { info.status = `${z.slice(6)} ${y} ago`; } else if (z.startsWith("OnlineNow")) { info.status = z.slice(6, z.search("Gender")); } - else if (zed.includes(":")) { info.status = z.slice(6) + " " + y + " " + (new Date()).getFullYear(); } + else if (zed.includes(":")) { info.status = `${z.slice(6)} ${y} ${(new Date()).getFullYear()}`; } else if (z.includes("Yesterday") || z.includes("Today") && zed.slice(1, 2) === "M") { - info.status = z.slice(6, -1) + " at " + y + zed.slice(0, 2); + info.status = `${z.slice(6, -1)} at ${y}${zed.slice(0, 2)}`; } - else if (isNaN(zed) === false) { info.status = z.slice(6) + " " + y + " " + zed; } + else if (isNaN(zed) === false) { info.status = `${z.slice(6)} ${y} ${zed}`; } } if (z.includes("Birthday") && !info.birthday) { var num = (z.length - z.search("Birthday")) * (-1); if (y.includes("Location")) { var baka = y.slice(0, y.search("Location")); } else { var baka = y.slice(-1) === "," ? y + " " + zed.slice(0, 4) : y; } - info.birthday = z.slice(num + 8) + " " + baka; + info.birthday = `${z.slice(num + 8)} ${baka}`; } if (z.includes("Gender")) { var amount = (z.search("Birthday")) ? z.search("Birthday") : null; @@ -83,21 +83,21 @@ module.exports = class extends Command { } while (x < text.length); var list = []; - if (info.gender) { list.push("šŸš» Gender: " + info.gender); } - if (info.birthday) { list.push("šŸŽ‚ Birthday: " + info.birthday); } - if (info.friends) { list.push("šŸ‘« Friends: " + info.friends); } + if (info.gender) { list.push(`šŸš» Gender: ${info.gender}`); } + if (info.birthday) { list.push(`šŸŽ‚ Birthday: ${info.birthday}`); } + if (info.friends) { list.push(`šŸ‘« Friends: ${info.friends}`); } const embed = new MessageEmbed() - .setTitle(term + "'s MAL Profile") + .setTitle(`${term}'s MAL Profile`) .setURL(url + term) - .setDescription("Last online: " + info.status); + .setDescription(`Last online: ${info.status}`); if (list.length > 0) { embed.addField("__General:__", list.join("\n")); } - embed.addField("__Anime:__", "šŸ•“ Days: " + info.aStats.days + " | šŸ“Š Mean: " + info.aStats.mean + "\nšŸ’š Watching: " + info.aStats.watch + "\nšŸ’™ Completed: " + info.aStats.completed + "\nšŸ’› On-Hold: " + info.aStats.hold + "\nšŸ’” Dropped: " + info.aStats.drop + "\nšŸ—“ Plan-to-Watch: " + info.aStats.plan, true) - .addField("__Manga:__", "šŸ•“ Days: " + info.mStats.days + " | šŸ“Š Mean: " + info.mStats.mean + "\nšŸ“— Reading: " + info.mStats.read + "\nšŸ“˜ Completed: " + info.mStats.completed + "\nšŸ“™ On-Hold: " + info.mStats.hold + "\nšŸ“• Dropped: " + info.mStats.drop + "\nšŸ—“ Plan-to-Read: " + info.mStats.plan, true) + embed.addField("__Anime:__", `šŸ•“ Days: ${info.aStats.days} | šŸ“Š Mean: ${info.aStats.mean}\nšŸ’š Watching: ${info.aStats.watch}\nšŸ’™ Completed: ${info.aStats.completed}\nšŸ’› On-Hold: ${info.aStats.hold}\nšŸ’” Dropped: ${info.aStats.drop}\nšŸ—“ Plan-to-Watch: ${info.aStats.plan}`, true) + .addField("__Manga:__", `šŸ•“ Days: ${info.mStats.days} | šŸ“Š Mean: ${info.mStats.mean}\nšŸ“— Reading: ${info.mStats.read}\nšŸ“˜ Completed: ${info.mStats.completed}\nšŸ“™ On-Hold: ${info.mStats.hold}\nšŸ“• Dropped: ${info.mStats.drop}\nšŸ—“ Plan-to-Read: ${info.mStats.plan}`, true) .setTimestamp() .setColor(0x2E51A2) - .setThumbnail(loadBody(".user-image").find("img")[0].attribs.src) - .setFooter("Requested by: " + msg.author.tag); + .setThumbnail(loadBody(".user-image").find("img")[0].attribs["data-src"]) + .setFooter(`Requested by: ${msg.author.tag}`); msg.channel.send({embed}); }); diff --git a/index.js b/index.js index f268534..df12c10 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,10 @@ const { Client } = require("klasa"); const { Collection } = require("discord.js"); const config = require("./assets/settings.json"); -const util = require("./utilities/utilExport.js"); +const { envCheck, speech, dataManager, util } = require("./utilities/utilExport.js"); const { existsSync } = require("fs"); -util.envCheck(); //Checks to make sure Margarine is running in the right enviroment. +envCheck(); //Checks to make sure Margarine is running in the right enviroment. const client = new Client({ fetchAllMembers: false, @@ -24,13 +24,11 @@ client.gateways.guilds.schema .add("langSpeech", "language", { default: "en-CA" }) .add("defaultChannel", "channel"); -client.speech = util.speech; -client.dataManager = util.dataManager; -client.util = util.util; //All utility functions and extra search functions +client.speech = speech; +client.dataManager = dataManager; +client.util = util; //All utility functions and extra search functions -if (!existsSync(config.database)) { //Init the SQLite Database - util.dataManager("init"); -} +if (!existsSync(config.database)) { dataManager("init"); } //Init the SQLite Database client.ownerSetting = new Collection(); @@ -47,9 +45,6 @@ for (var x = 0; keys.length > x; x++) { client.ownerSetting.set("permLevel", config.permLevels); client.ownerSetting.set("globalPrefix", config.prefix); -client.database = { - "items": require("./assets/values/items.json"), - "recipes": require("./assets/values/recipes.json") -}; +client.itemData = require("./assets/items.json"); client.login(config.token); \ No newline at end of file diff --git a/utilities/dataManager.js b/utilities/dataManager.js index 72c8a02..32a3a2b 100644 --- a/utilities/dataManager.js +++ b/utilities/dataManager.js @@ -1,16 +1,24 @@ const sqlite = require("better-sqlite3"); const dbDir = require("../assets/settings.json")["database"]; -module.exports = (args, values, table) => { +/** + * Manages the SQLite database + * @param { string } args - An action for the database. Either init, add, select, update, or delete + * @param { string[] } values - An array of values for the add, select, and update actions. + * Select needs one value, while both add and update need two. + * @param { string } table - Target table in the database. + * @returns {Object} If action was select. Returns null for all other options. +*/ +module.exports = function dataManager(args, values, table) { let db = new sqlite(dbDir); switch (args) { case "init": const tableCheck = db.prepare("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='users';").get(); - if(tableCheck["count(*)"]) return console.log("Check passed!"); + if(tableCheck["count(*)"]) { return console.log("SQLite Database exists! Skipping creation step..."); } //Prevent crashing if SQLite database exists already - db.prepare('CREATE TABLE users (userID TEXT, credits INTEGER, rep INTEGER, cooldowns TEXT, profiles TEXT)').run(); + db.prepare("CREATE TABLE users (userID TEXT, credits INTEGER, rep INTEGER, cooldowns TEXT, profiles TEXT)").run(); db.prepare("CREATE TABLE awards (userID TEXT, suggest INTEGER, bugs INTEGER, minor INTEGER, major INTEGER)").run(); db.prepare("CREATE TABLE stats (statName TEXT, count INTEGER)").run(); @@ -22,8 +30,8 @@ module.exports = (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": - data = db.prepare("SELECT * FROM users WHERE userID=?").get(values); - if (data) return console.log("ERROR: This user already exists"); + var data = db.prepare("SELECT * FROM users WHERE userID=?").get(values); + 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 awards (userID) VALUES (?)").run(values); @@ -33,6 +41,7 @@ module.exports = (args, values, table) => { db.prepare("INSERT INTO product (userID) VALUES (?)").run(values); break; case "select": + var data; switch (table) { case "users": data = db.prepare("SELECT * FROM users WHERE userID=?").get(values); @@ -49,6 +58,9 @@ module.exports = (args, values, table) => { case "product": data = db.prepare("SELECT * FROM product WHERE userID=?").get(values); break; + case "stats": + data = db.prepare("SELECT * FROM stats WHERE statName=?").get(values); + break; default: console.log("ERROR: Table not found."); return false; @@ -58,19 +70,22 @@ module.exports = (args, values, table) => { case "update": switch (table) { case "users": - db.prepare("UPDATE users SET " + values[0] + " WHERE userID=?").run(values[1]); + db.prepare(`UPDATE users SET ${values[0]} WHERE userID=?`).run(values[1]); break; case "awards": - db.prepare("UPDATE awards SET" + values[0] + " WHERE userID=?").run(values[1]); + db.prepare(`UPDATE awards SET ${values[0]} WHERE userID=?`).run(values[1]); break; case "fishing": - db.prepare("UPDATE fishing SET " + values[0] + " WHERE userID=?").run(values[1]); + db.prepare(`UPDATE fishing SET ${values[0]} WHERE userID=?`).run(values[1]); break; case "harvest": - db.prepare("UPDATE harvest SET" + values[0] + " WHERE userID=?").run(values[1]); + db.prepare(`UPDATE harvest SET ${values[0]} WHERE userID=?`).run(values[1]); break; case "product": - db.prepare("UPDATE product SET " + values[0] + " WHERE userID=?").run(values[1]); + db.prepare(`UPDATE product SET ${values[0]} WHERE userID=?`).run(values[1]); + break; + case "stats": + db.prepare(`UPDATE stats SET ${values[0]} WHERE statName=?`).run(values[1]); break; default: console.log("ERROR: Table not found."); @@ -78,8 +93,8 @@ module.exports = (args, values, table) => { } break; case "delete": - data = db.prepare("SELECT * FROM users WHERE userID=?").get(values); - if (!data) return console.log("ERROR: This user doesn't exists"); + var data = db.prepare("SELECT * FROM users WHERE userID=?").get(values); + if (!data) { return console.log("ERROR: This user doesn't exists"); } db.prepare("DELETE FROM users WHERE userID=?").run(values); db.prepare("DELETE FROM awards WHERE userID=?").run(values); @@ -89,9 +104,4 @@ module.exports = (args, values, table) => { db.prepare("DELETE FROM product WHERE userID=?").run(values); break; } -}; - -module.exports.help = { - name: "dataManager", - description: "Manages the SQLite database." -} \ No newline at end of file +}; \ No newline at end of file diff --git a/utilities/envCheck.js b/utilities/envCheck.js index 7697a44..b035446 100644 --- a/utilities/envCheck.js +++ b/utilities/envCheck.js @@ -1,4 +1,9 @@ -module.exports = () => { +/** + * Verifies the enviroment before running Margarine. + * If the enviroment check fails, program will terminate + * @returns { null } If enviroment check passes. + */ +module.exports = function envCheck() { const { version: djsVersion } = require("discord.js"); const { version: kVersion } = require("klasa"); @@ -13,9 +18,4 @@ module.exports = () => { if (missingDep.length > 0) { console.log(missingDep.join("\n")); process.exit(); } else { return; } -}; - -module.exports.help = { - name: "envCheck", - description: "Verifies the enviroment before running Margarine." }; \ No newline at end of file diff --git a/utilities/speechHelper.js b/utilities/speechHelper.js index 9daf41b..971e109 100644 --- a/utilities/speechHelper.js +++ b/utilities/speechHelper.js @@ -1,6 +1,13 @@ -const fs = require("fs"); - -module.exports = function(msg, keys, replace=[]) { +const { existsSync } = require("fs"); + +/** + * Picks a random speech line to simulate speech. + * @param {KlasaMessage} msg - Required. + * @param {Object[]} keys - Required. Value 0 is the command or function name for searching and Value 1 is the context. + * @param {Object[]} [replace] - Can be null. Any value to replace in the text. Denoted as a tuple [replace, new] for each item + * @returns {string} Randomly selected speech line. + */ +module.exports = function speech(msg, keys, replace=[]) { if (!keys) { throw new Error("Keys missing in function call!"); } var name = keys[0]; @@ -10,10 +17,10 @@ module.exports = function(msg, keys, replace=[]) { category = category[category.length - 1].toLowerCase(); } - var PATH = msg.client.userBaseDirectory + "/assets/speech/" + msg.guild.settings.langSpeech + "/" + category + ".js"; + var PATH = `${msg.client.userBaseDirectory}/assets/speech/${msg.guild.settings.langSpeech}/${category}.js`; - if (fs.existsSync(PATH) === false) { - throw new Error("Localization file is missing.\nLanguage: " + msg.guild.settings.langSpeech + "\nCategory: " + category + "\nCommand: " + name + "\n" + PATH); + if (existsSync(PATH) === false) { + throw new Error(`Localization file is missing.\nLanguage: ${msg.guild.settings.langSpeech}\nCategory: ${category}\nCommand: ${name}\n${PATH}`); } var t = require(PATH); var n; @@ -29,9 +36,4 @@ module.exports = function(msg, keys, replace=[]) { } return text.replace("-prefix", msg.guild.settings.prefix); -}; - -module.exports.help = { - name: "speechHelper", - description: "Picks a random speech line and sends it to the channel." }; \ No newline at end of file diff --git a/utilities/utilExport.js b/utilities/utilExport.js index a8b4dc3..06faaf5 100644 --- a/utilities/utilExport.js +++ b/utilities/utilExport.js @@ -1,3 +1,5 @@ +/* Exports all needed utilities for the client. */ + exports.speech = require("./speechHelper.js"); exports.envCheck = require("./envCheck.js"); exports.dataManager = require("./dataManager.js"); @@ -5,5 +7,13 @@ exports.dataManager = require("./dataManager.js"); exports.util = { defaultChannel: require("./defaultChannel.js"), timekeeper: require("./timekeeper.js"), - presenceHelper: require("./presenceHelper.js") -} \ No newline at end of file + presenceHelper: require("./presenceHelper.js"), + /** + * Returns a capitialized text string + * @param { String } text + * @return { String } + */ + toTitleCase: function(text) { + return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase(); + } +}; \ No newline at end of file From 3cf3b25a9568728ce3c4d9c6a3a2e43c5738e496 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Wed, 15 Jan 2020 18:47:20 -0400 Subject: [PATCH 30/38] More Utility Rework + Help & Kick Command - Migrated ModEmbed utility - Moved envCheck and defaultChannel functions into the utilExport file. Deleting the respective files. - Added a command remover to remove all conflicting commands within Klasa's source. - Migrated Kick and help commands. - Minor grammatical error in about fixed --- commands/General/help.js | 146 +++++++++++++-------------- commands/Mod/kick.js | 53 +++++----- commands/System/about.js | 2 +- index.js | 9 +- utilities/defaultChannel.js | 26 ----- utilities/envCheck.js | 21 ---- {functions => utilities}/modEmbed.js | 34 ++++--- utilities/presenceHelper.js | 17 ++-- utilities/timekeeper.js | 10 +- utilities/utilExport.js | 61 ++++++++++- 10 files changed, 199 insertions(+), 180 deletions(-) delete mode 100644 utilities/defaultChannel.js delete mode 100644 utilities/envCheck.js rename {functions => utilities}/modEmbed.js (52%) diff --git a/commands/General/help.js b/commands/General/help.js index 0866266..eaab959 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -1,30 +1,50 @@ -/* Base command is from the default Komada help command. This has been modified a bit */ -exports.run = async (client, msg, [cmd, mod]) => { - const method = client.user.bot ? "author" : "channel"; - const help = this.buildHelp(client, msg); - const categories = Object.keys(help); - const helpMessage = []; - const prefix = msg.guildSettings.prefix || client.config.prefix; +const { Command, util: { isFunction } } = require("klasa"); +const { MessageEmbed } = require("discord.js"); +const has = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key); - if (cmd === undefined) { - for (let cat = 0; cat < categories.length; cat++) { helpMessage.push(`- ${categories[cat]}`); } +/* This is a modified command from the default Klasa commands. */ +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "help", + enabled: true, + guarded: true, + runIn: ["text", "dm"], + aliases: ["commands"], + requiredPermissions: ["SEND_MESSAGES"], + description: "Displays help for a command", + usage: "[command:str] [mod:str]", usageDelim: " " + }); + } + + async run(msg, [cmd, mod]) { + const help = await this.buildHelp(msg); + + Object.assign(help["general"], help["General"]); //Combine system "General" and Margarine "general" + delete help["General"]; //Delete system "General" + + const categories = Object.keys(help); + const helpMessage = []; + + if (cmd === undefined) { + for (let cat = 0; cat < categories.length; cat++) { helpMessage.push(`- ${this.client.util.toTitleCase(categories[cat])}`); } - const embed = new client.methods.Embed() - .setColor(0x04d5fd) - .setTitle(`${client.user.username}'s Command Categories`) - .setDescription("*Do " + `\`${prefix}help module \`` + " for category commands.*") - .addField("Categories:", helpMessage); - return msg.send({embed}); - } if (cmd) { - if (cmd === "category" || cmd === "module") { + const embed = new MessageEmbed() + .setColor(0x04d5fd) + .setTitle(`${this.client.user.username}'s Command Categories`) + .setDescription("*Do " + `\`${msg.guild.settings.prefix}help module \`` + " for category commands.*") + .addField("Categories:", helpMessage); + + return msg.send({embed}); + } if (cmd === "category" || cmd === "module") { if (!mod) { return msg.send("You did not supply me with a category!"); } for (let cat = 0; cat < categories.length; cat++) { if (categories[cat].toLowerCase() === mod.toLowerCase()) { - helpMessage.push(`**${categories[cat]} Commands**: \`\`\`asciidoc`); + helpMessage.push(`**${this.client.util.toTitleCase(categories[cat])} Commands**: \`\`\`asciidoc`); const subCategories = Object.keys(help[categories[cat]]); for (let subCat = 0; subCat < subCategories.length; subCat++) { - helpMessage.push(`= ${subCategories[subCat]} =`, `${help[categories[cat]][subCategories[subCat]].join("\n")}\n`); + helpMessage.push(`= ${this.client.util.toTitleCase(subCategories[subCat])} =`, `${help[categories[cat]][subCategories[subCat]].join("\n")}\n`); } helpMessage.push("```"); @@ -33,64 +53,44 @@ exports.run = async (client, msg, [cmd, mod]) => { if (Number(cat) + 1 === categories.length) { msg.send("The category you were looking for does not exist."); break; } } } else { - cmd = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd)); + cmd = this.client.commands.get(cmd) || this.client.aliases.get(cmd); if (!cmd) { return msg.send("āŒ | Unknown command, please run the help command with no arguments to get a list of categories."); } - - if (!this.runCommandInhibitors(client, msg, cmd)) { return; } - var usage = cmd.help.humanUse ? [cmd.help.humanUse, "_"] : [cmd.help.usage, " "]; - var usageAct = usage.length < 1 ? "": usage[0].split(usage[1]).join(cmd.help.usageDelim); - var alias = cmd.conf.aliases.length > 0 ? ` aka: (${cmd.conf.aliases.join(", ")})`: ""; + var usage = cmd.humanUse ? [cmd.humanUse, "_"] : [cmd.usageString, " "]; + var usageAct = usage.length < 1 ? "": usage[0].split(usage[1]).join(cmd.usageDelim); + var alias = cmd.aliases.length > 0 ? ` aka: (${cmd.aliases.join(", ")})`: ""; - const embed = new client.methods.Embed() + const embed = new MessageEmbed() .setColor(0x04d5fd) - .setTitle(cmd.help.name + alias) - .setDescription(cmd.help.description) - .addField("Usage:", `\`${prefix + cmd.help.name + " " + usageAct}\``) - .addField("Permission level:", client.ownerSetting.get("permLevel").general[cmd.conf.permLevel]); - if (cmd.help.extendedHelp) { embed.addField("Extended Help:", cmd.help.extendedHelp); } + .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]); + if (cmd.extendedHelp) { embed.addField("Extended Help:", cmd.extendedHelp); } msg.send({embed}); } } -}; - -exports.conf = { - enabled: true, - runIn: ["text", "dm"], - aliases: ["commands"], - permLevel: 0, - botPerms: ["SEND_MESSAGES"] -}; - -exports.help = { - name: "help", - description: "Display help for a command.", - usage: "[command:str] [mod:str]", usageDelim: " ", - humanUse: "(command|module)_ ([If module] command)" -}; - -/* eslint-disable no-restricted-syntax, no-prototype-builtins */ -exports.buildHelp = (client, msg) => { - const help = {}; - const prefix = msg.guildSettings.prefix || client.config.prefix; - - const commandNames = Array.from(client.commands.keys()); - const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0); - - for (const command of client.commands.values()) { - if (this.runCommandInhibitors(client, msg, command)) { - const cat = command.help.category; - const subcat = command.help.subCategory; - if (!help.hasOwnProperty(cat)) { help[cat] = {}; } - if (!help[cat].hasOwnProperty(subcat)) { help[cat][subcat] = []; } - help[cat][subcat].push(`\u00A0${prefix}${command.help.name.padEnd(longest)} :: ${command.help.description}`); - } - } - - return help; -}; - -exports.runCommandInhibitors = (client, msg, command) => !client.commandInhibitors.some((inhibitor) => { - if (!inhibitor.conf.spamProtection && inhibitor.conf.enabled) { return inhibitor.run(client, msg, command); } - return false; -}); \ No newline at end of file + + async buildHelp(message) { + const help = {}; + + const { prefix } = message.guildSettings; + const commandNames = [...this.client.commands.keys()]; + const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0); + + await Promise.all(this.client.commands.map((command) => + this.client.inhibitors.run(message, command, true) + .then(() => { + if (!has(help, command.category)) help[command.category] = {}; + if (!has(help[command.category], command.subCategory)) help[command.category][command.subCategory] = []; + const description = isFunction(command.description) ? command.description(message.language) : command.description; + help[command.category][command.subCategory].push(`${prefix}${command.name.padEnd(longest)} :: ${description}`); + }) + .catch(() => { + // noop + }) + )); + + return help; + } +}; \ No newline at end of file diff --git a/commands/Mod/kick.js b/commands/Mod/kick.js index a0e1587..0fd9407 100644 --- a/commands/Mod/kick.js +++ b/commands/Mod/kick.js @@ -1,32 +1,31 @@ -exports.run = async (client, msg, [user, reason]) => { - user = await client.funcs.userSearch(client, msg, user); - if (user === false) { return; } +const { Command } = require("klasa"); - if (!reason) { return msg.reply("You must supply a reason!"); } - if (user.kickable === false) { return msg.reply("I cannot kick that member"); } +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "kick", + enabled: true, + runIn: ["text"], + aliases: ["k"], + permissionLevel: 2, + requiredPermissions: ["KICK_MEMBERS", "EMBED_LINKS"], + description: "Kicks the mentioned user.", + usage: " ", usageDelim: "," + }); + } - var data = await client.funcs.modEmbed(msg, "kick", user, reason); - - if (data.embed.thumbnail) { - await user.send({embed: data.DMembed}); - await user.kick(reason); - } + async run(msg, [user, reason]) { + if (user === null) { return; } + user = msg.guild.members.get(user.id); + if (user.kickable === false) { return msg.reply("I cannot kick that member"); } - var channel = client.funcs.defaultChannel(client, msg.guild, "mod"); - await channel.send({embed: data.embed}); -}; + var data = this.client.util.modEmbed(msg, "kick", user, reason); + + if (data.embed.thumbnail) { + await user.send({embed: data.DMembed}); + await user.kick(`Automated Action - Moderator: ${msg.author.username} | Reason: ${reason}`); + } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["k"], permLevel: 2, - botPerms: ["KICK_MEMBERS", "EMBED_LINKS"], - requiredFuncs: ["modEmbed", "userSearch"] -}; - -exports.help = { - name: "kick", - description: "Kicks the mentioned user.", - usage: "[user:str] [reason:str]", usageDelim: "|", - humanUse: "[user] [reason]" + this.client.util.defaultChannel(msg.guild, "mod").send({embed: data.embed}); + } }; \ No newline at end of file diff --git a/commands/System/about.js b/commands/System/about.js index 39c1e15..db0e937 100644 --- a/commands/System/about.js +++ b/commands/System/about.js @@ -24,7 +24,7 @@ module.exports = class extends Command { \nI am a very helpful and amazing bot! Doing ${msg.guild.settings.prefix}help is great for finding ways I can assist you. I was written with Discord.js and Klasa, a Discord.js framework. \n**Stats:** I have been online, helping out, for ${this.client.util.timekeeper.elapsedTime(this.client.uptime)} using ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB of memory. ${this.client.users.size} users across ${this.client.guilds.size} guilds with ${this.client.channels.size.toLocaleString()} channels depend on my functions to be as reliable as possible! \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 the ${this.client.util.timekeeper.dateMaker(this.client.user.createdAt)} by Butterstroke#7150.`) + \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); diff --git a/index.js b/index.js index df12c10..d2bfc41 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ const { Client } = require("klasa"); const { Collection } = require("discord.js"); const config = require("./assets/settings.json"); -const { envCheck, speech, dataManager, util } = require("./utilities/utilExport.js"); +const { envCheck, speech, dataManager, util, commandRemover } = require("./utilities/utilExport.js"); const { existsSync } = require("fs"); envCheck(); //Checks to make sure Margarine is running in the right enviroment. @@ -15,14 +15,15 @@ const client = new Client({ Client.defaultPermissionLevels .add(5, ({ guild, member }) => guild && member.roles.has(guild.settings.modRole)) - .add(6, ({ guild, member }) => guild && member.permissions.has('ADMINISTRATOR')) + .add(6, ({ guild, member }) => guild && member.permissions.has("ADMINISTRATOR")) .add(9, ({ author, client }) => author === client.owner || author.id === config.secondary) .add(10, ({ author, client }) => author === client.owner); client.gateways.guilds.schema .add("modRole", "role") .add("langSpeech", "language", { default: "en-CA" }) - .add("defaultChannel", "channel"); + .add("defaultChannel", "channel") + .add("modlog", "channel"); client.speech = speech; client.dataManager = dataManager; @@ -47,4 +48,6 @@ client.ownerSetting.set("globalPrefix", config.prefix); client.itemData = require("./assets/items.json"); +commandRemover(client); + client.login(config.token); \ No newline at end of file diff --git a/utilities/defaultChannel.js b/utilities/defaultChannel.js deleted file mode 100644 index f2193fa..0000000 --- a/utilities/defaultChannel.js +++ /dev/null @@ -1,26 +0,0 @@ -function locate(cList, name) { - var channelList = Array.from(cList); - for (var x = 0; x < channelList.length; x++) { - if (name.includes(channelList[x][1].name) && channelList[x][1].type === "text") { x = channelList.length; return channelList[x][1].id; } - if (x + 1 === channelList.length) { return false; } - } -} - -module.exports = (guild, args="default") => { - if (guild.settings.defaultChannel !== null && args === "default") { return guild.channels.get(guild.settings.defaultChannel); } - else if (guild.settings.modlog !== null && args === "mod") { return guild.channels.get(guild.settings.modlog); } - - var channelID = locate(Array.from(guild.channels), ["general", "general-chat", "off-topic"]); - if (channelID === false) { - var channels = Array.from(guild.channels.sort((e1, e2) => e1.rawPosition - e2.rawPosition)); - for (var x = 0; x < channels.length; x++) { - var currChannel = channels[x][1]; - if (currChannel.type === "text" && currChannel.permissionsFor(guild.members.get(this.client.user.id)).has("SEND_MESSAGES")) { - channelID = currChannel.id; - x = channels.length; - } - } - } - - return guild.channels.get(channelID); -}; \ No newline at end of file diff --git a/utilities/envCheck.js b/utilities/envCheck.js deleted file mode 100644 index b035446..0000000 --- a/utilities/envCheck.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Verifies the enviroment before running Margarine. - * If the enviroment check fails, program will terminate - * @returns { null } If enviroment check passes. - */ -module.exports = function envCheck() { - const { version: djsVersion } = require("discord.js"); - const { version: kVersion } = require("klasa"); - - var missingDep = []; - - var nVersion = process.version.split("v")[1].split("."); - nVersion = Number(nVersion[0] + "." + nVersion[1]); - - if (djsVersion != "12.0.0-dev") { missingDep.push("You are not using the right discord.js package! Required version: v12.0.0-dev"); } - 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 (missingDep.length > 0) { console.log(missingDep.join("\n")); process.exit(); } - else { return; } -}; \ No newline at end of file diff --git a/functions/modEmbed.js b/utilities/modEmbed.js similarity index 52% rename from functions/modEmbed.js rename to utilities/modEmbed.js index 3c7e2f1..10d81b0 100644 --- a/functions/modEmbed.js +++ b/utilities/modEmbed.js @@ -1,4 +1,14 @@ -module.exports = (msg, action, user, reason) => { +const { MessageEmbed } = require("discord.js"); + +/** + * Creates an embed for a moderation action. + * @param { KlasaMessage } msg - Required. + * @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. + * @returns { {embed: MessageEmbed, DMembed: MessageEmbed} } Returns two embeds in the form of a tuple. First one is for the moderation logs and the second one is for the user involved. + */ +module.exports = function(msg, action=action.toLowerCase(), user, reason) { const client = msg.client; const Options = { ban: ["BAN_MEMBERS", "banned", 0xDD2E44], @@ -6,8 +16,8 @@ module.exports = (msg, action, user, reason) => { kick: ["KICK_MEMBERS", "kicked", 0x00AE86] }; - const embed = new client.methods.Embed().setTimestamp(); - var options = Options[action.toLowerCase()]; + const embed = new MessageEmbed().setTimestamp(); + var options = Options[action]; if (msg.channel.permissionsFor(msg.author).has(options[0]) === false) { embed.setColor(0xDD2E44) @@ -19,25 +29,17 @@ module.exports = (msg, action, user, reason) => { .setDescription("I do not have the correct permissions for this command!"); } else { embed.setColor(options[2]) - .setTitle("**User " + options[1] + "!**") + .setTitle(`**User ${options[1]}!**`) .setDescription(reason) - .addField("**Moderator:**", msg.author.tag + " (" + msg.author.id + ")") - .addField("**User:**", user.user.tag + " (" + user.user.id + ")") + .addField("**Moderator:**", `${msg.author.tag} (${msg.author.id})`) + .addField("**User:**", `${user.user.tag} (${user.user.id})`) .setThumbnail(msg.author.displayAvatarURL()); } - const DMembed = new client.methods.Embed() + const DMembed = new MessageEmbed() .setColor(options[2]) - .setTitle("Moderator Message:") + .setTitle("Moderator Message") .setDescription(`You have been ${options[1]} from ${msg.guild.name}!\n**Reason:** ${reason}`); return { embed: embed, DMembed: DMembed }; -}; - -module.exports.conf = { requiredModules: [] }; - -module.exports.help = { - name: "modEmbed", - type: "functions", - description: "General embeder for moderation commands." }; \ No newline at end of file diff --git a/utilities/presenceHelper.js b/utilities/presenceHelper.js index f47a3c1..282c99e 100644 --- a/utilities/presenceHelper.js +++ b/utilities/presenceHelper.js @@ -1,11 +1,16 @@ let games = require("../assets/localization.json")["games"]; -module.exports = (client, name, type, status) => { - if (status === null) { status = "online"; } - if (type === null) { type = 0; } //A.K.A => play - +/** + * 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 { 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. + */ +module.exports = (client, name, type=0, status="online") => { //Type defaulted to play and status defaulted to online. if (name === "-start" || name === "-reset") { - Presence(client, "play", "Playing around with " + client.owner.username, "online"); + var items = games[Math.floor(Math.random() * games.length)]; //For random status upon startup + Presence(client, items[1], items[0], "online"); client.timer = setInterval(function() { do { //No duplicate statuses, Margarine. K thx. var items = games[Math.floor(Math.random() * games.length)]; @@ -22,7 +27,7 @@ module.exports = (client, name, type, status) => { 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.ownerSetting.get("globalPrefix")}help | ${name}` : null; client.user.setPresence({ activity: { name, type }, status }); } diff --git a/utilities/timekeeper.js b/utilities/timekeeper.js index 34ab19e..304ec41 100644 --- a/utilities/timekeeper.js +++ b/utilities/timekeeper.js @@ -1,8 +1,8 @@ function properLabel(time, label) { if (time === 0) { return null; } - if (time === 1) { return " " + time + " " + label; } + if (time === 1) { return ` ${time} ${label}`; } - return " " + time + " " + label + "s"; + return ` ${time} ${label}s`; } module.exports = { @@ -13,9 +13,9 @@ module.exports = { var day = Math.floor(hour / 24); //Time and display correction. - lblTime = [properLabel(second % 60, "second"), properLabel(minute % 60, "minute"), properLabel(hour % 24, "hour"), properLabel(day, "day")]; + var lblTime = [properLabel(second % 60, "second"), properLabel(minute % 60, "minute"), properLabel(hour % 24, "hour"), properLabel(day, "day")]; lblTime = lblTime.filter(function(t) { return t; }); - if (lblTime.length > 1) { lblTime[0] = " and" + lblTime[0]; } //Adds an "and" to sound better in the display + if (lblTime.length > 1) { lblTime[0] = ` and ${lblTime[0]}`; } //Adds an "and" to sound better in the display lblTime.reverse(); if (lblTime.length === 2) { return lblTime.join(""); } //Commas for two items is bad English. @@ -26,7 +26,7 @@ module.exports = { var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var d = date.toLocaleString().split(" ")[0].split("/"); - return months[d[0]] + " " + d[1]+ ", " + d[2].slice(0, -1); + return `${months[d[0]]} ${d[1]}, ${d[2].slice(0, -1)}`; } }; diff --git a/utilities/utilExport.js b/utilities/utilExport.js index 06faaf5..1a19823 100644 --- a/utilities/utilExport.js +++ b/utilities/utilExport.js @@ -1,13 +1,70 @@ +const { existsSync, unlinkSync } = require("fs"); +const { version: djsVersion } = require("discord.js"); +const { version: kVersion } = require("klasa"); /* Exports all needed utilities for the client. */ exports.speech = require("./speechHelper.js"); -exports.envCheck = require("./envCheck.js"); exports.dataManager = require("./dataManager.js"); +/** Removes any unnessesscary commands in the default Klasa framework. + * @param { KlasaClient } client + */ +exports.commandRemover = function(client) { + const cmdNames = ["Admin/load", "Admin/unload", "Admins/transfer", "General/Chat Bot Info/info", "General/Chat Bot Info/stats"]; + for(var x = 0; x < cmdNames.length; x++) { + if (existsSync(client.userBaseDirectory + "/node_modules/klasa/src/commands/" + cmdNames[x] + ".js")) { + unlinkSync(client.userBaseDirectory + "/node_modules/klasa/src/commands/" + cmdNames[x] + ".js"); + } + } +}; + +/** + * Verifies the enviroment before running Margarine. + * If the enviroment check fails, program will terminate + * @returns { null } If enviroment check passes. + */ +exports.envCheck = function() { + var missingDep = []; + + var nVersion = process.version.split("v")[1].split("."); + nVersion = Number(`${nVersion[0]}.${nVersion[1]}`); + + if (djsVersion !== "12.0.0-dev") { missingDep.push("You are not using the right discord.js package! Required version: v12.0.0-dev"); } + 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 (missingDep.length > 0) { console.log(missingDep.join("\n")); process.exit(); } +}; + exports.util = { - defaultChannel: require("./defaultChannel.js"), timekeeper: require("./timekeeper.js"), presenceHelper: require("./presenceHelper.js"), + 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. + * @returns { KlasaChannel } Returns a channel that best fits the arguements given. + */ + defaultChannel: function(guild, args="default") { + if (guild.settings.defaultChannel !== null && args === "default") { return guild.channels.get(guild.settings.defaultChannel); } + else if (guild.settings.modlog !== null && args === "mod") { return guild.channels.get(guild.settings.modlog); } + + var name = ["general", "general-chat", "off-topic"]; + var channelID = Array.from(guild.channels).filter(channel => name.includes(channel[1].name) && channel[1].type === "text"); + if (channelID.length > 0) { return channelID[0][1]; } + + var channels = Array.from(guild.channels.sort((e1, e2) => e1.rawPosition - e2.rawPosition)); + for (var x = 0; x < channels.length; x++) { + var currChannel = channels[x][1]; + if (currChannel.type === "text" && currChannel.permissionsFor(guild.members.get(this.client.user.id)).has("SEND_MESSAGES")) { + channelID = currChannel; + x = channels.length; + } + } + + return guild.channels.get(channelID.id); + }, /** * Returns a capitialized text string * @param { String } text From b2cc513c6b5018fb4d2b7dde438b4bd80e6e7a06 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Fri, 17 Jan 2020 16:11:12 -0400 Subject: [PATCH 31/38] Username Links + Ban Command - Modified both AniList and MAL commands to search based on users and return the profile if the user has linked it - Migrated Ban Command --- assets/speech/en-CA/general.js | 43 +++++++++++++++++++---- commands/General/anilist.js | 51 +++++++++++++++++++-------- commands/General/anime.js | 21 ++++++------ commands/General/help.js | 8 ++--- commands/General/mal.js | 63 +++++++++++++++++++++------------- commands/General/roleinfo.js | 3 +- commands/General/serverinfo.js | 3 +- commands/General/userinfo.js | 17 ++++----- commands/Mod/ban.js | 54 ++++++++++++++--------------- commands/Mod/kick.js | 14 ++++---- index.js | 3 +- utilities/modEmbed.js | 2 +- utilities/presenceHelper.js | 7 +--- utilities/utilExport.js | 8 ++--- 14 files changed, 174 insertions(+), 123 deletions(-) diff --git a/assets/speech/en-CA/general.js b/assets/speech/en-CA/general.js index b9e2540..930fa77 100644 --- a/assets/speech/en-CA/general.js +++ b/assets/speech/en-CA/general.js @@ -1,7 +1,38 @@ -exports.anilist = [ //Missing search term - "You forgot to include a search term!", - "Here is your result for nothing: \" \". Give me a search term next time, baka!" -]; +exports.anilist = { + "setProfile": [ //Activates upon a successful link of the user's AniList profile. + "You're all set! I have your username in my systems now!", + "āœ… Username added. You're good to go!" + ], + "noUsername": [ //User has a profile but has not set their AniList profile. + "Huh... that user appears to have not set their AniList profile in my systems yet.", + "They haven't set their AniList profile yet! Try a general search for now." + ], + "noTerm": [ //Missing search term + "You forgot to include a search term!", + "Here is your result for nothing: \" \". Give me a search term next time, baka!" + ], + "404Err": [ //Profile not found. Given a 404 error + "Anilist profile by that user is not found!" + ] +}; + +exports.mal = { + "setProfile": [ //Activates upon a successful link of the user's MAL profile. + "You're all set! I have your username in my systems now!", + "āœ… Username added. You're good to go!" + ], + "noUsername": [ //User has a profile but has not set their MAL profile. + "Huh... that user appears to have not set their MAL profile in my systems yet.", + "They haven't set their MAL profile yet! Try a general search for now." + ], + "noTerm": [ //Missing search term + "You forgot to include a search term!", + "Here is your result for nothing: \" \". Give me a search term next time, baka!" + ], + "404Err": [ //Profile not found. Given a 404 error + "MAL profile by that user is not found!" + ] +}; exports.anime = { "noSearch": [ @@ -113,6 +144,4 @@ exports.info = { "You didn't give a correct search term. Do either server, user, or role.", "Looks like you provided me with an incorrect search term. I need either server, user, or role." ] -}; - -exports.mal = []; //Placeholder \ No newline at end of file +}; \ No newline at end of file diff --git a/commands/General/anilist.js b/commands/General/anilist.js index 90c37b7..2368e9d 100644 --- a/commands/General/anilist.js +++ b/commands/General/anilist.js @@ -10,36 +10,57 @@ module.exports = class extends Command { enabled: true, runIn: ["text"], cooldown: 60, - aliases: [], requiredPermissions: ["ATTACH_FILES"], - description: "Fetch a data's profile on AniList", - usage: "[term:str]", - extendedHelp: "There is a 60 second cooldown for each profile search to not spam the site." + description: "Fetch a someone's profile on AniList.", + usage: "[set|search|user:usersearch] [username:str]", usageDelim: " ", + extendedHelp: "Note: The user must set their own account name in Margarine in order to search by a Discord user. For general searching, use the search keyword before the username." }); } - async run(msg, [term]) { - if (!term) { return msg.channel.send(this.client.speech(msg, ["anilist"])); } + async run(msg, [user, username]) { + if (user === "set") { + var data = this.client.dataManager("select", msg.author.id, "users"); + if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } - var data = await anilist.user.all(term); + var profiles = JSON.parse(data.profiles); + profiles.Anilist = username; - if (data.status === 404) { return msg.channel.send("Anilist profile by that user is not found!"); } + this.client.dataManager("update", [`profiles='${JSON.stringify(profiles)}'`, msg.author.id], "users"); + return msg.channel.send(this.client.speech(msg, ["anilist", "setProfile"])); //Success of setting profile. + } + + if (user === null) { return; } //Return for failed usersearch. + if (user === "search" & username === null) { return msg.channel.send(this.client.speech(msg, ["anilist", "noTerm"])); } + if (user !== "search") { //Replace username value with stored AniList username in Margarine. + var userData = this.client.dataManager("select", user.id, "users"); + if (!userData) { + if (user.id !== msg.author.id) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noUser"])); } + return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); + } + + username = JSON.parse(userData.profiles).Anilist; + if (!username) { return msg.channel.send(this.client.speech(msg, ["anilist", "noUsername"])); } + } + + var data = await anilist.user.all(username); + + if (data.status === 404) { return msg.channel.send(this.client.speech(msg, ["anilist", "404Err"])); } var anime = data.stats.animeStatusDistribution, manga = data.stats.mangaStatusDistribution; - var animeL = ["šŸ’š Watching: " + anime[0].amount, "šŸ—“ Planned: " + anime[1].amount, "šŸ’™ Completed: " + anime[2].amount, "šŸ’” Dropped: " + anime[3].amount, "šŸ’› Paused: " + anime[4].amount]; - var mangaL = ["šŸ“— Reading: " + manga[0].amount, "šŸ—“ Planned: " + manga[1].amount, "šŸ“˜ Completed: " + manga[2].amount, "šŸ“• Dropped: " + manga[3].amount, "šŸ“™ Paused: " + manga[4].amount]; + var animeL = [`šŸ’š Watching: ${anime[0].amount}`, `šŸ—“ Planned: ${anime[1].amount}`, `šŸ’™ Completed: ${anime[2].amount}`, `šŸ’” Dropped: ${anime[3].amount}`, `šŸ’› Paused: ${anime[4].amount}`]; + var mangaL = [`šŸ“— Reading: ${manga[0].amount}`, `šŸ—“ Planned: ${manga[1].amount}`, `šŸ“˜ Completed: ${manga[2].amount}`, `šŸ“• Dropped: ${manga[3].amount}`, `šŸ“™ Paused: ${manga[4].amount}`]; const embed = new MessageEmbed() - .setTitle(term + "'s AniList Profile") + .setTitle(`${username}'s AniList Profile`) .setURL(data.siteUrl) - .setDescription("šŸ•“ Watch Days: " + Number(data.stats.watchedTime / 60 / 24).toFixed(1) + "\nšŸ”– Manga Chapters: " + data.stats.chaptersRead) - .addField("__Anime:__", "šŸ“Š Mean Score: " + data.stats.animeListScores.meanScore + "\n" + animeL.join("\n"), true) - .addField("__Manga:__", "šŸ“Š Mean Score: " + data.stats.mangaListScores.meanScore + "\n" + mangaL.join("\n"), true) + .setDescription(`šŸ•“ Watch Days: ${Number(data.stats.watchedTime / 60 / 24).toFixed(1)}\nšŸ”– Manga Chapters: ${data.stats.chaptersRead}`) + .addField("__Anime:__", `šŸ“Š Mean Score: ${data.stats.animeListScores.meanScore}\n${animeL.join("\n")}`, true) + .addField("__Manga:__", `šŸ“Š Mean Score: ${data.stats.mangaListScores.meanScore}\n${mangaL.join("\n")}`, true) .setTimestamp() .setColor(0x2E51A2) .setThumbnail(data.avatar.large) - .setFooter("Requested by: " + msg.author.tag); + .setFooter(`Requested by: ${msg.author.tag}`); msg.channel.send({embed}); } diff --git a/commands/General/anime.js b/commands/General/anime.js index 8bc51d1..e82e6df 100644 --- a/commands/General/anime.js +++ b/commands/General/anime.js @@ -10,7 +10,6 @@ module.exports = class extends Command { enabled: true, runIn: ["text"], cooldown: 30, - aliases: [], requiredPermissions: ["ATTACH_FILES"], description: "Search for anime on AniList", usage: "[term:str]", @@ -28,29 +27,29 @@ module.exports = class extends Command { if (!msg.channel.nsfw && data.isAdult) { return this.client.speech(msg, ["anime, nsfw"]); } var title = data.title.romaji; - if (data.title.english) { title = title + " | " + data.title.english; } + if (data.title.english) { title = `${title} | ${data.title.english}`; } var desc = `[Anilist](${data.siteUrl}) | [MyAnimeList](https://myanimelist.net/anime/${data.idMal})\n\n**Format:** `; - var time = data.season.charAt(0) + data.season.substring(1).toLowerCase() + " " + data.startDate.year; + var time = `${this.client.util.toTitleCase(data.season)} ${data.startDate.year}`; if (data.format === "TV_SHORT") { data.format = "TV Short"; } if (data.format === "SPECIAL") { data.format = "Special"; } - if (data.episodes === null) { data.episodes === "No episode count found"; } + if (data.episodes === null) { data.episodes = "No episode count found"; } - var duration = (data.duration === null) ? "" : data.duration + " minutes"; + var duration = (data.duration === null) ? "" : `${data.duration} minutes`; if (data.format === "MOVIE") { - desc = desc + `Movie \n**Released:** ${time}\n**Runtime:** ${duration}\n`; + desc = `${desc}Movie \n**Released:** ${time}\n**Runtime:** ${duration}\n`; } else { - desc = desc + `${data.format}\n**Season:** ${time}\n**Episodes:** ${data.episodes}`; - if (duration.length > 1) { desc = desc + " (" + duration + " per episode)"; } - desc = desc + "\n"; + desc = `${desc}${data.format}\n**Season:** ${time}\n**Episodes:** ${data.episodes}`; + if (duration.length > 1) { desc = `${desc} (${duration} per episode)`; } + desc = `${desc}\n`; } if (data.status === "NOT_YET_RELEASED") { - desc = desc + `**Status:** Not yet released\n\n${data.description.replace(/
/g, "").replace(/<(i|\/i)>/g, "")}`; + desc = `${desc}**Status:** Not yet released\n\n${data.description.replace(/
/g, "").replace(/<(i|\/i)>/g, "")}`; } else { - desc = desc + `**Status:** ${data.status.charAt(0) + data.status.substring(1).toLowerCase()} + desc = `${desc}**Status:** ${this.client.util.toTitleCase(data.status)} **Average Score:** ${data.meanScore} out of 100\n\n${data.description.replace(/
/g, "").replace(/<(i|\/i)>/g, "")}`; } diff --git a/commands/General/help.js b/commands/General/help.js index eaab959..b6e9cdb 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -13,7 +13,7 @@ module.exports = class extends Command { aliases: ["commands"], requiredPermissions: ["SEND_MESSAGES"], description: "Displays help for a command", - usage: "[command:str] [mod:str]", usageDelim: " " + usage: "[module|command:str] [mod:str]", usageDelim: " " }); } @@ -36,7 +36,7 @@ module.exports = class extends Command { .addField("Categories:", helpMessage); return msg.send({embed}); - } if (cmd === "category" || cmd === "module") { + } if (cmd === "module") { if (!mod) { return msg.send("You did not supply me with a category!"); } for (let cat = 0; cat < categories.length; cat++) { @@ -81,8 +81,8 @@ module.exports = class extends Command { await Promise.all(this.client.commands.map((command) => this.client.inhibitors.run(message, command, true) .then(() => { - if (!has(help, command.category)) help[command.category] = {}; - if (!has(help[command.category], command.subCategory)) help[command.category][command.subCategory] = []; + if (!has(help, command.category)) { help[command.category] = {}; } + if (!has(help[command.category], command.subCategory)) { help[command.category][command.subCategory] = []; } const description = isFunction(command.description) ? command.description(message.language) : command.description; help[command.category][command.subCategory].push(`${prefix}${command.name.padEnd(longest)} :: ${description}`); }) diff --git a/commands/General/mal.js b/commands/General/mal.js index 004ff14..0a353a1 100644 --- a/commands/General/mal.js +++ b/commands/General/mal.js @@ -10,24 +10,47 @@ module.exports = class extends Command { enabled: true, runIn: ["text"], cooldown: 60, - aliases: ["choice"], requiredPermissions: ["ATTACH_FILES"], description: "Fetch a user's profile on MyAnimeList", - usage: "[term:str]", - extendedHelp: "There is a 60 second cooldown for each profile search to not spam the MAL site." + usage: "[set|search|user:usersearch] [username:str]", usageDelim: " ", + extendedHelp: "Note: The user must set their own account name in Margarine in order to search by a Discord user. For general searching, use the search keyword before the username." }); } - async run(msg, [term]) { - const url = "https://myanimelist.net/profile/"; + async run(msg, [user, username]) { + if (user === "set") { + var data = this.client.dataManager("select", msg.author.id, "users"); + if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } - request(url + term, function(err, res, body) { + var profiles = JSON.parse(data.profiles); + profiles.MAL = username; + + this.client.dataManager("update", [`profiles='${JSON.stringify(profiles)}'`, msg.author.id], "users"); + return msg.channel.send(this.client.speech(msg, ["mal", "setProfile"])); //Success of setting profile. + } + + if (user === null) { return; } //Return for failed usersearch. + if (user === "search" & username === null) { return msg.channel.send(this.client.speech(msg, ["mal", "noTerm"])); } + if (user !== "search") { //Replace username value with stored MAL username in Margarine. + var userData = this.client.dataManager("select", user.id, "users"); + if (!userData) { + if (user.id !== msg.author.id) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noUser"])); } + return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); + } + + username = JSON.parse(userData.profiles).MAL; + if (!username) { return msg.channel.send(this.client.speech(msg, ["mal", "noUsername"])); } + } + + const url = `https://myanimelist.net/profile/${username}`; + + request(url, function(err, res, body) { var loadBody = cheerio.load(body); var text = loadBody.text().split(" "); var x = 0; 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() : ""; - if (z + y + zed === "404NotFound") { return msg.channel.send("Whoops! Looks like a user by that name does not exist."); } + if (z + y + zed === "404NotFound") { return msg.channel.send(this.client.speech(msg, ["MAL", "404Err"])); } else if (z.length > 1) { if (z.startsWith("Online")) { if (zed.startsWith("ago")) { info.status = `${z.slice(6)} ${y} ago`; } @@ -38,18 +61,10 @@ module.exports = class extends Command { } else if (isNaN(zed) === false) { info.status = `${z.slice(6)} ${y} ${zed}`; } } if (z.includes("Birthday") && !info.birthday) { - var num = (z.length - z.search("Birthday")) * (-1); - if (y.includes("Location")) { var baka = y.slice(0, y.search("Location")); } - else { var baka = y.slice(-1) === "," ? y + " " + zed.slice(0, 4) : y; } - info.birthday = `${z.slice(num + 8)} ${baka}`; + info.birthday = `šŸŽ‚ Birthday: ${z.slice(-3)} ${y.slice(0, 2)}`; + if (y.search(",") > -1) { info.birthday += `, ${zed.slice(0, 4)}`; } } if (z.includes("Gender")) { - var amount = (z.search("Birthday")) ? z.search("Birthday") : null; - - if (z.startsWith("ago")) { var amount2 = 9; } - else if (z.startsWith("AM") || z.startsWith("PM")) { var amount2 = 8; } - else { var amount2 = 15; } - - info.gender = z.slice(amount2, amount); + info.gender = `šŸš» Gender: ${z.substring(z.search("Gender") + 6, z.toLowerCase().search("male") + 4)}`; } else if (z.startsWith("Watching") || z.startsWith("Reading")) { if (!info.aStats.watch || !info.mStats.read) { var num = [z.search("Completed"), z.search("On-Hold"), z.search("Dropped")]; @@ -67,7 +82,7 @@ module.exports = class extends Command { info.mStats.plan = zed.slice(4, -5); } } - } else if (z === "All" && !info.friends) { info.friends = y.slice(1, -8); } + } 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; } @@ -83,13 +98,13 @@ module.exports = class extends Command { } while (x < text.length); var list = []; - if (info.gender) { list.push(`šŸš» Gender: ${info.gender}`); } - if (info.birthday) { list.push(`šŸŽ‚ Birthday: ${info.birthday}`); } - if (info.friends) { list.push(`šŸ‘« Friends: ${info.friends}`); } + if (info.gender) { list.push(info.gender); } + if (info.birthday) { list.push(info.birthday); } + if (info.friends) { list.push(info.friends); } const embed = new MessageEmbed() - .setTitle(`${term}'s MAL Profile`) - .setURL(url + term) + .setTitle(`${username}'s MAL Profile`) + .setURL(url) .setDescription(`Last online: ${info.status}`); if (list.length > 0) { embed.addField("__General:__", list.join("\n")); } embed.addField("__Anime:__", `šŸ•“ Days: ${info.aStats.days} | šŸ“Š Mean: ${info.aStats.mean}\nšŸ’š Watching: ${info.aStats.watch}\nšŸ’™ Completed: ${info.aStats.completed}\nšŸ’› On-Hold: ${info.aStats.hold}\nšŸ’” Dropped: ${info.aStats.drop}\nšŸ—“ Plan-to-Watch: ${info.aStats.plan}`, true) diff --git a/commands/General/roleinfo.js b/commands/General/roleinfo.js index 5cd879c..1fb29cd 100644 --- a/commands/General/roleinfo.js +++ b/commands/General/roleinfo.js @@ -7,7 +7,6 @@ module.exports = class extends Command { name: "roleinfo", enabled: true, runIn: ["text"], - cooldown: 0, aliases: ["role"], description: "Get information on a role", usage: "[rolesrc:str]", @@ -22,7 +21,7 @@ module.exports = class extends Command { const embed = new MessageEmbed() .setTimestamp() - .setAuthor(role.name + " | " + role.id) + .setAuthor(`${role.name} | ${role.id}`) .setColor(role.hexColor) .addField("Position:", (msg.guild.roles.size - role.position), true) .addField("Hex Colour:", role.hexColor, true) diff --git a/commands/General/serverinfo.js b/commands/General/serverinfo.js index b45117a..73ab95c 100644 --- a/commands/General/serverinfo.js +++ b/commands/General/serverinfo.js @@ -7,7 +7,6 @@ module.exports = class extends Command { name: "serverinfo", enabled: true, runIn: ["text"], - cooldown: 0, aliases: ["server"], description: "Get your server's information", extendedHelp: "Need Discord info on your server? I got you covered!" @@ -20,7 +19,7 @@ module.exports = class extends Command { const embed = new MessageEmbed() .setTimestamp() .setColor(0x04d5fd) - .setAuthor(guild.name + " | " + guild.id) + .setAuthor(`${guild.name} | ${guild.id}`) .setThumbnail(guild.iconURL()) .addField("Region:", guild.region, true) .addField("Created:", guild.createdAt.toLocaleString(), true) diff --git a/commands/General/userinfo.js b/commands/General/userinfo.js index 3093d88..a2e0d0a 100644 --- a/commands/General/userinfo.js +++ b/commands/General/userinfo.js @@ -7,23 +7,20 @@ module.exports = class extends Command { name: "userinfo", enabled: true, runIn: ["text"], - cooldown: 0, aliases: ["user"], description: "Get a user's information", - usage: "[user:usersearch]", usageDelim: " ", + usage: "[user:usersearch]", extendedHelp: "Need Discord info on a specific user? I got you covered!" }); } - async run(message, [user]) { + async run(msg, [user]) { if (user === null) { return; } - - let guild = message.guild; - user = guild.members.get(user.id); + user = msg.guild.members.get(user.id); const embed = new MessageEmbed() .setTimestamp() - .setFooter(guild.name, guild.iconURL()); + .setFooter(msg.guild.name, msg.guild.iconURL()); const statusList = { online: "online", @@ -56,8 +53,8 @@ module.exports = class extends Command { } embed.setThumbnail(user.user.displayAvatarURL()) - .setAuthor(user.user.tag + " | " + user.id) - .setDescription("Currently " + Status + activity) + .setAuthor(`${user.user.tag} | ${user.id}`) + .setDescription(`Currently ${Status}${activity}`) .addField("ID: ", user.id, true) .addField("Bot user:", user.user.bot ? "True": "False", true) .addBlankField(true) @@ -65,6 +62,6 @@ module.exports = class extends Command { .addField("Joined:", user.joinedAt.toLocaleString(), true) .setColor(0x04d5fd); - message.channel.send({embed}); + msg.channel.send({embed}); } }; \ No newline at end of file diff --git a/commands/Mod/ban.js b/commands/Mod/ban.js index df14162..d4c28a3 100644 --- a/commands/Mod/ban.js +++ b/commands/Mod/ban.js @@ -1,33 +1,29 @@ -exports.run = async (client, msg, [user, reason]) => { - user = await client.funcs.userSearch(msg, {user: [user], name: this.help.name}); - if (user.valid === null) { return; } - user = client.users.find("username", user.user[0].username); +const { Command } = require("klasa"); - if (!reason) { return msg.reply("You must supply a reason!"); } - if (msg.guild.member(user).bannable === false) { return msg.reply("I cannot ban that member"); } - - var Toast = await client.funcs.modEmbed(client, msg, "kick", user.user[0], reason); - - if (Toast.embed.thumbnail) { - await user.send({embed: Toast.DMembed}); - await msg.client.users.fetch(user.id).kick(reason); +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "ban", + enabled: true, + runIn: ["text"], + aliases: ["b"], + description: "Ban someone.", + usage: " ", usageDelim: "," + }); } - - await Toast.channel.send({embed: Toast[0]}); -}; -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["b"], - permLevel: 3, - botPerms: ["BAN_MEMBERS", "EMBED_LINKS"], - requiredFuncs: ["userSearch", "modEmbed"] -}; - -exports.help = { - name: "ban", - description: "Bans the mentioned user.", - usage: " [reason:str] [...]", - usageDelim: " " + async run(msg, [user, reason]) { + if (user === null) { return; } + user = msg.guild.members.get(user.id); + if (user.bannable === false) { return msg.reply("I cannot ban that member"); } + + var data = this.client.util.modEmbed(msg, "ban", user, reason); + + if (data.embed.thumbnail) { + await user.send({embed: data.DMembed}); + await user.ban(`Automated Action - Moderator: ${msg.author.username} | Reason: ${reason}`); + } + + this.client.util.defaultChannel(msg.guild, "mod").send({embed: data.embed}); + } }; \ No newline at end of file diff --git a/commands/Mod/kick.js b/commands/Mod/kick.js index 0fd9407..fb0ee26 100644 --- a/commands/Mod/kick.js +++ b/commands/Mod/kick.js @@ -18,13 +18,13 @@ module.exports = class extends Command { if (user === null) { return; } user = msg.guild.members.get(user.id); if (user.kickable === false) { return msg.reply("I cannot kick that member"); } - - var data = this.client.util.modEmbed(msg, "kick", user, reason); - - if (data.embed.thumbnail) { - await user.send({embed: data.DMembed}); - await user.kick(`Automated Action - Moderator: ${msg.author.username} | Reason: ${reason}`); - } + + var data = this.client.util.modEmbed(msg, "kick", user, reason); + + if (data.embed.thumbnail) { + await user.send({embed: data.DMembed}); + await user.kick(`Automated Action - Moderator: ${msg.author.username} | Reason: ${reason}`); + } this.client.util.defaultChannel(msg.guild, "mod").send({embed: data.embed}); } diff --git a/index.js b/index.js index d2bfc41..34ef568 100644 --- a/index.js +++ b/index.js @@ -19,8 +19,9 @@ Client.defaultPermissionLevels .add(9, ({ author, client }) => author === client.owner || author.id === config.secondary) .add(10, ({ author, client }) => author === client.owner); -client.gateways.guilds.schema +client.gateways.guilds.schema //Add all configurable settings .add("modRole", "role") + .add("muteRole", "role") .add("langSpeech", "language", { default: "en-CA" }) .add("defaultChannel", "channel") .add("modlog", "channel"); diff --git a/utilities/modEmbed.js b/utilities/modEmbed.js index 10d81b0..3d79ca1 100644 --- a/utilities/modEmbed.js +++ b/utilities/modEmbed.js @@ -41,5 +41,5 @@ module.exports = function(msg, action=action.toLowerCase(), user, reason) { .setTitle("Moderator Message") .setDescription(`You have been ${options[1]} from ${msg.guild.name}!\n**Reason:** ${reason}`); - return { embed: embed, DMembed: DMembed }; + return { embed, DMembed }; }; \ No newline at end of file diff --git a/utilities/presenceHelper.js b/utilities/presenceHelper.js index 282c99e..0e09e08 100644 --- a/utilities/presenceHelper.js +++ b/utilities/presenceHelper.js @@ -30,9 +30,4 @@ function Presence(client, type, name, status) { name = (name !== "-null") ? `${client.ownerSetting.get("globalPrefix")}help | ${name}` : null; client.user.setPresence({ activity: { name, type }, status }); -} - -module.exports.help = { - name: "presenceHelper", - description: "Sets and manages the bot's presence" -} \ No newline at end of file +}; \ No newline at end of file diff --git a/utilities/utilExport.js b/utilities/utilExport.js index 1a19823..5258ab5 100644 --- a/utilities/utilExport.js +++ b/utilities/utilExport.js @@ -12,8 +12,8 @@ exports.dataManager = require("./dataManager.js"); exports.commandRemover = function(client) { const cmdNames = ["Admin/load", "Admin/unload", "Admins/transfer", "General/Chat Bot Info/info", "General/Chat Bot Info/stats"]; for(var x = 0; x < cmdNames.length; x++) { - if (existsSync(client.userBaseDirectory + "/node_modules/klasa/src/commands/" + cmdNames[x] + ".js")) { - unlinkSync(client.userBaseDirectory + "/node_modules/klasa/src/commands/" + cmdNames[x] + ".js"); + if (existsSync(`${client.userBaseDirectory}/node_modules/klasa/src/commands/${cmdNames[x]}.js`)) { + unlinkSync(`${client.userBaseDirectory}/node_modules/klasa/src/commands/${cmdNames[x]}.js`); } } }; @@ -46,7 +46,7 @@ exports.util = { * @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: function(guild, args="default") { + defaultChannel: (guild, args="default") => { if (guild.settings.defaultChannel !== null && args === "default") { return guild.channels.get(guild.settings.defaultChannel); } else if (guild.settings.modlog !== null && args === "mod") { return guild.channels.get(guild.settings.modlog); } @@ -70,7 +70,7 @@ exports.util = { * @param { String } text * @return { String } */ - toTitleCase: function(text) { + toTitleCase: (text) => { return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase(); } }; \ No newline at end of file From 1744e92a00f4765110de4bc0d57b6bd44757155c Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Sun, 19 Jan 2020 02:16:57 -0400 Subject: [PATCH 32/38] Finishing Mod Command Migration - Added a mute command - Migrated Purge Command. All moderation commands are migrated as of this commit. - Fixed a missing permission setting for the ban command and updated the kick command's level as it was on the old system - Small cleanup to system commands and ready event. - Removed more unused code. - Added documentation to the rest of the utility functions and migrated the final utility, musicCheck. All utilities are migrated as of this commit. --- LICENSE | 3 +- assets/speech/en-CA/intChecker.js | 61 -------------------- assets/speech/en-CA/mod.js | 29 ++++++++++ assets/speech/en-CA/transaction.js | 41 -------------- commands/Mod/ban.js | 1 + commands/Mod/kick.js | 2 +- commands/Mod/mute.js | 49 ++++++++++++++++ commands/Mod/purge.js | 89 ++++++++++++++---------------- commands/Owner/embeder.js | 55 ------------------ commands/System/exit.js | 9 ++- commands/System/invite.js | 10 ++-- commands/System/permlevel.js | 7 +-- commands/System/ping.js | 12 ++-- events/ready.js | 6 +- functions/constantMath.js | 43 --------------- functions/musicCheck.js | 19 ------- functions/transaction.js | 37 ------------- utilities/modEmbed.js | 6 +- utilities/presenceHelper.js | 16 +++--- utilities/timekeeper.js | 21 +++++-- utilities/utilExport.js | 25 +++++++++ 21 files changed, 194 insertions(+), 347 deletions(-) delete mode 100644 assets/speech/en-CA/intChecker.js create mode 100644 assets/speech/en-CA/mod.js delete mode 100644 assets/speech/en-CA/transaction.js create mode 100644 commands/Mod/mute.js delete mode 100644 commands/Owner/embeder.js delete mode 100644 functions/constantMath.js delete mode 100644 functions/musicCheck.js delete mode 100644 functions/transaction.js diff --git a/LICENSE b/LICENSE index f693fba..7080fab 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,8 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2017 Butterstroke + Beta 0.1 to Release 1.0 (Komada Version) Copyright 2017-2019 Butterstroke + Release 1.0 (Klasa Version) Copyright 2020 Frederick Katsura Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/assets/speech/en-CA/intChecker.js b/assets/speech/en-CA/intChecker.js deleted file mode 100644 index ecae543..0000000 --- a/assets/speech/en-CA/intChecker.js +++ /dev/null @@ -1,61 +0,0 @@ -module.exports = { - "none": { - "credit": [ - "You didn't supply me with an amount of credits, baka!", - "Credits? Hello? I need an amount of credits!" - ], - "craft": [ - "You can't craft nothing, baka!", - "Wow. Crafting nothing, I see. Got nothing else to do?" - ], - "default": [ - "You didn't include a value here, baka!", - "No value, no results, baka!", - "A man once said you always have value in life. Apparently, you can't spread some of that wealth into your command." - ] - }, - "negative": { - "credit": [ - "You can't bet a negative amount of credits!", - "What are you trying to do? Steal someone's credits? That's illegal, you know.", - "Robbing a bank would reel you in more credits than gambling negative credits." - ], - "craft": [ - "You can't craft a negative number, baka!", - "You're better off selling your raw items than crafting a negative amount." - ], - "default": [ - "No negative values in this established command, baka!", - "Negatives? Here? HA! You're really funny!" - ] - }, - "zero": { - "credit": [ - "You can't use zero credits here! Bet some *actual* credits and then we'll talk.", - "...wow, I didn't know you were that oblivious to gambling credits. You don't bet **nothing**, baka!" - ], - "craft": [ - "Why are you even crafting, baka!", - "Tell me the answer of 0/0 and then I'll craft you 0 of that item." - ], - "default": [ - "We've divided by zero. It didn't go so well...", - "Zero is an evil number. Don't give me these evils to work with." - ] - }, - "noInteger": { - "credit": [ - "There is no decimal work in credits! Whole credits only.", - "You can't split a credit! Give me a whole number, baka!" - ], - "craft": [ - "You can't have a part of something, baka!", - "Uh... you want to craft half of an item? I don't think that will work out well for you." - ], - "default": [ - "Decimals? That's like giving me fraction work. No thanks!", - "Decimals: fun to look at, not possible with what you are trying to do.", - "The only decimals I like to look at is in human currency. My credits are not that so keep them away!" - ] - } -}; \ No newline at end of file diff --git a/assets/speech/en-CA/mod.js b/assets/speech/en-CA/mod.js new file mode 100644 index 0000000..b53fb89 --- /dev/null +++ b/assets/speech/en-CA/mod.js @@ -0,0 +1,29 @@ +exports.kick = []; //Placeholder +exports.ban = []; //Placeholder + +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." + ] +}; \ No newline at end of file diff --git a/assets/speech/en-CA/transaction.js b/assets/speech/en-CA/transaction.js deleted file mode 100644 index d9b85ba..0000000 --- a/assets/speech/en-CA/transaction.js +++ /dev/null @@ -1,41 +0,0 @@ -exports.validate = { - "none": [ - "You didn't supply me with an amount of credits, baka!", - "Credits? Hello? I need an amount of credits!", - "A man once said you always have value in life. Apparently, you can't spread some of that wealth into your command." - ], - "zero": [ - "You can't use zero credits here! Use some *actual* credits and then we'll talk.", - "...wow, I didn't know you were that oblivious to credits. You don't bet **nothing**, baka!", - "We've divided by zero. It didn't go so well...", - "Zero is an evil number. Don't give me these evils to work with." - ], - "noInt": [ - "There is no decimal work in credits! Whole credits only.", - "You can't split a credit! Give me a whole number, baka!", - "Decimals? That's like giving me fraction work. No thanks!", - "Decimals: fun to look at, not possible with what you are trying to do.", - "The only decimals I like to look at is in human currency. My credits are not that so keep them away!" - ] -}; - -exports.dbCheck = { - "err": [ - "Hmm... it seems like I've encountered an error. Please try again later." - ], - "noRow": [ - "You haven't redeemed your first daily yet! :cry:", - "You haven't signed up and received your credits yet! D:", - "You need some credits to do this, baka! Get some with the daily command!", - "Credits speak a whole lot of value in these parts. Set yourself up with a daily command first!", - "Get yourself some credits first!", - "Where are your credits?! Oh. You haven't redeemed your first daily yet...", - "Oh... you didn't redeem your first daily yet..." - ], - "lessCredit": [ - "You don't have that many credits, baka!", - "A poor person like yourself could never afford that bet.", - "Try paying in dirt. It's worth more than your bank right now.", - "Try to pull a fast one on me? Too bad you can't afford it, baka!" - ] -}; \ No newline at end of file diff --git a/commands/Mod/ban.js b/commands/Mod/ban.js index d4c28a3..7234409 100644 --- a/commands/Mod/ban.js +++ b/commands/Mod/ban.js @@ -7,6 +7,7 @@ module.exports = class extends Command { enabled: true, runIn: ["text"], aliases: ["b"], + permissionLevel: 6, description: "Ban someone.", usage: " ", usageDelim: "," }); diff --git a/commands/Mod/kick.js b/commands/Mod/kick.js index fb0ee26..2c49131 100644 --- a/commands/Mod/kick.js +++ b/commands/Mod/kick.js @@ -7,7 +7,7 @@ module.exports = class extends Command { enabled: true, runIn: ["text"], aliases: ["k"], - permissionLevel: 2, + permissionLevel: 5, requiredPermissions: ["KICK_MEMBERS", "EMBED_LINKS"], description: "Kicks the mentioned user.", usage: " ", usageDelim: "," diff --git a/commands/Mod/mute.js b/commands/Mod/mute.js new file mode 100644 index 0000000..7e4d8b7 --- /dev/null +++ b/commands/Mod/mute.js @@ -0,0 +1,49 @@ +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "mute", + enabled: true, + runIn: ["text"], + aliases: ["m"], + permissionLevel: 5, + description: "Mute someone.", + extendedHelp: "Requires a server moderator to identify the mute role in the guild configurations first.", + usage: " [reason:str]", usageDelim: "," + }); + } + + async run(msg, [user, reason]) { + if (user === null) { return; } + if (msg.guild.settings.muteRole === null) { return msg.channel.send(this.client.speech(msg, ["mute", "noRole"])); } + user = msg.guild.members.get(user.id); + + var role = msg.guild.roles.get(msg.guild.settings.muteRole); + if (role.position > msg.guild.members.get(this.client.user.id).roles.highest.position) { return msg.channel.send(this.client.speech(msg, ["mute", "rolePos"])); } + + if (msg.channel.permissionsFor(user).has("ADMINISTRATOR")) { //Admins can talk regardless. Send message to warn that it will not work. + msg.channel.send(this.client.speech(msg, ["mute", "admin"])); + } + + if (user.roles.has(role.id)) { + var data = this.client.util.modEmbed(msg, "unmute", user, reason); + user.roles.remove(role.id); + + //Send embeds to logs and target user. + user.send({embed: data.DMembed}); + this.client.util.defaultChannel(msg.guild, "mod").send({embed: data.embed}); + + return msg.channel.send(this.client.speech(msg, ["mute", "unmuted"], [["-user", user.user.username]])); + } + + var data = this.client.util.modEmbed(msg, "mute", user, reason); + user.roles.add(role.id); + + //Send embeds to logs and target user. + user.send({embed: data.DMembed}); + this.client.util.defaultChannel(msg.guild, "mod").send({embed: data.embed}); + + msg.channel.send(this.client.speech(msg, ["mute", "muted"], [["-user", user.user.username]])); + } +}; \ No newline at end of file diff --git a/commands/Mod/purge.js b/commands/Mod/purge.js index a77063c..d45b168 100644 --- a/commands/Mod/purge.js +++ b/commands/Mod/purge.js @@ -1,56 +1,47 @@ -exports.run = async (client, message, [Amount, user]) => { - message.delete(); - let messagecount = Number(Amount); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); - if (user) { - user = client.funcs.userSearch(client, message, user); - if (user.username === null) { - const embed = new client.methods.Embed() - .setTimestamp() - .setAuthor(message.guild.name, message.guild.iconURL()) - .addField(":x: No User found! :x:"); - return message.channel.send({embed}); - } - } - - if (!Amount || (2 > Amount) || (Amount > 99)) { return message.reply("You didn't give me an amount between 2 and 99 to delete!"); } - - if (message.channel.permissionsFor(message.author.id).has("MANAGE_MESSAGES") === false) { - const embed = new client.methods.Embed() - .setColor("#FF0000") - .setTimestamp() - .setTitle("āŒ ERROR: MISSING PERMISSIONS! āŒ") - .setDescription("You do not have the correct permissions for this command!"); - return message.channel.send({embed}); +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "purge", + enabled: true, + runIn: ["text"], + 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: " ", + 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." + }); } - message.channel.messages.fetch({ limit: messagecount }).then((messages) => { - if (user) { - message.delete(); - const filterBy = user ? user.id : client.user.id; - messages = messages.filter(m => m.author.id === filterBy).array().slice(0, Amount); - var extra = `by ${user.tag} `; + async run(msg, [amount=10, 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. + + if (msg.channel.permissionsFor(msg.author.id).has("MANAGE_MESSAGES") === false) { + const embed = new MessageEmbed() + .setColor("#FF0000") + .setTimestamp() + .setTitle("āŒ ERROR: MISSING PERMISSIONS! āŒ") + .setDescription("You do not have the correct permissions for this command!"); + + return msg.channel.send({embed}); } - message.channel.bulkDelete(messages).catch(error => console.log(error.stack)); - return message.reply(`Purged ${Amount} messages ` + (extra || "") + "from the channel."); - }); -}; + msg.channel.messages.fetch({ limit: msgCount }).then((messages) => { + if (user && userCheck[2]) { + const filterBy = user ? user.id : client.user.id; + messages = messages.filter(m => m.author.id === filterBy).array().slice(0, amount); + var extra = `by ${user.tag} `; + } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 2, - botPerms: ["MANAGE_MESSAGES"], - requiredFuncs: ["userSearch"], - cooldown: 30, -}; - -exports.help = { - name: "purge", - description: "Purges X amount of messages from a given channel.", - usage: "[Amount:int] [user:str]", - 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." + msg.channel.bulkDelete(messages).catch(error => console.log(error.stack)); + msg.channel.send(this.client.speech(msg, ["purge", "success"], [["-amount", amount], ["-user", (extra || "")]])); + }); + } }; \ No newline at end of file diff --git a/commands/Owner/embeder.js b/commands/Owner/embeder.js deleted file mode 100644 index 891ffbe..0000000 --- a/commands/Owner/embeder.js +++ /dev/null @@ -1,55 +0,0 @@ -exports.run = async (client, message, [color, title, description]) => { - let Color = color.toLowerCase(); - - //Color Codes for embed - if (Color === "aqua") { Color = "0x1ABC9C"; } - if (Color === "green") { Color = "0x2ECC71"; } - if (Color === "blue") { Color = "0x3498DB"; } - if (Color === "purple") { Color = "0x9B59B6"; } - if (Color === "gold") { Color = "0xF1C40F"; } - if (Color === "orange") { Color = "0xE67E22"; } - if (Color === "red") { Color = "0xE74C3C"; } - if (Color === "grey" || Color === "gray") { Color = "0x95A5A6"; } - if (Color === "navy") { Color = "0x34495E"; } - if (Color === "dark aqua") { Color = "0x11806A"; } - if (Color === "dark green") { Color = "0x1F8B4C"; } - if (Color === "dark blue") { Color = "0x206694"; } - if (Color === "dark purple") { Color = "0x71368A"; } - if (Color === "dark gold") { Color = "0xC27C0E"; } - if (Color === "dark orange") { Color = "0xA84300"; } - if (Color === "dark red") { Color = "0x992D22"; } - if (Color === "dark grey" || Color === "dark gray") { Color = "0x979C9F"; } - if (Color === "darker grey" || Color === "darker gray") { Color = "0x7F8C8D"; } - if (Color === "light grey" || Color === "light gray") { Color = "0xBCC0C0"; } - if (Color === "dark navy") { Color = "0x2C3E50"; } - if (Color === "blurple") { Color = "0x7289DA"; } - if (Color === "greyple" || Color === "grayple") { Color = "0x99AAB5"; } - if (Color === "darkish") { Color = "0x2C2F33"; } - if (Color === "almost black") { Color = "0x23272A"; } - if (Color === "default") { Color = "0x000000"; } - - if(!title || !description) { return message.reply("You need to provide a subject title and description!"); } - - message.delete().catch(); - const embed = new client.methods.Embed() - .setColor(Color) - .setTimestamp() - .addField(`${title}`, `${description}`); - return message.channel.send({embed}); - }; - - exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 10, - botPerms: [], - requiredFuncs: [], - }; - - exports.help = { - name: "embeder", - description: "Embeds a simple message.", - usage: " ", - usageDelim: " |", - }; \ No newline at end of file diff --git a/commands/System/exit.js b/commands/System/exit.js index d123585..921f104 100644 --- a/commands/System/exit.js +++ b/commands/System/exit.js @@ -3,19 +3,18 @@ const { Command } = require("klasa"); module.exports = class extends Command { constructor(...args) { super(...args, { - name: 'exit', - runIn: ['text', 'dm'], + name: "exit", + runIn: ["text", "dm"], aliases: ["shutdown", "sleep"], guarded: true, permissionLevel: 10, - description: 'Shuts down the bot.', - usage: "" + description: "Shuts down the bot." }); } async run(msg) { await msg.delete().catch(); - await msg.channel.send("Good night, " + this.client.owner.username + "!"); + await msg.channel.send(`Good night, ${this.client.owner.username}!`); await process.exit().catch((e) => { console.error(e); }); } }; \ No newline at end of file diff --git a/commands/System/invite.js b/commands/System/invite.js index e492e8d..0c74d59 100644 --- a/commands/System/invite.js +++ b/commands/System/invite.js @@ -3,12 +3,10 @@ const { Command } = require("klasa"); module.exports = class extends Command { constructor(...args) { super(...args, { - name: 'invite', - runIn: ['text', 'dm'], - aliases: [], + name: "invite", + runIn: ["text", "dm"], guarded: true, - description: "Displays the invite link for Margarine.", - usage: "" + description: "Displays the invite link for Margarine." }); } @@ -16,4 +14,4 @@ module.exports = class extends Command { 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:`); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/commands/System/permlevel.js b/commands/System/permlevel.js index 7d3a30e..3506085 100644 --- a/commands/System/permlevel.js +++ b/commands/System/permlevel.js @@ -5,8 +5,7 @@ module.exports = class extends Command { constructor(...args) { super(...args, { name: "permlevel", - runIn: ['text'], - aliases: [], + runIn: ["text"], guarded: true, description: "Checks your permission level." }); @@ -27,7 +26,7 @@ module.exports = class extends Command { 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); + return msg.channel.send(`Your permission level is ${this.client.ownerSetting.get("permLevel").general[authorLvl]} ${info}`); } for (var i = 5; i < 8; i++) { @@ -35,6 +34,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 ${this.client.ownerSetting.get("permLevel").general[permLevel]}`); } }; \ No newline at end of file diff --git a/commands/System/ping.js b/commands/System/ping.js index 382e5db..368b19f 100644 --- a/commands/System/ping.js +++ b/commands/System/ping.js @@ -1,19 +1,17 @@ -const { Command } = require('klasa'); +const { Command } = require("klasa"); module.exports = class extends Command { constructor(...args) { super(...args, { - name: 'ping', - runIn: ['text', 'dm'], - aliases: [], + name: "ping", + runIn: ["text", "dm"], guarded: true, - description: 'Ping/Pong command', - usage: "" + description: "Ping/Pong command" }); } async run(message) { const msg = await message.channel.send("Pinging..."); - await msg.edit(`šŸŽ‰ Pong! (Took: ${(msg.editedTimestamp || msg.createdTimestamp) - (message.editedTimestamp || message.createdTimestamp)}ms.) šŸŽ‰`) + await msg.edit(`šŸŽ‰ Pong! (Took: ${(msg.editedTimestamp || msg.createdTimestamp) - (message.editedTimestamp || message.createdTimestamp)}ms.) šŸŽ‰`); } }; \ No newline at end of file diff --git a/events/ready.js b/events/ready.js index 3292bc4..6f86253 100644 --- a/events/ready.js +++ b/events/ready.js @@ -1,14 +1,14 @@ -const { Event } = require('klasa'); +const { Event } = require("klasa"); module.exports = class extends Event { constructor(...args) { super(...args, { once: true, - event: 'klasaReady' + event: "klasaReady" }); } async run() { - this.client.util.presenceHelper(this.client, "-start"); //Initialize presence + this.client.util.presenceHelper(this.client, "-start"); //Initialize presence } }; \ No newline at end of file diff --git a/functions/constantMath.js b/functions/constantMath.js deleted file mode 100644 index 94ee32b..0000000 --- a/functions/constantMath.js +++ /dev/null @@ -1,43 +0,0 @@ -module.exports = (client, message, MathNumber) => { - const reg = new RegExp(/(-|\.)?\d+((\.|,)\d+)?/); - - if (MathNumber.match(reg) === null) { - var number = MathNumber; - if (number === "e") { number = Math.E; } - else if (number === "pi") { number = Math.PI; } - else if (number.includes("sqrt")) { number = Math.sqrt(number.slice(4)); } - else if (number.includes("abs")) { number = Math.abs(number.slice(3)); } - //Logs - else if (number.includes("ln")) { number = Math.LN(number.slice(2)); } - else if (number.includes("log")) { number = Math.LOG(number.slice(3)); } - //Trigonometry - else if (number.includes("cos")) { number = Math.cos(number.slice(3)); } - else if (number.includes("sin")) { number = Math.sin(number.slice(3)); } - else if (number.includes("tan")) { number = Math.tan(number.slice(3)); } - else { number = null; } - } else { - return MathNumber; - } - /* - Math.LOG2E // returns base 2 logarithm of E - Math.LOG10E // returns base 10 logarithm of E - - acos(x) Returns the arccosine of x, in radians - asin(x) Returns the arcsine of x, in radians - atan(x) Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians - atan2(y, x) Returns the arctangent of the quotient of its arguments - exp(x) Returns the value of Ex - log(x) Returns the natural logarithm (base E) of x - max(x, y, z, ..., n) Returns the number with the highest value - min(x, y, z, ..., n) Returns the number with the lowest value - pow(x, y) Returns the value of x to the power of y*/ - return number; -}; - -module.exports.conf = { requiredModules: [] }; - -module.exports.help = { - name: "constantMath", - type: "functions", - description: "Checks a letter if it is a constant.", -}; \ No newline at end of file diff --git a/functions/musicCheck.js b/functions/musicCheck.js deleted file mode 100644 index 971b638..0000000 --- a/functions/musicCheck.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = (msg, tag) => { - var client = msg.client; - if (!msg.member.voice.channelID) { - client.speech(msg, ["func-music", "general", "userVC"]); - return false; - } else if (tag !== "join") { - if (!client.music.get(msg.guild.id)) { - client.speech(msg, ["func-music", "general", "noQueue"]); - return false; - } else if (msg.member.voice.channelID !== client.music.get(msg.guild.id).channel.id) { - client.speech(msg, ["func-music", "general", "mismatch"]); - return false; - } - - return client.music.get(msg.guild.id); - } - - return true; -}; \ No newline at end of file diff --git a/functions/transaction.js b/functions/transaction.js deleted file mode 100644 index 6cf9846..0000000 --- a/functions/transaction.js +++ /dev/null @@ -1,37 +0,0 @@ -module.exports = (msg, amount, user, callback) => { - const client = msg.client; - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.general); - - if (!user) { user = msg.author; } - - var check; - if (!amount) { check = "none"; } - else if (amount === 0) { check = "zero"; } - else if (Number.isInteger(amount) === false) { check = "noInt"; } - - if (check) { - msg.channel.send(client.speech(msg, ["func-transaction", "validate", check])); - return false; - } - - db.get(`SELECT credits FROM users WHERE userId = "${user.id}"`, [], (err, row) => { - let text; - if (err) { - console.log(err); - text = "err"; - } else if (!row) { text = "noRow"; } - else if (row.credits < credits) { text = "lessCredit"; } - - if (text) { client.speech(msg, ["func-transaction", "dbCheck", test]); return false; } - - db.run(`UPDATE users SET credits ="${amount + row.credits}" WHERE userId = "${user.id}"`); - callback([true, row.credits, (row.credits + amount)]); - }); -}; - -exports.help = { - name: "transaction", - type: "functions", - description: "Checks and does any credit transactions." -}; \ No newline at end of file diff --git a/utilities/modEmbed.js b/utilities/modEmbed.js index 3d79ca1..e289c42 100644 --- a/utilities/modEmbed.js +++ b/utilities/modEmbed.js @@ -12,8 +12,10 @@ module.exports = function(msg, action=action.toLowerCase(), user, reason) { const client = msg.client; const Options = { ban: ["BAN_MEMBERS", "banned", 0xDD2E44], - unban: ["BAN_MEMBERS", "unbanned", 0x21A321], - kick: ["KICK_MEMBERS", "kicked", 0x00AE86] + unban: ["BAN_MEMBERS", "unbanned", 0x38b058], + kick: ["KICK_MEMBERS", "kicked", 0xFFFF66], + mute: ["MANAGE_ROLES", "muted", 0x808080], + unmute: ["MANAGE_ROLES", "unmuted", 0x38b058] }; const embed = new MessageEmbed().setTimestamp(); diff --git a/utilities/presenceHelper.js b/utilities/presenceHelper.js index 0e09e08..df12f7e 100644 --- a/utilities/presenceHelper.js +++ b/utilities/presenceHelper.js @@ -1,5 +1,13 @@ 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; + + client.user.setPresence({ activity: { name, type }, 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. @@ -22,12 +30,4 @@ module.exports = (client, name, type=0, status="online") => { //Type defaulted t Presence(client, type, name, status); clearInterval(client.timer); } -}; - -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; - - client.user.setPresence({ activity: { name, type }, status }); }; \ No newline at end of file diff --git a/utilities/timekeeper.js b/utilities/timekeeper.js index 304ec41..bd2c1a2 100644 --- a/utilities/timekeeper.js +++ b/utilities/timekeeper.js @@ -1,3 +1,9 @@ +/** + * Combines a specific label with a count + * @param { Number } time - Required. Any number. + * @param { String} label - Required. Any label. + * @returns { String } Returns a time + label format. Example: "60 minutes" + */ function properLabel(time, label) { if (time === 0) { return null; } if (time === 1) { return ` ${time} ${label}`; } @@ -6,6 +12,11 @@ function properLabel(time, label) { } module.exports = { + /** + * Creates a human readable string from a process.uptime. + * @param { Number } time - A process.uptime count. + * @returns { String } Returns a human readable time count. For example, "1 hour, 23 minutes, and 12 seconds" + */ elapsedTime: (time) => { var second = Math.floor(time / 1000); var minute = Math.floor(second / 60); @@ -22,15 +33,15 @@ module.exports = { return lblTime.join(); }, + /** + * Creates a human readable date from a date object + * @param { Date } date - Required + * @returns { String } Returns a human readable date. For example, "May 26, 2017" + */ dateMaker: (date) => { var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var d = date.toLocaleString().split(" ")[0].split("/"); return `${months[d[0]]} ${d[1]}, ${d[2].slice(0, -1)}`; } -}; - -module.exports.help = { - name: "timekeeper", - description: "Creates a human readable time display out of timestamps.", }; \ No newline at end of file diff --git a/utilities/utilExport.js b/utilities/utilExport.js index 5258ab5..f8cb931 100644 --- a/utilities/utilExport.js +++ b/utilities/utilExport.js @@ -65,6 +65,31 @@ exports.util = { return guild.channels.get(channelID.id); }, + /** + * Goes over all common checks to ensure the user is able to interact with a music command + * @param { KlasaMessage } msg - Required + * @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"])); + return false; + } else if (tag !== "join") { + if (!client.music.get(msg.guild.id)) { + msg.channel.send(client.speech(msg, ["func-music", "general", "noQueue"])); + return false; + } else if (msg.member.voice.channelID !== client.music.get(msg.guild.id).channel.id) { + msg.channel.send(client.speech(msg, ["func-music", "general", "mismatch"])); + return false; + } + + return client.music.get(msg.guild.id); + } + + return true; + }, /** * Returns a capitialized text string * @param { String } text From 7b4716f4f3c185d597bf6fa76ebd0af3bc3c1d27 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Tue, 21 Jan 2020 15:24:00 -0400 Subject: [PATCH 33/38] guildCreate + Games Module - Migrated all of the game commands. All economy commands are migrated as of this commit. - Migrated the guildCreate event. All events are migrated as of this commit. - Cleaned up games speech file and added more to the dataCheck speech file. - Cleaned up userSearch argument. --- arguments/userSearch.js | 6 +- assets/speech/en-CA/dataCheck.js | 13 ++- assets/speech/en-CA/games.js | 14 +-- commands/Economy/Games/chouhan.js | 54 +++++----- commands/Economy/Games/coin.js | 49 ++++----- commands/Economy/Games/hazard.js | 171 ++++++++++++++++-------------- commands/Economy/Games/twoup.js | 70 ++++++------ events/guildCreate.js | 30 ++++++ 8 files changed, 222 insertions(+), 185 deletions(-) create mode 100644 events/guildCreate.js diff --git a/arguments/userSearch.js b/arguments/userSearch.js index f0327bc..a36c62b 100644 --- a/arguments/userSearch.js +++ b/arguments/userSearch.js @@ -20,13 +20,11 @@ module.exports = class extends Argument { var regex = new RegExp(regExpEsc(arg), "i"); var results = msg.guild.members.filter(m => regex.test(m.user.username)); - if (results.size == 0) { + if (results.size === 0) { msg.channel.send(this.client.speech(msg, ["func-userSearch", "default"])); return null; } return this.client.users.get(results.keys().next().value); - - //Check for bot user and if the command doesn't allow bots. } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/assets/speech/en-CA/dataCheck.js b/assets/speech/en-CA/dataCheck.js index 7c0dfbf..b046eb8 100644 --- a/assets/speech/en-CA/dataCheck.js +++ b/assets/speech/en-CA/dataCheck.js @@ -13,7 +13,9 @@ exports.noAccount = [ //When the user does not exist in the database "Credits speak a whole lot of value in these parts. Set yourself up with a daily command first!", "Get yourself some credits first!", "Where are your credits?! Oh. You haven't redeemed your first daily yet...", - "Oh... you didn't redeem your first daily yet..." + "Oh... you didn't redeem your first daily yet...", + "Oh no! You haven't redeemed your first daily yet! You should do that and then come back.", + "Seems like you haven't redeemed your first daily yet. Go and do that, you'll be able to play." ]; exports.sameUser = [ //When the target is the user but command can't have the same @@ -32,13 +34,16 @@ exports.lackCredits = [ //When the user doesn't have enough credits "You don't have that many credits, baka!", "A poor person like yourself could never afford that bet.", "Try paying in dirt. It's worth more than your bank right now.", - "Try to pull a fast one on me? Too bad you can't afford it, baka!" + "Try to pull a fast one on me? Too bad you can't afford it, baka!", + "That's an awfully high amount for someone who can't afford it." ]; exports.noItems = [ //When an item does not exist in the items.json file. - "Hmm... nope. Not finding that item here." + "Hmm... nope. Not finding that item here.", + "That's not an item." ]; exports.noZero = [ //When a command requires a nonzero amount. - "Hey! You don't have any of this!" + "Hey! You don't have any of this!", + "You can't have nothing here!" ]; \ No newline at end of file diff --git a/assets/speech/en-CA/games.js b/assets/speech/en-CA/games.js index 8658cba..2697ac2 100644 --- a/assets/speech/en-CA/games.js +++ b/assets/speech/en-CA/games.js @@ -1,13 +1,3 @@ -exports.noRow = [ - "Oh no! You haven't redeemed your first daily yet! You should do that and then come back.", - "Seems like you haven't redeemed your first daily yet. Go and do that, you'll be able to play my games then." -]; - -exports.noCredits = [ - "You don't have enough credits to make that bet!", - "That's an awfully high bet for someone who can't afford it." -]; - exports.chouhan = { "win": [ "**Sum:** -sum \n**Guess:** -guess \nYou have won -earning credits!" @@ -26,9 +16,7 @@ exports.coin = { ] }; -exports.hazard = [ - //Placeholder, not needed at the moment. -]; +exports.hazard = []; //Placeholder, not needed at the moment. exports.twoup = { "win": [ diff --git a/commands/Economy/Games/chouhan.js b/commands/Economy/Games/chouhan.js index 070cbe1..21ffbfd 100644 --- a/commands/Economy/Games/chouhan.js +++ b/commands/Economy/Games/chouhan.js @@ -1,32 +1,34 @@ -exports.run = async (client, msg, [bet, credit]) => { - 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)); } +const { Command } = require("klasa"); - var sum = rolls[0] + rolls[1] + rolls[2] + rolls[3] + rolls[4] + rolls[5]; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "chouhan", + enabled: true, + runIn: ["text"], + aliases: ["chōhan"], + description: "Bet your credits on if the sum of six dice are even or odd.", + 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." + }); + } - if ((sum%2 === 0 && bet === "even") || (sum%2 !== 0 && bet === "odd")) { var result = ["won", 1.5]; } - else { var result = ["lost", -1]; } + 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"])); } - client.funcs.transactions(msg, {credit: [credit, "*", result[1]]}, function(data) { - if (data.valid === false) { return; } + 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)); } - msg.channel.send(`**Sum:** ${sum} \n**Your Guess:** ${bet} \n*You have ${result[0]} ${Math.abs(data.earnings)} credits.*`); - }); -}; + var sum = rolls[0] + rolls[1] + rolls[2] + rolls[3] + rolls[4] + rolls[5]; -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["chō-han", "chōhan", "chou-han"], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "chouhan", - description: "Bet your credits on if the sum of six dice are even or odd.", - usage: " [credits:int]", - 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.", - humanUse: "(even|odd)_(amount)" + 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)]])); + } + + 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]])); + } }; \ No newline at end of file diff --git a/commands/Economy/Games/coin.js b/commands/Economy/Games/coin.js index 790a5c0..1bcb2b6 100644 --- a/commands/Economy/Games/coin.js +++ b/commands/Economy/Games/coin.js @@ -1,28 +1,29 @@ -exports.run = async (client, msg, [choice, bet]) => { - let y = Math.random() > .5 ? "Heads": "Tails"; +const { Command } = require("klasa"); - if (y.toLowerCase() === choice.toLowerCase()) { var result = ["won", 2]; } - else { var result = ["lost", -1]; } +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "coin", + enabled: true, + runIn: ["text"], + description: "Flip a coin!", + usage: " ", usageDelim: " " + }); + } - client.funcs.transactions(msg, {credit: [bet, "*", result[1]]}, function(data) { - if (data.valid === false) { return; } + 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"])); } - msg.channel.send("**" + y + "!** You have " + result[0] + " " + Math.abs(data.earnings) + " credits"); - }); -}; + let y = Math.random() > .5 ? "Heads": "Tails"; -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "coin", - description: "Flip a coin!", - usage: " [bet:int]", - usageDelim: " ", - humanUse: "(heads|tails) (amount)" -}; + 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]])); + } + + 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]])); + } +}; \ No newline at end of file diff --git a/commands/Economy/Games/hazard.js b/commands/Economy/Games/hazard.js index 159a25c..4feb31d 100644 --- a/commands/Economy/Games/hazard.js +++ b/commands/Economy/Games/hazard.js @@ -1,95 +1,102 @@ -exports.run = async (client, message, [bet]) => { - const embed = new client.methods.Embed() - .setTimestamp() - .setFooter(message.guild.name, message.guild.iconURL()) - .setColor(0x04d5fd); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); - const sumAll = [this.roll(1)[0]]; const choice = [5, 6, 7, 8, 9]; - var castMain = choice[~~(Math.random() * choice.length)]; var earnings; - - if (sumAll[0] < 4) { var results = 1; } - else if (castMain === sumAll[0]) { var results = 0; } - else if (sumAll[0] > 10) { - if (castMain === 5 || castMain === 9) { var results = 1; } - else if (castMain === 6 || castMain === 8) { var results = (sumAll[0] === 11) ? 0 : 1; } - else { var results = (sumAll[0] === 12) ? 0 : 1; } - } else { - var chance = choice[~~(Math.random() * choice.length)]; - while (castMain === chance) { var chance = choice[~~(Math.random() * choice.length)]; } - - var roll = this.roll(3); - roll.forEach(element => { sumAll.push(element); }); +function roll (time) { + var rolls = []; + for (var a = 0; a < time; a++) { + var x = Math.floor(Math.random() * (Math.floor(6) - Math.ceil(1) + 1)) + Math.ceil(1); + var y = Math.floor(Math.random() * (Math.floor(6) - Math.ceil(1) + 1)) + Math.ceil(1); + rolls.push(x + y); + } + return rolls; +}; - for (var i = 1; i < 5; i++) { - if (castMain === sumAll[i] || chance === sumAll[i]) { var results = 0; i = 5; } - else if (i === 4) { var results = 1; } - } +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "hazard", + enabled: true, + runIn: ["text"], + description: "Gamble your credits in a early version of craps, a dice game.", + 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." + }); } - if (chance && results === 0) { - if (Math.abs(castMain - 7) === 2) { - if (Math.abs(chance - 7) === 3) { earnings = 4/3; } - else if (Math.abs(chance - 7) === 2) { earnings = 1; } - else if (Math.abs(chance - 7) === 1) { earnings = 4/5; } - else { earnings = 2/3; } - } else if (Math.abs(castMain - 7) === 1) { - if (Math.abs(chance - 7) === 3) { earnings = 5/3; } - else if (Math.abs(chance - 7) === 2) { earnings = 5/4; } - else if (Math.abs(chance - 7) === 1) { earnings = 1; } - else { earnings = 5/6; } + 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"])); } + + const embed = new MessageEmbed() + .setTimestamp() + .setFooter(msg.guild.name, msg.guild.iconURL()) + .setColor(0x04d5fd); + + const sumAll = [roll(1)[0]]; + const choice = [5, 6, 7, 8, 9]; + var castMain = choice[~~(Math.random() * choice.length)]; + var earnings, results, chance; + + if (sumAll[0] < 4) { results = 1; } + else if (castMain === sumAll[0]) { results = 0; } + else if (sumAll[0] > 10) { + if (castMain === 5 || castMain === 9) { results = 1; } + else if (castMain === 6 || castMain === 8) { results = (sumAll[0] === 11) ? 0 : 1; } + else { results = (sumAll[0] === 12) ? 0 : 1; } } else { - if (Math.abs(chance - 7) === 3) { earnings = 2/1; } - else if (Math.abs(chance - 7) === 2) { earnings = 3/2; } - else if (Math.abs(chance - 7) === 1) { earnings = 6/5; } - else { earnings = 1; } + chance = choice[~~(Math.random() * choice.length)]; + while (castMain === chance) { chance = choice[~~(Math.random() * choice.length)]; } + + var rolls = roll(3); + rolls.forEach(element => { sumAll.push(element); }); + + for (var i = 1; i < 5; i++) { + if (castMain === sumAll[i] || chance === sumAll[i]) { results = 0; i = 5; } + else if (i === 4) { results = 1; } + } } - } else if (results === 0) { earnings = 2; } - else { earnings = 1; } - if (!bet) { var result = ["X", bet, 0]; } - else if (results === 0) { - earnings = (bet * earnings).toFixed(0); - var result = ["won", bet, Number(earnings - bet)]; - } else { var result = ["lost", 1, Number(-bet - 1)]; } + if (chance && results === 0) { + switch (Math.abs(castMain - 7)) { + case 2: + if (Math.abs(chance - 7) === 3) { earnings = 4/3; } + else if (Math.abs(chance - 7) === 2) { earnings = 1; } + else if (Math.abs(chance - 7) === 1) { earnings = 4/5; } + else { earnings = 2/3; } + break; + case 1: + if (Math.abs(chance - 7) === 3) { earnings = 5/3; } + else if (Math.abs(chance - 7) === 2) { earnings = 5/4; } + else if (Math.abs(chance - 7) === 1) { earnings = 1; } + else { earnings = 5/6; } + break; + case 0: + if (Math.abs(chance - 7) === 3) { earnings = 2/1; } + else if (Math.abs(chance - 7) === 2) { earnings = 3/2; } + else if (Math.abs(chance - 7) === 1) { earnings = 6/5; } + else { earnings = 1; } + break; + }; + } else if (results === 0) { earnings = 2; } + else { earnings = 1; } - chance = (chance) ? " | Chance: " + chance : ""; - embed.addField("Lucky numbers:", "Starter: " + castMain + chance, true); - embed.addField("Sums:", sumAll.join(", "), true); + if (!bet) { var result = ["X", bet, 0]; } + else if (results === 0) { + earnings = (bet * earnings).toFixed(0); + var result = ["won", (bet * earnings) - bet]; + } else { var result = ["lost", -bet]; } - client.funcs.transactions(message, {credit: [result[1], "+", result[2]]}, function(data) { - if (data.valid === false) { return; } - else if (sumAll[0] < 4) { embed.addField("Result:", "Rolled less than a 4. Auto loss."); } - else if (sumAll[0] > 10) { embed.addField("Result:", "Rolled higher than a 10! Your numbers determine you " + result[0] + "!"); } - else if (result[0] === "lost") { embed.addField("Result:", "You have lost " + bet + " credits"); } - else { embed.addField("Result:", "You have won " + Math.abs(data.earnings) + " credits"); } - - message.channel.send({embed}); - }); -}; + chance = (chance) ? ` | Chance: ${chance}` : ""; + embed.addField("Lucky numbers:", `Starter: ${castMain}${chance}`, true); + embed.addField("Sums:", sumAll.join(", "), true); -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "hazard", - description: "Gamble your credits in a early version of craps, a dice game.", - usage: "[bet:int]", - 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.", - humanUse: "(Amount of credits)" -}; + if (sumAll[0] < 4) { embed.addField("Result:", "Rolled less than a 4. Auto loss."); } + else if (sumAll[0] > 10) { embed.addField("Result:", `Rolled higher than a 10! Your numbers determine you ${result[0]}!`); } + else if (result[0] === "lost") { embed.addField("Result:", `You have lost ${bet} credits`); } + else { embed.addField("Result:", `You have won ${Math.abs(data.earnings)} credits`); } -exports.roll = (time) => { - var rolls = []; - for (var a = 0; a < time; a++) { - var x = Math.floor(Math.random() * (Math.floor(6) - Math.ceil(1) + 1)) + Math.ceil(1); - var y = Math.floor(Math.random() * (Math.floor(6) - Math.ceil(1) + 1)) + Math.ceil(1); - rolls.push(x + y); + this.client.dataManager("update", [`credits=${result[1]}`, msg.author.id], "users"); + msg.channel.send({embed}); } - return rolls; }; \ No newline at end of file diff --git a/commands/Economy/Games/twoup.js b/commands/Economy/Games/twoup.js index 20dc569..a7f7d19 100644 --- a/commands/Economy/Games/twoup.js +++ b/commands/Economy/Games/twoup.js @@ -1,36 +1,42 @@ -exports.run = async (client, msg, [bet]) => { - let rolls = []; - for (var z = 0; z < 7; z++) { - var x = (Math.random() > .5) ? "heads" : "tails"; - rolls.push(x); - } +const { Command } = require("klasa"); - let fact = []; - for (var y = 0; y < 7; y++) { - if (rolls[y] === rolls[y + 1] && rolls[y] === "heads") { var result = ["won", 1.4]; break; } - else if (rolls[y] !== rolls[1]) { fact.push(true); } - else if (y === 6) { var result = fact.includes(false) ? ["lost", -1] : ["won", 2]; } - else { fact.push(false); } +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "twoup", + enabled: true, + runIn: ["text"], + description: "Bet on coin flips. Get two heads in a row and win or hope for all five odds!", + 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." + }); } - client.funcs.transactions(msg, {credit: [bet, "*", result[1]]}, function(data) { - if (data.valid === false) { return; } - - msg.channel.send(`**Coins:** ${rolls.join(", ")}\nYou have ${result[0]} ${Math.abs(data.earnings)} credits.`); - }); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["two-up"], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "twoup", - description: "Bet on coin flips. Get two heads in a row and win or hope for all five odds!", - usage: "[bet:int]", humanUse: "(Amount)", - 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, in part to mark a shared experience with Diggers through the ages." + 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"])); } + + let rolls = []; + for (var z = 0; z < 7; z++) { + var x = (Math.random() > .5) ? "heads" : "tails"; + rolls.push(x); + } + + let fact = []; + for (var y = 0; y < 7; y++) { + if (rolls[y] === rolls[y + 1] && rolls[y] === "heads") { var result = ["won", 1.4]; break; } + else if (rolls[y] !== rolls[1]) { fact.push(true); } + else if (y === 6) { var result = fact.includes(false) ? ["lost", -1] : ["won", 2]; } + else { fact.push(false); } + } + + 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]])); + } + + 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]])); + } }; \ No newline at end of file diff --git a/events/guildCreate.js b/events/guildCreate.js new file mode 100644 index 0000000..a3980bf --- /dev/null +++ b/events/guildCreate.js @@ -0,0 +1,30 @@ +const { Event } = require("klasa"); +const { MessageEmbed } = require("discord.js"); + +module.exports = class extends Event { + constructor(...args) { + super(...args, { + enabled: true, + event: "guildCreate" + }); + } + + async run(guild) { + if (!guild.available) { return; } + + const embed = new MessageEmbed() + .setTimestamp() + .setColor(0xF1C40F) + .setTitle(`Greetings to the users of ${guild.name}!`) + .setDescription(`My name is ${this.client.user.username} and I'd like to thank you for inviting me. I am a helpful and fantastic bot created with Klasa, a discord.js framework.\n + If you want so see my awesome commands, feel free to do ${guild.settings.get("prefix")}help. I will send you my help menu where you will be provided with more information.\n + If you found something not quite right or have a suggestion, please use my report command and let my creator know! I do have a TOS for some of my abilities so please refer to [this link](https://github.com/Butterstroke/MargarineBot/blob/master/TermsOfService.md) for more information. I look forward to having fun with you!`); + + 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 From 3a412c600673caf7fcad75d3574e5b0180b165d6 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Fri, 24 Jan 2020 18:27:07 -0400 Subject: [PATCH 34/38] Migrated Some Fun Commands + Small cleanup --- assets/speech/en-CA/fun.js | 38 ++++++++++++++---- commands/Economy/Games/hazard.js | 2 +- commands/Fun/poll.js | 60 ++++++++++++++-------------- commands/Fun/roll.js | 38 ++++++++---------- commands/Fun/rps.js | 68 ++++++++++++++------------------ commands/Fun/say.js | 40 +++++++++---------- commands/System/report.js | 2 +- monitors/linkdetector.js | 16 -------- monitors/prefixHelp.js | 6 +-- monitors/sweardetector.js | 14 ------- 10 files changed, 132 insertions(+), 152 deletions(-) delete mode 100644 monitors/linkdetector.js delete mode 100644 monitors/sweardetector.js diff --git a/assets/speech/en-CA/fun.js b/assets/speech/en-CA/fun.js index 51d662d..ce3e2bd 100644 --- a/assets/speech/en-CA/fun.js +++ b/assets/speech/en-CA/fun.js @@ -1,24 +1,46 @@ exports.roll = { "zero": [ "You can't roll from 0!", - "A die with 0 sides? You got to be joking." + "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 can't roll a negative number, baka!", + "You need a positive number! A negative sided die is impossible!" ], "success": [ - "šŸŽ² You rolled a -value! šŸŽ²" - ], - "noNumber": [ - "It seems you added some letters into your number. Please try again!" + "šŸŽ² You rolled a -value! šŸŽ²", + "You've rolled -value! šŸŽ²", + "šŸŽ² Ah ha! You've rolled a -value!" ] }; exports.rps = { "sameUser": [ - "Hey! You can't play rock, paper, scissors with yourself! Invite someone into the mix or play with me instead!" + "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!**" ] -}; \ No newline at end of file +}; + +exports.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!" + ] +}; + +exports.say = [ + "You need to provide me with a message!", + "I need a message to echo before I can do this!" +]; \ No newline at end of file diff --git a/commands/Economy/Games/hazard.js b/commands/Economy/Games/hazard.js index 4feb31d..42fae27 100644 --- a/commands/Economy/Games/hazard.js +++ b/commands/Economy/Games/hazard.js @@ -77,7 +77,7 @@ module.exports = class extends Command { else if (Math.abs(chance - 7) === 1) { earnings = 6/5; } else { earnings = 1; } break; - }; + } } else if (results === 0) { earnings = 2; } else { earnings = 1; } diff --git a/commands/Fun/poll.js b/commands/Fun/poll.js index f28931c..243fd3c 100644 --- a/commands/Fun/poll.js +++ b/commands/Fun/poll.js @@ -1,34 +1,34 @@ -exports.run = async (client, msg, [question, ...option]) => { - if (!question) { return msg.reply("You need to provide a question."); } - else if (option.length < 2) { return msg.reply("You need to provide at least two options!"); } - else if (option.length > emote.length) { return msg.reply("Whoa! You have a giant list of options! Not even I can handle all of these!"); } +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); - var emote = ["āœ…", "āŽ", "ā˜‘", "āœ”", "āŒ", "āœ–", "ā­•", "šŸ”˜"]; +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." + }); + } - msg.delete().catch(); - const embed = new client.methods.Embed() - .setColor("#FFFFFF") - .setTimestamp() - .setDescription(`A poll has been started by ${msg.author.username}!`) - .addField("Question: ", `${question}`); + async run(msg, [question, ...option]) { + var emote = ["āœ…", "āŽ", "ā˜‘", "āœ”", "āŒ", "āœ–", "ā­•", "šŸ”˜"]; - 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]); } -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "poll", - description: "Poll users", - usage: "[question:str] [option:str][...]", usageDelim: " | ", - humanUse: "(question)_(option1)_(option2)_(etc...->option5)" + 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]); } + } }; \ No newline at end of file diff --git a/commands/Fun/roll.js b/commands/Fun/roll.js index f82d913..b9b35fa 100644 --- a/commands/Fun/roll.js +++ b/commands/Fun/roll.js @@ -1,24 +1,20 @@ -exports.run = (client, msg, sides) => { - sides = (sides.length < 1) ? 6 : Number(sides); - if (sides === 0) { return msg.channel.send(client.speech(msg, ["roll", "zero"])); } +const { Command } = require("klasa"); - if (Number.isInteger(sides)) { - if (sides < 0) { return msg.channel.send(client.speech(msg, ["roll", "negative"])); } - var y = Math.floor(Math.random() * (Math.floor(sides) - Math.ceil(1) + 1)) + Math.ceil(1); - return msg.channel.send(client.speech(msg, ["roll", "success"]).replace("-value", y)); - } - return msg.channel.send(client.speech(msg, ["roll", "noNumber"])); -}; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "roll", + runIn: ["text"], + description: "Roll a die. Will default to 6 if no amount is provided.", + usage: "[sides:int]" + }); + } + + async run(msg, [sides=6]) { + if (sides === 0) { return msg.channel.send(this.client.speech(msg, ["roll", "zero"])); } + if (sides < 0) { return msg.channel.send(this.client.speech(msg, ["roll", "negative"])); } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "roll", description: "Roll a die!", - usage: "[sides:str]", humanUse: "[sides]" + var y = Math.floor(Math.random() * (Math.floor(sides) - Math.ceil(1) + 1)) + Math.ceil(1); + msg.channel.send(this.client.speech(msg, ["roll", "success"]).replace("-value", y)); + } }; \ No newline at end of file diff --git a/commands/Fun/rps.js b/commands/Fun/rps.js index 8d83f6a..5c6545a 100644 --- a/commands/Fun/rps.js +++ b/commands/Fun/rps.js @@ -1,41 +1,33 @@ -exports.run = async (client, msg, [choice, user]) => { - if (!user) { user = client.user.id; } - client.funcs.userSearch(client, msg, user).then(data => { - if (data !== false) { - if (data.user.id === msg.author.id) { return msg.channel.send(client.speech(msg, ["rps", "sameUser"])); } +const { Command } = require("klasa"); - var types = ["rock", "paper", "scissors"]; - var hand = types[Math.floor(Math.random() * (Math.floor(2) - Math.ceil(1) + 1)) + Math.ceil(1)]; - - if ((choice === "rock" && hand === "scissors") || (choice === "paper" && hand === "rock") || (choice === "scissors" && hand === "paper")) { var result = `${msg.author.username} wins`; } - else if ((choice === "rock" && hand === "paper") || (choice === "paper" && hand === "scissors") || (choice === "scissors" && hand === "rock")) { var result = `${data.user.username} wins`; } - else { var result = "Draw"; } +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "rps", + runIn: ["text"], + aliases: ["rockpaperscissors"], + description: "Play Rock, Paper, Scissors", + usage: " [user:usersearch]", usageDelim: " " + }); + } - msg.channel.send( - client.speech(msg, ["rps", "success"]) - .replace("-user1", msg.author.username) - .replace("-user2", data.user.username) - .replace("-hand1", choice) - .replace("-hand2", hand) - .replace("-result", result) - ); - } - }); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["rockpaperscissors"], - permLevel: 0, - botPerms: [], - requiredFuncs: ["userSearch"] -}; - -exports.help = { - name: "rps", - description: "Play Rock, Paper, Scissors!", - usage: " [user:str]", - usageDelim: " ", - humanUse: "(paper|scissors|rock)_(user)" + async run(msg, [choice, user]) { + if (!user) { user === this.client.user; } + if (user.id === msg.author.id) { return msg.channel.send(this.client.speech(msg, ["rps", "sameuser"])); } + + var types = ["rock", "paper", "scissors"]; + var hand = types[Math.floor(Math.random() * (Math.floor(2) - Math.ceil(1) + 1)) + Math.ceil(1)]; + + if ((choice === "rock" && hand === "scissors") || (choice === "paper" && hand === "rock") || (choice === "scissors" && hand === "paper")) { var result = `${msg.author.username} wins`; } + else if ((choice === "rock" && hand === "paper") || (choice === "paper" && hand === "scissors") || (choice === "scissors" && hand === "rock")) { var result = `${data.user.username} wins`; } + else { var result = "Draw"; } + + msg.channel.send(this.client.speech(msg, ["rps", "success"], [ + ["-user1", msg.author.username], + ["-user2", user.username], + ["-hand1", choice], + ["-hand2", hand], + ["-result", result] + ])); + } }; \ No newline at end of file diff --git a/commands/Fun/say.js b/commands/Fun/say.js index 8a12072..567ad2c 100644 --- a/commands/Fun/say.js +++ b/commands/Fun/say.js @@ -1,21 +1,21 @@ -exports.run = (client, message, [msg]) => { - if (!msg) { return message.reply("You need to provide a message."); } +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "say", + runIn: ["text"], + aliases: ["echo", "talk"], + description: "Have Margarine echo what you said.", + usage: "[message:str]" + }); + } + + async run(msg, [message]) { + if (!message) { return msg.channel.send(this.client.speech(msg, ["say"])); } - message.delete().catch(); - if (message.author.id === client.owner.id) { return message.channel.send(msg); } - return message.channel.send(`${message.author.username} (${message.author.id}) wanted to say: ${msg}`); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["echo", "talk"], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "say", - description: "Have Margarine echo what you said.", - usage: "[msg:str]", humanUse: "[msg]" -}; + msg.delete().catch(); + if (msg.author.id === client.owner.id) { return msg.channel.send(message); } + msg.channel.send(`${msg.author.username} (${msg.author.id}) wanted to say: ${message}`); + } +}; \ No newline at end of file diff --git a/commands/System/report.js b/commands/System/report.js index 8f5f0cb..f556955 100644 --- a/commands/System/report.js +++ b/commands/System/report.js @@ -52,7 +52,7 @@ module.exports = class extends Command { this.client.channels.get(this.client.ownerSetting.get("channels").report).send(embed); msg.author.send({embed: DMembed}); - this.client.dataManager("update", ["count=" + reportNumber, "report"], "stats"); + this.client.dataManager("update", [`count=${reportNumber}`, "report"], "stats"); }).catch(() => { msg.author.send(this.client.speech(msg, ["report", "timeout", "t2"])); }); }); }).catch(() => { msg.author.send(this.client.speech(msg, ["report", "timeout", "t1"])); }); diff --git a/monitors/linkdetector.js b/monitors/linkdetector.js deleted file mode 100644 index ac51e69..0000000 --- a/monitors/linkdetector.js +++ /dev/null @@ -1,16 +0,0 @@ -exports.conf = { - enabled: false, - ignoreBots: false, - ignoreSelf: false -}; - -exports.run = (client, message) => { - const links = [/*Insert blacklisted links here*/]; - const Link = ["discord.gg"]; - if (links.some(word => message.content.includes(links))) { - return; - } else if(message.content.includes(Link)) { - message.delete(); - message.reply("No advertising links, baka!"); - } -}; diff --git a/monitors/prefixHelp.js b/monitors/prefixHelp.js index 2dc59ef..ae1f607 100644 --- a/monitors/prefixHelp.js +++ b/monitors/prefixHelp.js @@ -1,9 +1,9 @@ -const { Monitor } = require('klasa'); +const { Monitor } = require("klasa"); module.exports = class extends Monitor { constructor(...args) { super(...args, { - name: 'prefixHelp', + name: "prefixHelp", enabled: true, ignoreEdits: false, ignoreOthers: false @@ -13,7 +13,7 @@ module.exports = class extends Monitor { run(msg) { var defaultPrefix = msg.client.gateways.guilds.schema.get("prefix").default; - if (msg.content == defaultPrefix + "help") { + if (msg.content === `${defaultPrefix}help`) { if (defaultPrefix !== msg.guild.settings.prefix) { return msg.channel.send(`Whoops! Looks like you are thinking of my default prefix. That is not the case here. Please use: ${msg.guild.settings.prefix}`); } diff --git a/monitors/sweardetector.js b/monitors/sweardetector.js deleted file mode 100644 index 85d1499..0000000 --- a/monitors/sweardetector.js +++ /dev/null @@ -1,14 +0,0 @@ -exports.run = (client, message) => { - const swearWords = [/* Insert swearwords in here */]; - var msg = message.content.toLowerCase(); - if(swearWords.some(word => msg.includes(word)) || swearWords.some(word => message.content.includes(word))) { - message.delete(); - message.reply("You shouldn't have said that!"); - } -}; - -exports.conf = { - enabled: false, - ignoreBots: false, - ignoreSelf: false, -}; \ No newline at end of file From a270d15e88214e1291ade717844755bfba93c366 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Fri, 24 Jan 2020 23:36:20 -0400 Subject: [PATCH 35/38] Migrated Music Commands --- assets/speech/en-CA/music.js | 37 +++++++------- commands/Music/join.js | 63 +++++++++++------------ commands/Music/leave.js | 39 +++++++------- commands/Music/nowplaying.js | 62 +++++++++++----------- commands/Music/pause.js | 37 +++++++------- commands/Music/play.js | 99 ++++++++++++++++++------------------ commands/Music/queue.js | 72 +++++++++++++------------- commands/Music/queueadd.js | 92 ++++++++++++++++----------------- commands/Music/remove.js | 44 ++++++++-------- commands/Music/resume.js | 37 +++++++------- commands/Music/skip.js | 33 ++++++------ commands/Music/volume.js | 50 +++++++++--------- index.js | 1 + utilities/utilExport.js | 13 +++-- 14 files changed, 334 insertions(+), 345 deletions(-) diff --git a/assets/speech/en-CA/music.js b/assets/speech/en-CA/music.js index c0e8bac..0720a14 100644 --- a/assets/speech/en-CA/music.js +++ b/assets/speech/en-CA/music.js @@ -14,10 +14,10 @@ exports.join = { ] }; -exports.leave = [ //Parameter 1: Voice channel name. - "I have left -param1.", - "The party is now over in -param1.", - "Thanks for the fun! I've cleaned up and have left -param1." +exports.leave = [ + "I have left -channel.", + "The party is now over in -channel.", + "Thanks for the fun! I've cleaned up and have left -channel." ]; exports.nowplaying = { @@ -90,16 +90,10 @@ exports.queueadd = { ] }; -exports.remove = { - "noInt": [ - "I only have songs queued in integers. Come back with a whole number, will you?", - "This isn't a number... Come back with a number, baka!" - ], - "success": [ //Parameter 1: Song title - "**-param1** has been removed from the queue.", - "Okay! **-param1** has been removed from the queue." - ] -}; +exports.remove = [ + "**-song** has been removed from the queue.", + "Okay! **-song** has been removed from the queue." +]; exports.resume = { "noPause": [ @@ -114,13 +108,14 @@ exports.resume = { exports.skip = [ "ā­ Skipped the current song.", - "On to the next song! ā­" + "On to the next song! ā­", + "ā­ Okay! Playing the next song then!" ]; exports.volume = { - "noArgs": [ //Parameter 1: volume - "šŸ“¢ Volume: -param1%", - "Currently playing at -param1%" + "noArgs": [ + "šŸ“¢ Volume: -vol%", + "Currently playing at -vol%" ], "zero": [ "You might as well mute me if you don't want any noise." @@ -154,5 +149,9 @@ exports.general = { "BAKA! You aren't even in my voice channel to begin with!", "You are not in my voice channel! Come in and tell me face to face!", "I'm already playing in another VC. You should join in on the fun instead!" - ] //Margarine not in the same VC + ], //Margarine not in the same VC + "noHandler": [ //Margarine needs a dispatcher active in order to do the command + "Hey! I'm not playing anything right now!", + "You should really play some music before you try to interact with the music." + ] }; \ No newline at end of file diff --git a/commands/Music/join.js b/commands/Music/join.js index 34f9c27..f5a12c3 100644 --- a/commands/Music/join.js +++ b/commands/Music/join.js @@ -1,38 +1,35 @@ -exports.run = async (client, msg) => { - var check = client.funcs.musicCheck(msg, "join"); - if (check === false) { return; } - var vcID = msg.guild.channels.get(msg.member.voice.channelID); +const { Command } = require("klasa"); - const permissions = vcID.permissionsFor(msg.guild.me); - if (permissions.has("CONNECT") === false) { return msg.channel.send(client.speech(msg, ["join", "noConnect"])); } - if (permissions.has("SPEAK") === false) { return msg.channel.send(client.speech(msg, ["join", "noSpeak"])); } +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "join", + runIn: ["text"], + description: "Joins the VC that you are in." + }); + } - var vcSettings = { - channel: vcID, - queue: [], - volume: 100, - state: "STOP", - connection: null, - dispatcher: null - }; + async run(msg) { + var check = this.client.util.musicCheck(msg, "join"); + if (check === false) { return; } + + var vcID = msg.guild.channels.get(msg.member.voice.channelID); + const permissions = vcID.permissionsFor(msg.guild.me); + if (permissions.has("CONNECT") === false) { return msg.channel.send(this.client.speech(msg, ["join", "noConnect"])); } + if (permissions.has("SPEAK") === false) { return msg.channel.send(this.client.speech(msg, ["join", "noSpeak"])); } - vcID.join().then(connection => { vcSettings.connection = connection; }); - client.music.set(msg.guild.id, vcSettings); + var vcSettings = { + channel: vcID, + queue: [], + volume: 100, + state: "STOP", + connection: null, + dispatcher: null + }; - msg.channel.send(client.speech(msg, ["join", "success"]).replace("-channel", vcID.name)); -}; + vcID.join().then(connection => { vcSettings.connection = connection; }); + this.client.music.set(msg.guild.id, vcSettings); -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "join", - description: "Joins the VC that you are in.", usage: "" -}; - -exports.init = (client) => { client.music = new client.methods.Collection(); }; \ No newline at end of file + msg.channel.send(this.client.speech(msg, ["join", "success"], [["-param1", vcID.name]])); + } +}; \ No newline at end of file diff --git a/commands/Music/leave.js b/commands/Music/leave.js index 5ebde19..37ffc21 100644 --- a/commands/Music/leave.js +++ b/commands/Music/leave.js @@ -1,21 +1,20 @@ -exports.run = async (client, msg) => { - var vcID = client.funcs.musicCheck(msg); - if (vcID === false) { return; } +const { Command } = require("klasa"); - vcID.channel.leave(); - client.music.delete(msg.guild.id); - msg.channel.send(client.speech(msg, ["leave"]).replace("-channel", vcID.channel.name)); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "leave", - description: "Leaves the VC that you are in.", usage: "" -}; \ No newline at end of file +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "leave", + runIn: ["text"], + description: "Leaves the VC that you are in." + }); + } + + async run(msg) { + var vcID = this.client.util.musicCheck(msg); + if (vcID === false) { return; } + + vcID.channel.leave(); + this.client.music.delete(msg.guild.id); + msg.channel.send(this.client.speech(msg, ["leave"], [["-channel", vcID.channel.name]])); + } +}; \ No newline at end of file diff --git a/commands/Music/nowplaying.js b/commands/Music/nowplaying.js index e488d43..3d6f780 100644 --- a/commands/Music/nowplaying.js +++ b/commands/Music/nowplaying.js @@ -1,35 +1,35 @@ -const moment = require("moment"); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); +const { duration } = require("moment"); require("moment-duration-format"); -exports.run = async (client, msg) => { - const handler = client.music.get(msg.guild.id); - if (!handler) { throw client.speech(msg, ["func-music", "general", "noQueue"]); } - if (handler.queue.length < 1) { return msg.channel.send(client.speech(msg, ["nowplaying", "noQueue"])); } - if (handler.state !== "PLAY") { return msg.channel.send(client.speech(msg, ["nowplaying", "notPlay"])); } - - let song = handler.queue[0]; - const embed = new client.methods.Embed() - .setColor(0x04d5fd) - .setTimestamp() - .setTitle(`šŸ“» __${msg.guild.name}'s Music Stream__`) - .setDescription("*Streaming all your requests from the fabulous library of Youtube.*") - .setThumbnail(song.image) - .addField("**Title:**", `[${song.title}](${song.url})`) - .addField("**Requested by:**", song.requester, true) - .addField("**Time Left:**", `${moment.duration((song.seconds * 1000) - handler.dispatcher.count).format("h:mm:ss", { trim: false })} out of ` + moment.duration(song.seconds * 1000).format("h:mm:ss", { trim: false }), true); - - msg.channel.send({embed}); -}; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "nowplaying", + aliases: ["np", "whatsplaying", "whatsplayingfam"], + runIn: ["text"], + requiredPermissions: ["EMBED_LINKS"], + description: "See what's currently playing in VC." + }); + } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["np", "whatsplaying", "whatsplayingfam"], - permLevel: 0, - botPerms: ["EMBED_LINKS"] -}; + async run(msg) { + const handler = this.client.music.get(msg.guild.id, "handler"); + if (!handler) { throw this.client.speech(msg, ["func-music", "general", "noQueue"]); } + if (handler.queue.length < 1) { return this.client.speech(msg, ["nowplaying", "noQueue"]); } + if (handler.state !== "PLAY") { return this.client.speech(msg, ["nowplaying", "notPlay"]); } + + let song = handler.queue[0]; + const embed = new MessageEmbed() + .setColor(0x04d5fd) + .setTimestamp() + .setTitle(`šŸ“» __${msg.guild.name}'s Music Stream__`) + .setDescription("*Streaming all your requests from the fabulous library of Youtube.*") + .addField("**Title:**", `[${song.title}](${song.url})`) + .addField("**Requested by:**", song.requester, true) + .addField("**Time Left:**", `${duration((song.seconds * 1000) - handler.dispatcher.streamTime).format("h:mm:ss", { trim: false })} out of ${duration(song.seconds * 1000).format("h:mm:ss", { trim: false })}`, true); -exports.help = { - name: "nowplaying", - description: "See what's currently playing in VC.", usage: "" -}; + msg.channel.send({embed}); + } +}; \ No newline at end of file diff --git a/commands/Music/pause.js b/commands/Music/pause.js index ab12d88..dc7a9f5 100644 --- a/commands/Music/pause.js +++ b/commands/Music/pause.js @@ -1,22 +1,21 @@ -exports.run = async (client, msg) => { - var handler = client.funcs.musicCheck(msg); - if (handler === false) { return; } - if (handler.state === "PAUSE") { return msg.send(client.speech(msg, ["pause", "paused"])); } +const { Command } = require("klasa"); - handler.state = "PAUSE"; - handler.dispatcher.pause(); - msg.send(client.speech(msg, ["pause", "success"])); -}; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "pause", + runIn: ["text"], + description: "Pause the playlist." + }); + } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; + async run(msg) { + var handler = this.client.util.musicCheck(msg, "handler"); + if (handler === false) { return; } + if (handler.state === "PAUSE") { return msg.channel.send(this.client.speech(msg, ["pause", "paused"])); } -exports.help = { - name: "pause", - description: "Pauses the playlist.", usage: "" -}; + handler.dispatcher.pause(); //Breaks when the bot hasn't started to play yet. Potentially a musicCheck requirement. + handler.state = "PAUSE"; //Execute after since bot will not be able to resume if pause() errors + msg.channel.send(this.client.speech(msg, ["pause", "success"])); + } +}; \ No newline at end of file diff --git a/commands/Music/play.js b/commands/Music/play.js index 086b6b4..e86b37b 100644 --- a/commands/Music/play.js +++ b/commands/Music/play.js @@ -1,62 +1,61 @@ +const { Command } = require("klasa"); const yt = require("ytdl-core"); -exports.run = async (client, msg) => { - const handler = client.music.get(msg.guild.id); - - if (!handler) { - if(msg.member.voice.channelID) { - await client.commands.get("join").run(client, msg); - if(!client.music.get(msg.guild.id)) { return; } - return this.run(client, msg); +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "play", + runIn: ["text"], + requiredPermissions: ["CONNECT", "SPEAK"], + description: "Plays the queue of music." + }); } - throw client.speech(msg, ["func-music", "general", "userVC"]); - } + async run(msg) { + const handler = this.client.music.get(msg.guild.id); + + if (!handler) { + if(msg.member.voice.channelID) { + await this.client.commands.get("join").run(msg); + if (!this.client.music.get(msg.guild.id)) { return; } + return this.run(msg); + } - if (handler.state === "PLAY") { - if (msg.member.voice.channelID !== handler.channel.id) { throw client.speech(msg, ["func-music", "general", "mismatch"]); } + throw msg.channel.send(this.client.speech(msg, ["func-music", "general", "userVC"])); + } - throw client.speech(msg, ["play", "alreadyPlay"]); - } else if (handler.state === "PAUSE") { return client.commands.get("resume").run(client, msg); } - else { handler.state = "PLAY"; } + if (handler.state === "PLAY") { + if (msg.member.voice.channelID !== handler.channel.id) { throw msg.channel.send(this.client.speech(msg, ["func-music", "general", "mismatch"])); } - if(handler.queue.length === 0) { return msg.channel.send(client.speech(msg, ["play", "noQueue"])); } + throw msg.channel.send(this.client.speech(msg, ["play", "alreadyPlay"])); + } else if (handler.state === "PAUSE") { return this.client.commands.get("resume").run(msg); } + + if (handler.queue.length === 0) { return msg.channel.send(this.client.speech(msg, ["play", "noQueue"])); } - (function play(song) { - if (song === undefined) { - return msg.channel.send(client.speech(msg, ["play", "allDone"])).then(() => { - handler.state = "STOP"; - }); - } + handler.state = "PLAY"; + this.play(msg, handler, handler.queue[0]); - msg.channel.send(client.speech(msg, ["play", "nextSong"]) - .replace("-request", song.requester) - .replace("-title", song.title)); + return null; + } + + play(msg, handler, song) { + if (song === undefined) { + return msg.channel.send(this.client.speech(msg, ["play", "allDone"])).then(() => { + handler.state = "STOP"; + }); + } + + msg.channel.send(this.client.speech(msg, ["play", "nextSong"], [["-param1", song.requester], ["-param2", song.title]])); - return handler.dispatcher = handler.connection.play(yt(song.url, { audioonly: true }), { passes: 2 }) - .on("end", () => { setTimeout(() => { - handler.queue.shift(); - play(handler.queue[0]); - }, 100); }) + return handler.dispatcher = handler.connection.play(yt(song.url, { audioonly: true }), { passes: 2 }) + .on("end", () => { setTimeout(() => { + handler.queue.shift(); + this.play(msg, handler, handler.queue[0]); + }, 100); }) - .on("error", err => msg.channel.send(`error: ${err}`).then(() => { - handler.queue.shift(); - play(handler.queue[0]); - })); - }(handler.queue[0])); - - return null; -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], permLevel: 0, - botPerms: ["CONNECT", "SPEAK"] -}; - -exports.help = { - name: "play", - description: "Plays the queue of music.", - usage: "[songURL:str]" + .on("error", err => msg.channel.send(`error: ${err}`).then(() => { + handler.queue.shift(); + this.play(msg, handler, handler.queue[0]); + })); + } }; \ No newline at end of file diff --git a/commands/Music/queue.js b/commands/Music/queue.js index 4fdea8e..4a84f7a 100644 --- a/commands/Music/queue.js +++ b/commands/Music/queue.js @@ -1,39 +1,39 @@ -const moment = require("moment"); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); +const { duration } = require("moment"); require("moment-duration-format"); -exports.run = (client, msg, page) => { - const handler = client.music.get(msg.guild.id); - if (!handler) { throw client.speech(msg, ["func-music", "general", "noQueue"]); } - - if (page.length < 1 || page === 1) { page = 1; var count = 0; } - else { var count = (10 * (page - 1)); } - - if (handler.queue.length < count) { return msg.channel.send(client.speech(msg, ["queue"]).replace("-pgs", Math.ceil(handler.queue.length / 10))); } - - const embed = new client.methods.Embed() - .setColor(0x04d5fd) - .setTitle(`šŸ“» __${msg.guild.name}'s Stream of Music__`) - .setDescription(`Currently streaming ${handler.queue.length} ${(handler.queue.length === 1) ? "song" : "songs"}.`) - .setThumbnail(msg.guild.iconURL()) - .setFooter(`Page: ${page} of ` + Math.ceil(handler.queue.length / 10)); - - for (let i = count; i < Math.min(handler.queue.length, (count + 10)); i++) { - embed.addField(`${i + 1}) ` + handler.queue[i].title, `Requested by: ${handler.queue[i].requester} - Run time: ` + moment.duration(handler.queue[i].seconds * 1000).format("h:mm:ss", { trim: false })); - } - - msg.send(embed); //There is an error here. No idea why but it doesn't affect anything so I'm leaving it alone. -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: ["EMBED_LINKS"] -}; - -exports.help = { - name: "queue", - description: "Displays the music queue.", - usage: "[page:int]", humanUse: "[Page number]" +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "queue", + runIn: ["text"], + requiredPermissions: ["EMBED_LINKS"], + description: "Displays the music queue.", + usage: "[page:int]" + }); + } + + async run(msg, [page=1]) { + const handler = this.client.music.get(msg.guild.id); + if (!handler) { throw this.client.speech(msg, ["func-music", "general", "noQueue"]); } + + if (page.length < 1 || page === 1) { page = 1; var count = 0; } + else { var count = (10 * (page - 1)); } + + if (handler.queue.length < count) { return this.client.speech(msg, ["queue"], [Math.ceil(handler.queue.length / 10)]); } + + const embed = new MessageEmbed() + .setColor(0x04d5fd) + .setTitle(`šŸ“» __${msg.guild.name}'s Stream of Music__`) + .setDescription(`Currently streaming ${handler.queue.length} ${(handler.queue.length === 1) ? "song" : "songs"}.`) + .setThumbnail(msg.guild.iconURL()) + .setFooter(`Page: ${page} of ${Math.ceil(handler.queue.length / 10)}`); + + for (let i = count; i < Math.min(handler.queue.length, (count + 10)); i++) { + embed.addField(`${i + 1}) ${handler.queue[i].title}`, `Requested by: ${handler.queue[i].requester} - Run time: ${duration(handler.queue[i].seconds * 1000).format("h:mm:ss", { trim: false })}`); + } + + msg.channel.send({embed}); + } }; \ No newline at end of file diff --git a/commands/Music/queueadd.js b/commands/Music/queueadd.js index b110e45..a06c1bc 100644 --- a/commands/Music/queueadd.js +++ b/commands/Music/queueadd.js @@ -1,54 +1,50 @@ -const yt = require("ytdl-core"); +const { Command } = require("klasa"); +const { getInfo } = require("ytdl-core"); const ytPlay = require("youtube-playlist"); -const getInfoAsync = require("util").promisify(yt.getInfo); +const getInfoAsync = require("util").promisify(getInfo); -exports.run = async (client, msg, [song]) => { - var handler = client.funcs.musicCheck(msg); - if (handler === false) { return; } - var id = []; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "queueadd", + runIn: ["text"], + description: "Adds a song or a playlist to the queue.", + usage: "[song:str]", + extendedHelp: "Note: Only Youtube song and Youtube playlist URLs only. Youtube mixes do not count." + }); + } - if (song.match(/(playlist\?list=\S{30,34})/)) { - msg.send(client.speech(msg, ["queueadd", "listDetect"])); - var list = await Promise.resolve(ytPlay(song, "id")); + async run(msg, [song]) { + var handler = this.client.util.musicCheck(msg); + if (handler === false) { return; } - for(var x = 0; x < list.data.playlist.length; x++) { - id.push(list.data.playlist[x]); + var id = []; + + if (song.match(/(playlist\?list=\S{30,34})/)) { + msg.channel.send(this.client.speech(msg, ["queueadd", "listDetect"])); + var list = await Promise.resolve(ytPlay(song, "id")); + + for(var x = 0; x < list.data.playlist.length; x++) { + id.push(list.data.playlist[x]); + } + } else if (song.match(/(?:v=)(\S{11})/)) { + id.push(song.match(/(?:v=)(\S{11})/)[1]); + } else { throw msg.channel.send(this.client.speech(msg, ["queueadd", "noURL"])); } + + for (var x = 0; x < id.length; x++) { + try { + var info = await getInfoAsync("https://youtu.be/" + id[x]); + + handler.queue.push({ + url: `https://youtu.be/${id[x]}`, + title: info.title, + seconds: info.length_seconds, + requester: msg.author.tag + }); + } catch(err) { msg.channel.send(this.client.speech(msg, ["queueadd", "errCatch"], [["-param1", id[x]]])); } + } + + if (id.length === 1) { msg.channel.send(this.client.speech(msg, ["queueadd", "success"], [["-param1", info.title]])); } + else { msg.channel.send(this.client.speech(msg, ["queueadd", "multi"], [["-param1", id.length]])); } } - } else if (song.match(/(?:v=)(\S{11}$)/)) { - id.push(song.split(".com/")[1].match(/(?:v=)(\S{11}$)/)[1]); - } else { throw client.speech(msg, ["queueadd", "noURL"]); } - - for(var x = 0; x < id.length; x++) { - try { - var info = await getInfoAsync("https://youtu.be/" + id[x]); - - handler.queue.push({ - url: "https://youtu.be/" + id[x], - title: info.title, - seconds: info.length_seconds, - requester: msg.author.tag, - image: info.thumbnail_url - }); - } catch(err) { - msg.send("Whoops! Looks like I can't access this video. "); - } - } - - if (id.length === 1) { msg.send(client.speech(msg, ["queueadd", "success"]).replace("-title", info.title)); } - else { msg.send(client.speech(msg, ["queueadd", "multi"]).replace("-number", id.length)); } -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "queueadd", - description: "Adds a song or a playlist to the queue.", - usage: "[song:str]", humanUse: "[Song/Playlist URL]", - extendedHelp: "Note: Only Youtube song and Youtube playlist URLs only. Youtube mixes do not count." }; \ No newline at end of file diff --git a/commands/Music/remove.js b/commands/Music/remove.js index 7174ffb..c222813 100644 --- a/commands/Music/remove.js +++ b/commands/Music/remove.js @@ -1,24 +1,22 @@ -exports.run = async (client, msg, [songID]) => { - var handler = client.funcs.musicCheck(msg); - if (handler === false) { return; } - if (Number.isInteger(songID) === false) { return msg.channel.send(client.speech(msg, ["remove", "noInt"])); } +const { Command } = require("klasa"); - songID = songID - 1; - var title = handler.queue[songID].title; - handler.queue.splice(songID, 1); - msg.channel.send(client.speech(msg, ["remove", "success"]).replace("-title", title)); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "remove", - description: "Removes a song from the queue.", - usage: "[songID:int]", humanUse: "[Song number]" -}; \ No newline at end of file +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "remove", + runIn: ["text"], + description: "Removes a song from the queue.", + usage: "[songID:int]" + }); + } + + async run(msg, [songID=songID - 1]) { + var handler = this.client.util.musicCheck(msg); + if (handler === false) { return; } + if (songID === 0) { return this.client.commands.get("skip").run(msg); } + + var title = handler.queue[songID].title; + handler.queue.splice(songID, 1); + msg.channel.send(this.client.speech(msg, ["remove"], [["-song", title]])); + } +}; \ No newline at end of file diff --git a/commands/Music/resume.js b/commands/Music/resume.js index 1f22759..06d0c0a 100644 --- a/commands/Music/resume.js +++ b/commands/Music/resume.js @@ -1,22 +1,21 @@ -exports.run = async (client, msg) => { - var handler = client.funcs.musicCheck(msg); - if (handler === false) { return; } - if (handler.state !== "PAUSE") { return msg.channel.send(client.speech(msg, ["resume", "noPause"])); } +const { Command } = require("klasa"); - handler.dispatcher.resume(); - handler.state = "PLAY"; - msg.channel.send(client.speech(msg, ["resume", "success"])); -}; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "resume", + runIn: ["text"], + description: "Resumes the playlist." + }); + } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; + async run(msg) { + var handler = this.client.util.musicCheck(msg, "handler"); + if (handler === false) { return; } + if (handler.state !== "PAUSE") { return msg.channel.send(this.client.speech(msg, ["resume", "noPause"])); } -exports.help = { - name: "resume", - description: "Resumes the playlist.", usage: "" -}; + handler.dispatcher.resume(); + handler.state = "PLAY"; + msg.channel.send(this.client.speech(msg, ["resume", "success"])); + } +}; \ No newline at end of file diff --git a/commands/Music/skip.js b/commands/Music/skip.js index 271612f..3e2e7d6 100644 --- a/commands/Music/skip.js +++ b/commands/Music/skip.js @@ -1,20 +1,19 @@ -exports.run = async (client, msg) => { - var handler = client.funcs.musicCheck(msg); - if (handler === false) { return; } +const { Command } = require("klasa"); - handler.dispatcher.end(); - msg.channel.send(client.speech(msg, ["skip"])); -}; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "skip", + runIn: ["text"], + description: "Skips the current song." + }); + } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; + async run(msg) { + var handler = this.client.util.musicCheck(msg, "handler"); + if (handler === false) { return; } -exports.help = { - name: "skip", - description: "Skips the current song.", usage: "" -}; + handler.dispatcher.end(); + msg.channel.send(this.client.speech(msg, ["skip"])); + } +}; \ No newline at end of file diff --git a/commands/Music/volume.js b/commands/Music/volume.js index 85a0f8d..2ae48bf 100644 --- a/commands/Music/volume.js +++ b/commands/Music/volume.js @@ -1,29 +1,29 @@ -exports.run = async (client, msg, [volume]) => { - var handler = client.funcs.musicCheck(msg); - if (handler === false) { return; } +const { Command } = require("klasa"); - if (!volume) { return msg.send(client.speech(msg, ["volume", "noArgs"]).replace("-vol", Math.round(dispatcher.volume * 50))); } - if (volume === 0) { return msg.send(client.speech(msg, ["volume", "zero"])); } - if (volume > 100) { return msg.send(client.speech(msg, ["volume", "overHun"])); } - if (handler.playing !== "PLAY") { return msg.send(client.speech(msg, ["volume", "notPlay"])); } +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "volume", + runIn: ["text"], + aliases: ["vol"], + description: "Manage the volume for current song.", + usage: "[volume:int]" + }); + } - const dispatcher = handler.dispatcher; - var emote = (volume < (dispatcher.volume * 50)) ? ["šŸ”‰ Decreasing"] : ["šŸ”Š Increasing"]; + async run(msg, [volume]) { + var handler = this.client.util.musicCheck(msg, "handler"); + if (handler === false) { return; } - dispatcher.setVolume(Math.min(volume) / 50, 2); - msg.send(client.speech(msg, ["volume", "success"]).replace("-action", emote).replace("-vol", Math.round(dispatcher.volume * 50))); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["vol"], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "volume", - description: "Manage the volume for current song.", - usage: "[volume:int]", humanUse: "[Volume percentage]" + if (!volume) { return msg.channel.send(this.client.speech(msg, ["volume", "noArgs"], [["-vol",Math.round(dispatcher.volume * 50)]])); } + if (volume === 0) { return msg.channel.send(this.client.speech(msg, ["volume", "zero"])); } + if (volume > 100) { return msg.channel.send(this.client.speech(msg, ["volume", "overHun"])); } + if (handler.playing !== "PLAY") { return msg.channel.send(this.client.speech(msg, ["volume", "notPlay"])); } + + const dispatcher = handler.dispatcher; + var emote = (volume < (dispatcher.volume * 50)) ? ["šŸ”‰ Decreasing"] : ["šŸ”Š Increasing"]; + + dispatcher.setVolume(Math.min(volume) / 50, 2); + msg.channel.send(this.client.speech(msg, ["volume", "success"], [["-param1", emote], ["-param2", Math.round(dispatcher.volume * 50)]])); + } }; \ No newline at end of file diff --git a/index.js b/index.js index 34ef568..6246e0d 100644 --- a/index.js +++ b/index.js @@ -33,6 +33,7 @@ client.util = util; //All utility functions and extra search functions if (!existsSync(config.database)) { dataManager("init"); } //Init the SQLite Database client.ownerSetting = new Collection(); +client.music = new Collection(); var keys = Object.keys(config); for (var x = 0; keys.length > x; x++) { diff --git a/utilities/utilExport.js b/utilities/utilExport.js index f8cb931..0d6e198 100644 --- a/utilities/utilExport.js +++ b/utilities/utilExport.js @@ -77,16 +77,19 @@ exports.util = { msg.channel.send(client.speech(msg, ["func-music", "general", "userVC"])); return false; } else if (tag !== "join") { - if (!client.music.get(msg.guild.id)) { + var handler = client.music.get(msg.guild.id); + if (!handler) { msg.channel.send(client.speech(msg, ["func-music", "general", "noQueue"])); return false; - } else if (msg.member.voice.channelID !== client.music.get(msg.guild.id).channel.id) { + } else if (msg.member.voice.channelID !== handler.channel.id) { msg.channel.send(client.speech(msg, ["func-music", "general", "mismatch"])); return false; - } + } else if (tag === "handler" && !handler.dispatcher) { + msg.channel.send(client.speech(msg, ["func-music", "general", "noHandler"])); + } - return client.music.get(msg.guild.id); - } + return handler; + } return true; }, From 3875e31f20d20760d7bbfc7ffcf42b1ca59798b2 Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Sun, 26 Jan 2020 01:32:23 -0400 Subject: [PATCH 36/38] Fun Module Migrated + More Cleanup - As of this commit, all fun commands are migrated! - Added a fix in dataManager where "bugs" should have been "bug". This will break further updates if user uses the previous database setup. - Removed the bingo command. - Cleaned up lines that are redundant across all files - Fixed a few cases where client was not defined for speech component. --- assets/speech/en-CA/fun.js | 29 ++++++++++++++++++++++ commands/Economy/Cooking/fish.js | 1 - commands/Economy/Cooking/harvest.js | 1 - commands/Economy/Cooking/sell.js | 1 - commands/Economy/Games/chouhan.js | 2 ++ commands/Economy/Games/coin.js | 2 ++ commands/Economy/Games/hazard.js | 2 ++ commands/Economy/Games/twoup.js | 2 ++ commands/Economy/balance.js | 1 - commands/Economy/daily.js | 3 +-- commands/Economy/exchange.js | 1 - commands/Economy/rep.js | 1 - commands/Fun/Interactions/8ball.js | 29 ++++++++++------------ commands/Fun/Interactions/baka.js | 36 +++++++++++++-------------- commands/Fun/Interactions/crash.js | 29 +++++++++++----------- commands/Fun/bingo.js | 26 -------------------- commands/Fun/killme.js | 38 ++++++++++++++--------------- commands/General/avatar.js | 1 - commands/General/choose.js | 2 +- commands/General/greet.js | 6 +---- commands/General/help.js | 6 ++--- commands/General/userinfo.js | 2 +- commands/Mod/purge.js | 2 +- commands/Owner/presence.js | 32 ++++++++++++------------ commands/Owner/setAvatar.js | 1 - commands/System/about.js | 11 ++++----- commands/System/report.js | 2 -- utilities/dataManager.js | 4 +-- 28 files changed, 133 insertions(+), 140 deletions(-) delete mode 100644 commands/Fun/bingo.js diff --git a/assets/speech/en-CA/fun.js b/assets/speech/en-CA/fun.js index ce3e2bd..1ef9d12 100644 --- a/assets/speech/en-CA/fun.js +++ b/assets/speech/en-CA/fun.js @@ -43,4 +43,33 @@ exports.poll = { 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 diff --git a/commands/Economy/Cooking/fish.js b/commands/Economy/Cooking/fish.js index 8566b9d..b529754 100644 --- a/commands/Economy/Cooking/fish.js +++ b/commands/Economy/Cooking/fish.js @@ -6,7 +6,6 @@ module.exports = class extends Command { name: "fish", enabled: true, runIn: ["text"], - aliases: [], cooldown: 30, description: "Fish and try to turn your credits into a fortune!", extendedHelp: "Spend 10 credits to fish and catch yourself a fortune! (30 second cooldown)" diff --git a/commands/Economy/Cooking/harvest.js b/commands/Economy/Cooking/harvest.js index acf5b11..2cab5a5 100644 --- a/commands/Economy/Cooking/harvest.js +++ b/commands/Economy/Cooking/harvest.js @@ -6,7 +6,6 @@ module.exports = class extends Command { name: "harvest", enabled: true, runIn: ["text"], - aliases: [], cooldown: 30, description: "Harvest fruits and other foods for cooking!", extendedHelp: "Spend 10 credits to gather materials! (30 second cooldown)" diff --git a/commands/Economy/Cooking/sell.js b/commands/Economy/Cooking/sell.js index 3e2aaed..22c6108 100644 --- a/commands/Economy/Cooking/sell.js +++ b/commands/Economy/Cooking/sell.js @@ -6,7 +6,6 @@ module.exports = class extends Command { name: "sell", enabled: true, runIn: ["text"], - aliases: [], description: "Sell your items!", usage: " [amount:int]", usageDelim: " " }); diff --git a/commands/Economy/Games/chouhan.js b/commands/Economy/Games/chouhan.js index 21ffbfd..7f61c25 100644 --- a/commands/Economy/Games/chouhan.js +++ b/commands/Economy/Games/chouhan.js @@ -11,6 +11,8 @@ module.exports = class extends Command { 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." }); + + this.humanUse = " "; } async run(msg, [choice=choice.toLowerCase(), bet]) { diff --git a/commands/Economy/Games/coin.js b/commands/Economy/Games/coin.js index 1bcb2b6..43c58e0 100644 --- a/commands/Economy/Games/coin.js +++ b/commands/Economy/Games/coin.js @@ -9,6 +9,8 @@ module.exports = class extends Command { description: "Flip a coin!", usage: " ", usageDelim: " " }); + + this.humanUse = " "; } async run(msg, [choice=choice.toLowerCase(), bet]) { diff --git a/commands/Economy/Games/hazard.js b/commands/Economy/Games/hazard.js index 42fae27..97c3353 100644 --- a/commands/Economy/Games/hazard.js +++ b/commands/Economy/Games/hazard.js @@ -21,6 +21,8 @@ module.exports = class extends Command { 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." }); + + this.humanUse = ""; } async run(msg, [bet]) { diff --git a/commands/Economy/Games/twoup.js b/commands/Economy/Games/twoup.js index a7f7d19..831ba40 100644 --- a/commands/Economy/Games/twoup.js +++ b/commands/Economy/Games/twoup.js @@ -10,6 +10,8 @@ module.exports = class extends Command { 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." }); + + this.humanUse = ""; } async run(msg, [bet]) { diff --git a/commands/Economy/balance.js b/commands/Economy/balance.js index 6a4a65e..cea2d48 100644 --- a/commands/Economy/balance.js +++ b/commands/Economy/balance.js @@ -7,7 +7,6 @@ module.exports = class extends Command { name: "balance", enabled: true, runIn: ["text"], - cooldown: 0, aliases: ["bal", "credits", "profile"], requiredPermissions: ["EMBED_LINKS"], description: "Check credit amounts and cooldowns", diff --git a/commands/Economy/daily.js b/commands/Economy/daily.js index f761802..df2be42 100644 --- a/commands/Economy/daily.js +++ b/commands/Economy/daily.js @@ -6,9 +6,8 @@ module.exports = class extends Command { name: "daily", enabled: true, runIn: ["text"], - aliases: [], description: "Get a daily amount of credits or give them to someone else.", - usage: "[user:usersearch]", + usage: "[user:usersearch]" }); } diff --git a/commands/Economy/exchange.js b/commands/Economy/exchange.js index 7451f4b..9699883 100644 --- a/commands/Economy/exchange.js +++ b/commands/Economy/exchange.js @@ -7,7 +7,6 @@ module.exports = class extends Command { enabled: true, runIn: ["text"], cooldown: 10, - aliases: [], description: "Give someone some of your credits", usage: "[user:usersearch] [credit:int]", usageDelim: " " }); diff --git a/commands/Economy/rep.js b/commands/Economy/rep.js index 96c66bf..464fbf2 100644 --- a/commands/Economy/rep.js +++ b/commands/Economy/rep.js @@ -6,7 +6,6 @@ module.exports = class extends Command { name: "rep", enabled: true, runIn: ["text"], - aliases: [], description: "Give someone a reputation point!", usage: "[user:usersearch] [note:str]", usageDelim: "|" }); diff --git a/commands/Fun/Interactions/8ball.js b/commands/Fun/Interactions/8ball.js index 896c541..d2267af 100644 --- a/commands/Fun/Interactions/8ball.js +++ b/commands/Fun/Interactions/8ball.js @@ -1,19 +1,16 @@ -exports.run = async (client, message, [args]) => { - let response = ["Yes", "Maybe", "No", "Try again later", "Possibly", "Absolutely", "Probably not", "Outcome is looking good", "Outcome not looking good", "The stars say yes"]; +const { Command } = require("klasa"); - message.channel.send(`${response[~~(Math.random() * response.length)]}, ${message.author.username}.`); -}; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "8ball", + enabled: true, + runIn: ["text"], + description: "Ask the magic 8ball wizard for an answer!" + }); + } -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "8ball", - description: "Ask the magic 8ball wizard for an answer!", - usage: "[args:str][...]" + async run(msg) { + msg.channel.send(this.client.speech(msg, ["func-fun", "eightball"], [["-user", msg.author.username]])); + } }; \ No newline at end of file diff --git a/commands/Fun/Interactions/baka.js b/commands/Fun/Interactions/baka.js index e23d391..7f23302 100644 --- a/commands/Fun/Interactions/baka.js +++ b/commands/Fun/Interactions/baka.js @@ -1,19 +1,19 @@ -exports.run = async (client, msg, [user]) => { - var data = await client.funcs.userSearch(client, msg, {user: [user], name: this.help.name}); - if (data.valid !== false) { msg.channel.send("Baka " + data.user[0].prefered + "!"); } -}; +const { Command } = require("klasa"); -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: ["userSearch"] -}; - -exports.help = { - name: "baka", - description: "For the stupid people.", - usage: "[user:str]" -}; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "baka", + enabled: true, + runIn: ["text"], + description: "For the stupid people", + usage: "[user:usersearch]" + }); + } + + async run(msg, [user]) { + if (user === null) { return; } + + msg.channel.send(`Baka ${user.username}!`); + } +}; \ No newline at end of file diff --git a/commands/Fun/Interactions/crash.js b/commands/Fun/Interactions/crash.js index abdc554..338ff45 100644 --- a/commands/Fun/Interactions/crash.js +++ b/commands/Fun/Interactions/crash.js @@ -1,17 +1,16 @@ -exports.run = async (client, message) => { - message.channel.send(`Wow. That's awful of you, ${message.author.username}. I'm just here trying to be helpful and make friends but you want to shut me down. Quite rude!`); -}; +const { Command } = require("klasa"); -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "crash", - description: "šŸ‘€ Do it. I dare you to.", - usage: "" +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "crash", + enabled: true, + runIn: ["text"], + description: "šŸ‘€ Do it. I dare you to." + }); + } + + async run(msg) { + msg.channel.send(this.client.speech(msg, ["func-fun", "crash"], [["-user", msg.author.username]])); + } }; \ No newline at end of file diff --git a/commands/Fun/bingo.js b/commands/Fun/bingo.js deleted file mode 100644 index 07a4509..0000000 --- a/commands/Fun/bingo.js +++ /dev/null @@ -1,26 +0,0 @@ -exports.run = function(client, message){ - let y = Math.floor(Math.random() * (Math.floor(75) - Math.ceil(1) + 1)) + Math.ceil(1); - let x = null; - - if (y < 15) { x = "B"; } - else if (y < 30){ x = "I"; } - else if (y < 45){ x = "N"; } - else if (y < 60){ x = "G"; } - else { x = "O"; } - - message.channel.send(x + y); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "bingo", - description: "Supplies bingo numbers to play bingo.", - usage: "" -}; diff --git a/commands/Fun/killme.js b/commands/Fun/killme.js index af2ee4e..9a7522a 100644 --- a/commands/Fun/killme.js +++ b/commands/Fun/killme.js @@ -1,20 +1,20 @@ -exports.run = function(client, message) { - message.channel.send(`${message.author.username} has died.`).then(Message => { - setTimeout(() => { Message.edit("Respawning..."); }, 1000); - setTimeout(() => { Message.edit(`Revival complete. Welcome back, ${message.author.username}`); }, 1000); - }); -}; +const { Command } = require("klasa"); -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: ["kms"], - permLevel: 0, - botPerms: [] -}; - -exports.help = { - name: "killme", - description: "Kill yourself with this command. Now comes with free revival!", - usage: "" -}; +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "killme", + enabled: true, + runIn: ["text"], + aliases: ["kms"], + description: "Kill yourself with this command. Now comes with free revival!" + }); + } + + async run(msg) { + msg.channel.send(`${msg.author.username} has died.`).then(Message => { + setTimeout(() => { Message.edit("Respawning..."); }, 1000); + setTimeout(() => { Message.edit(`Revival complete. Welcome back, ${msg.author.username}`); }, 1000); + }); + } +}; \ No newline at end of file diff --git a/commands/General/avatar.js b/commands/General/avatar.js index 15a15cb..d53b8fc 100644 --- a/commands/General/avatar.js +++ b/commands/General/avatar.js @@ -6,7 +6,6 @@ module.exports = class extends Command { name: "avatar", enabled: true, runIn: ["text"], - aliases: [], requiredPermissions: ["ATTACH_FILES"], description: "Fetch a user's avatar!", usage: "[user:usersearch]" diff --git a/commands/General/choose.js b/commands/General/choose.js index f546dca..0f80bab 100644 --- a/commands/General/choose.js +++ b/commands/General/choose.js @@ -14,7 +14,7 @@ module.exports = class extends Command { } async run(msg, [...choice]) { - if (choice.length < 2) { return msg.channel.send(client.speech(msg, ["choose", "lackChoice"])); } + if (choice.length < 2) { return msg.channel.send(this.client.speech(msg, ["choose", "lackChoice"])); } var numChoice = Math.floor(Math.random() * choice.length); msg.channel.send(this.client.speech(msg, ["choose", "success"], [["-user", msg.author.username], ["-result", choice[numChoice]]])); diff --git a/commands/General/greet.js b/commands/General/greet.js index c1df3a1..892231e 100644 --- a/commands/General/greet.js +++ b/commands/General/greet.js @@ -1,7 +1,4 @@ const { Command } = require("klasa"); -const { MessageEmbed } = require("discord.js"); -const AnilistNode = require("anilist-node"); -const anilist = new AnilistNode(); module.exports = class extends Command { constructor(...args) { @@ -9,7 +6,6 @@ module.exports = class extends Command { name: "greet", enabled: true, runIn: ["text"], - aliases: [], description: "Have Margarine greet you or someone with a hello!", usage: "[user:usersearch]" }); @@ -19,6 +15,6 @@ module.exports = class extends Command { if (user === null) { return; } if (user.id === this.client.user.id) { return msg.send(this.client.speech(msg, ["greet", "me"], [["-param1", msg.author.username]])); } - msg.send(this.client.speech(msg, ["greet", "success"], [["-param1", user.username]])); + msg.channel.send(this.client.speech(msg, ["greet", "success"], [["-param1", user.username]])); } }; \ No newline at end of file diff --git a/commands/General/help.js b/commands/General/help.js index b6e9cdb..ca635b8 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -56,17 +56,17 @@ module.exports = class extends Command { cmd = this.client.commands.get(cmd) || this.client.aliases.get(cmd); if (!cmd) { return msg.send("āŒ | Unknown command, please run the help command with no arguments to get a list of categories."); } - var usage = cmd.humanUse ? [cmd.humanUse, "_"] : [cmd.usageString, " "]; + var usage = cmd.humanUse ? [cmd.humanUse.trim(), "_"] : [cmd.usageString, " "]; var usageAct = usage.length < 1 ? "": usage[0].split(usage[1]).join(cmd.usageDelim); var alias = cmd.aliases.length > 0 ? ` aka: (${cmd.aliases.join(", ")})`: ""; - + const embed = new MessageEmbed() .setColor(0x04d5fd) .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]); - if (cmd.extendedHelp) { embed.addField("Extended Help:", cmd.extendedHelp); } + if (typeof cmd.extendedHelp === "string") { embed.addField("Extended Help:", cmd.extendedHelp); } msg.send({embed}); } } diff --git a/commands/General/userinfo.js b/commands/General/userinfo.js index a2e0d0a..15e8ab0 100644 --- a/commands/General/userinfo.js +++ b/commands/General/userinfo.js @@ -33,7 +33,7 @@ module.exports = class extends Command { var activity; if (user.presence.activity === null) { activity = " "; } else if (user.presence.activity.name === "Custom Status") { - activity = " while doing " + user.presence.activity.state; + activity = ` while doing ${user.presence.activity.state}`; } else { switch (user.presence.activity.type) { //All cases covered case "PLAYING": diff --git a/commands/Mod/purge.js b/commands/Mod/purge.js index d45b168..6fc3681 100644 --- a/commands/Mod/purge.js +++ b/commands/Mod/purge.js @@ -35,7 +35,7 @@ module.exports = class extends Command { msg.channel.messages.fetch({ limit: msgCount }).then((messages) => { if (user && userCheck[2]) { - const filterBy = user ? user.id : client.user.id; + const filterBy = user ? user.id : this.client.user.id; messages = messages.filter(m => m.author.id === filterBy).array().slice(0, amount); var extra = `by ${user.tag} `; } diff --git a/commands/Owner/presence.js b/commands/Owner/presence.js index a19ff87..ee33aa5 100644 --- a/commands/Owner/presence.js +++ b/commands/Owner/presence.js @@ -1,17 +1,19 @@ -exports.run = async (client, msg, [status, game, type]) => { client.funcs.presenceHelper(client, game, type, status); }; +const { Command } = require("klasa"); -exports.conf = { - enabled: true, - runIn: ["text", "dm"], - aliases: [], - permLevel: 9, - botPerms: [] -}; - -exports.help = { - name: "presence", - description: "Sets Margarine's status entirely", - usage: " [game:str] [play|stream|listen|watch]", - usageDelim: " | ", - humanUse: "(online|idle|dnd|invisible)_(game)_(play|stream|listen|watch)" +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "presence", + enabled: true, + runIn: ["text", "dm"], + permissionLevel: 9, + description: "Set Margarine's status entirely", + usage: " [game:str] [play|stream|listen|watch]", + usageDelim: " | " + }); + } + + async run(msg, [status, game, type="play"]) { + this.client.util.presenceHelper(this.client, game, type, status); + } }; \ No newline at end of file diff --git a/commands/Owner/setAvatar.js b/commands/Owner/setAvatar.js index 2fb652f..59f120b 100644 --- a/commands/Owner/setAvatar.js +++ b/commands/Owner/setAvatar.js @@ -6,7 +6,6 @@ module.exports = class extends Command { name: "setavatar", enabled: true, runIn: ["text", "dm"], - aliases: [], permissionLevel: 9, description: "Set Margarine's avatar", usage: "[image:str]" diff --git a/commands/System/about.js b/commands/System/about.js index db0e937..2a7f2da 100644 --- a/commands/System/about.js +++ b/commands/System/about.js @@ -5,17 +5,16 @@ const { serverLink } = require("../../assets/settings.json"); module.exports = class extends Command { constructor(...args) { super(...args, { - name: 'about', - runIn: ['text', 'dm'], + name: "about", + runIn: ["text", "dm"], aliases: ["stats", "whoami"], guarded: true, - description: 'General information', - usage: "" + description: "General information" }); } async run(msg) { - var support = (serverLink && serverLink.length > 1) ? "| [Support Server](" + serverLink + ")" : ""; + var support = (serverLink && serverLink.length > 1) ? `| [Support Server](${serverLink})` : ""; const embed = new MessageEmbed() .setColor(0x37FDFC) @@ -26,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.ownerSetting.get("build").version} | Released on: ${this.client.ownerSetting.get("build").releaseDate}`); msg.channel.send({embed}); } diff --git a/commands/System/report.js b/commands/System/report.js index f556955..8e33e79 100644 --- a/commands/System/report.js +++ b/commands/System/report.js @@ -7,10 +7,8 @@ module.exports = class extends Command { name: "report", enabled: true, runIn: ["text"], - aliases: [], requiredPermissions: ["EMBED_LINKS"], description: "File a report to the bot owner. (ie: Bug, issue, complaint)", - usage: "", extendedHelp: "Margarine will be sliding into your DMs for a few questions. Be sure to have DMs open and ready to answer some questions!" }); } diff --git a/utilities/dataManager.js b/utilities/dataManager.js index 32a3a2b..a1543b7 100644 --- a/utilities/dataManager.js +++ b/utilities/dataManager.js @@ -19,10 +19,10 @@ module.exports = function dataManager(args, values, table) { if(tableCheck["count(*)"]) { return console.log("SQLite Database exists! Skipping creation step..."); } //Prevent crashing if SQLite database exists already db.prepare("CREATE TABLE users (userID TEXT, credits INTEGER, rep INTEGER, cooldowns TEXT, profiles TEXT)").run(); - db.prepare("CREATE TABLE awards (userID TEXT, suggest INTEGER, bugs INTEGER, minor INTEGER, major INTEGER)").run(); + db.prepare("CREATE TABLE awards (userID TEXT, suggest INTEGER, bug INTEGER, minor INTEGER, major INTEGER)").run(); db.prepare("CREATE TABLE stats (statName TEXT, count INTEGER)").run(); - db.prepare("INSERT INTO awards (userID, suggest, bugs, minor, major) VALUES (?, ?, ?, ?, ?)").run("Overall", 0, 0, 0, 0); + db.prepare("INSERT INTO awards (userID, suggest, bug, minor, major) VALUES (?, ?, ?, ?, ?)").run("Overall", 0, 0, 0, 0); db.prepare("INSERT INTO stats (statName, count) VALUES (?, ?)").run("report", 0); db.prepare("CREATE TABLE fishing (userID TEXT, trash INTEGER, fish INTEGER, crab INTEGER, squid INTEGER, shark INTEGER)").run(); From d3837cfcc077d7420f8ccb6b7b1882c8bc9d42ba Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Tue, 28 Jan 2020 15:41:29 -0400 Subject: [PATCH 37/38] Cleanup + Final Migration All code is now migrated! Cleanedup several functions and commands AniList and MAL usernames are now able to be removed through those commands. Added en-CA to language to fix an issue of changing the language settings and not being able to revert back. Added a revoke command to delete all user data for a user. Added a cooldown check to prevent spam daily -> revoke commands. Broke the award command into two commands, one for the general user and one for awarding. --- arguments/userSearch.js | 10 ++- assets/settingsExample.json | 4 +- assets/speech/en-CA/dataCheck.js | 5 ++ assets/speech/en-CA/economy.js | 15 ++++ assets/speech/en-CA/general.js | 31 +++------ assets/speech/en-CA/music.js | 3 +- assets/speech/en-CA/system.js | 31 ++++++++- assets/speech/en-CA/userSearch.js | 48 ------------- commands/Economy/daily.js | 9 +++ commands/Economy/revoke.js | 32 +++++++++ commands/General/anilist.js | 11 +-- commands/General/award.js | 110 +++++++++--------------------- commands/General/emoji.js | 8 +-- commands/General/mal.js | 10 +-- commands/General/manga.js | 93 +++++++++++++------------ commands/Music/queueadd.js | 2 +- commands/Owner/ecoedit.js | 34 --------- commands/Owner/giveAward.js | 48 +++++++++++++ events/ready.js | 2 + languages/en-CA.js | 15 ++++ package-lock.json | 29 ++++---- package.json | 12 ++-- utilities/dataManager.js | 2 +- utilities/presenceHelper.js | 2 +- utilities/speechHelper.js | 13 ++-- 25 files changed, 307 insertions(+), 272 deletions(-) delete mode 100644 assets/speech/en-CA/userSearch.js create mode 100644 commands/Economy/revoke.js delete mode 100644 commands/Owner/ecoedit.js create mode 100644 commands/Owner/giveAward.js create mode 100644 languages/en-CA.js diff --git a/arguments/userSearch.js b/arguments/userSearch.js index a36c62b..55d3348 100644 --- a/arguments/userSearch.js +++ b/arguments/userSearch.js @@ -17,11 +17,15 @@ module.exports = class extends Argument { if (arg === undefined) { return msg.author; } if (IDRegex.test(arg)) { return this.client.users.get(/(\d{17,21})/.exec(arg)[0]); } - var regex = new RegExp(regExpEsc(arg), "i"); - var results = msg.guild.members.filter(m => regex.test(m.user.username)); + var results = []; + + if (msg.guild) { + var regex = new RegExp(regExpEsc(arg), "i"); + results = msg.guild.members.filter(m => regex.test(m.user.username)); + } if (results.size === 0) { - msg.channel.send(this.client.speech(msg, ["func-userSearch", "default"])); + msg.channel.send(this.client.speech(msg, ["func-system", "usersearch"])); return null; } diff --git a/assets/settingsExample.json b/assets/settingsExample.json index ce70f02..31e2a37 100644 --- a/assets/settingsExample.json +++ b/assets/settingsExample.json @@ -3,8 +3,8 @@ "ownerID": "User ID", "prefix": "Prefix", "build": { - "version": "Release 1.0 - Klasa Rewrite (Developer)", - "releaseDate": "December 24th, 2019" + "version": "Release 1.0", + "releaseDate": "January 30th, 2020" }, "owner": { "channels": { diff --git a/assets/speech/en-CA/dataCheck.js b/assets/speech/en-CA/dataCheck.js index b046eb8..b2882cd 100644 --- a/assets/speech/en-CA/dataCheck.js +++ b/assets/speech/en-CA/dataCheck.js @@ -46,4 +46,9 @@ exports.noItems = [ //When an item does not exist in the items.json file. exports.noZero = [ //When a command requires a nonzero amount. "Hey! You don't have any of this!", "You can't have nothing here!" +]; + +exports.revoked = [ //User tried to make a new profile after deleting their data (Less than 24 hours) + "You can't do this yet! It's been too soon since you've deleted your own data.", + "Nope, wait a little longer if you want back in. There's a cooldown for deleting your own data." ]; \ No newline at end of file diff --git a/assets/speech/en-CA/economy.js b/assets/speech/en-CA/economy.js index 35c1cf1..889786b 100644 --- a/assets/speech/en-CA/economy.js +++ b/assets/speech/en-CA/economy.js @@ -28,3 +28,18 @@ 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." + ], + "success": [ + "Okay. I've deleted your data from my systems. If you want to give it to me again, wait 24 hours." + ], + "timeout": [ + "Whoops! Looks like you forgot to respond to me. I'm not waiting around anymore." + ] +} diff --git a/assets/speech/en-CA/general.js b/assets/speech/en-CA/general.js index 930fa77..0d2d5b4 100644 --- a/assets/speech/en-CA/general.js +++ b/assets/speech/en-CA/general.js @@ -3,6 +3,10 @@ exports.anilist = { "You're all set! I have your username in my systems now!", "āœ… Username added. You're good to go!" ], + "removeProfile": [ //Successfully removed profile. + "Okay! That username is no longer attached to you!", + "āœ… Username removed. You're good to go!" + ], "noUsername": [ //User has a profile but has not set their AniList profile. "Huh... that user appears to have not set their AniList profile in my systems yet.", "They haven't set their AniList profile yet! Try a general search for now." @@ -21,6 +25,10 @@ exports.mal = { "You're all set! I have your username in my systems now!", "āœ… Username added. You're good to go!" ], + "removeProfile": [ //Successfully removed profile. + "Okay! That username is no longer attached to you!", + "āœ… Username removed. You're good to go!" + ], "noUsername": [ //User has a profile but has not set their MAL profile. "Huh... that user appears to have not set their MAL profile in my systems yet.", "They haven't set their MAL profile yet! Try a general search for now." @@ -68,29 +76,6 @@ exports.manga = { exports.avatar = []; //Placeholder -exports.award = { - "noType": [ - "BAKA! I need a type of an award!", - "But, what kind of award are you giving someone? You never provided me with one!" - ], - "noText": [ - "Explain yourself on giving the award!", - "Tell me a story. Express yourself. Or just explain why you are giving an award. That works too." - ], - "noRow": [ - "That user has not gotten their first daily yet!", - "That user doesn't seem to like my games. They haven't even claimed their first daily yet!", - "Looks like that user doesn't have a profile. Sad. No rewards for them." - ], - "success": [ //Parameter 1: User id, Parameter 2: Awarded Credits - "<@-id>, (-id) have been awarded -credits credits!", - "<@-param1>, (-param1) has been awarded -param2 credits!", - "Congratulations <@-param1> (-param1)! You've been awarded -param2 credits!" - ] -}; - -exports.calculate = []; - exports.choose = { "lackChoice": [ "There's not a lot of options here, is there?", diff --git a/assets/speech/en-CA/music.js b/assets/speech/en-CA/music.js index 0720a14..e5e0dd1 100644 --- a/assets/speech/en-CA/music.js +++ b/assets/speech/en-CA/music.js @@ -17,7 +17,8 @@ exports.join = { exports.leave = [ "I have left -channel.", "The party is now over in -channel.", - "Thanks for the fun! I've cleaned up and have left -channel." + "Thanks for the fun! I've cleaned up and have left -channel.", + "And that's it for the fun in -channel! We should do that again some other time." ]; exports.nowplaying = { diff --git a/assets/speech/en-CA/system.js b/assets/speech/en-CA/system.js index 0bdc0f3..71d84b3 100644 --- a/assets/speech/en-CA/system.js +++ b/assets/speech/en-CA/system.js @@ -1,7 +1,8 @@ exports.report = { "start": [ "I'm going to be asking a couple of questions so I'll be taking this into your DMs.", - "Time for a questionaire! I'll be asking a couple questions in your DMs." + "Time for a questionaire! I'll be asking a couple questions in your DMs.", + "Time for a trip into your DMs. Don't worry, I'll only be asking a couple of questions." ], "q1": [ "Alright. Let's get to the point. First question: What kind of issue is this?\nPlease answer `issue`, `bug`, `complaint`, or `suggestion`", @@ -25,4 +26,30 @@ exports.report = { "Looks like the time ran out! Take a moment to prepare yourself and then contact me when ready." ] } -}; \ No newline at end of file +}; + +exports.award = { + "noType": [ //User does not provide an award type. + "BAKA! I need a type of an award!", + "But, what kind of award are you giving someone? You never provided me with one!" + ], + "noText": [ //User does not provide a reason for the award. + "Explain yourself on giving the award!", + "Tell me a story. Express yourself. Or just explain why you are giving an award. That works too." + ], + "success": [ + "<@-id>, (-id) has been awarded -credits credits!", + "Congratulations <@-id> (-id)! You've been awarded -credits credits!", + "<@-id> (-id) has been awarded -credits shiny credits!" + ] +}; + +exports.usersearch = [ + "Whatever you are trying to find, it's not typed right or it doesn't exist.", + "Where is the user? I don't know but not any location where I can find it!", + "I couldn't find the user! Give me a better thing to search with, baka!", + "Another non-existant user? Really?", + "... There isn't a user here, baka!", + "You say user, I say doesn't exist. Baka!", + "BAKA! That user doesn't exist! Stop trying to trick me." +]; \ No newline at end of file diff --git a/assets/speech/en-CA/userSearch.js b/assets/speech/en-CA/userSearch.js deleted file mode 100644 index e57a342..0000000 --- a/assets/speech/en-CA/userSearch.js +++ /dev/null @@ -1,48 +0,0 @@ -exports.daily = [ - "You can't give your credits to a bot user, baka!", - "Bots don't have records within our bank to take dailies!", - "What is the bot going to do with all of these credits? It's more useful not to take a daily at this point." -]; - -exports.balance = [ - "Bots can't have any records!", - "Bots aren't allowed to have bank accounts. They could hack them easily at this point.", - "You are lucky I don't have one because then I'd show you the true power of business!" -]; - -exports.rep = [ - "You can't give rep to a bot user. However, as long as you keep interacting with them, I'm sure they will be happy! :smile:", - "Bots can't have rep, baka!", - "A bot's reputation is on how well you like it. It doesn't need points to show it." -]; - -exports.exchange = [ - "You can't give your credits to a bot user!", - "Exchanging to a bot user is just not possible. They are known to do foul things with money from time to time.", - "Nope! No can do. Bots can't have credits." -]; - -exports.award = [ - "Awarding a non-existant user? Wow, I think we've hit a new low here.", - "Fake users don't get awards, baka!", - "Are you trying to funnel some extra credits through a false user again?" -]; - -exports.ecoedit = [ - "Trying to edit some credits on a fake account? Not on my watch, baka!", - "A fake account is a fake account. There is nothing else to do here." -]; - -exports.default = [ - "Whatever you are trying to find, it's not typed right or it doesn't exist.", - "Where is the user? I don't know but not any location where I can find it!", - "I couldn't find the user! Give me a better thing to search with, baka!", - "Another non-existant user? Really?", - "... There isn't a user here, baka!", - "You say user, I say doesn't exist. Baka!" -]; - -exports.noGuild = [ - "B-baka! I can't find a user here with that term!", - "We're not in a guild right now... how do you expect me to find a user like that in here!" -]; \ No newline at end of file diff --git a/commands/Economy/daily.js b/commands/Economy/daily.js index df2be42..2010236 100644 --- a/commands/Economy/daily.js +++ b/commands/Economy/daily.js @@ -18,6 +18,15 @@ module.exports = class extends Command { if (!data && user.id !== msg.author.id) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } if (!data) { + if (this.client.settings.usedDaily.has(msg.author.id)) { //Check if user has recently deleted their own data. + var revokeCheck = this.client.settings.usedDaily.get(msg.author.id); + if ((revokeCheck + 86400000) > Date.now()) { //Revoke was executed less than 24 hours ago. + return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "revoked"])); + } + + this.client.settings.usedDaily.delete(msg.author.id); + } + this.client.dataManager("add", msg.author.id); return msg.channel.send(this.client.speech(msg, ["daily", "self"])); } diff --git a/commands/Economy/revoke.js b/commands/Economy/revoke.js new file mode 100644 index 0000000..cd3d63c --- /dev/null +++ b/commands/Economy/revoke.js @@ -0,0 +1,32 @@ +const { Command } = require("klasa"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "revoke", + enabled: true, + runIn: ["text"], + description: "Delete your user data in Margarine's systems.", + extendedHelp: "By deleting your data, you will not be able to create another profile for another 24 hours since deletion. The data is not recoverable." + }); + } + + 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"])); } + + 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(() => { + 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"])); } + + 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"])); }); + }); + } +}; \ No newline at end of file diff --git a/commands/General/anilist.js b/commands/General/anilist.js index 2368e9d..832ed68 100644 --- a/commands/General/anilist.js +++ b/commands/General/anilist.js @@ -12,21 +12,24 @@ module.exports = class extends Command { cooldown: 60, requiredPermissions: ["ATTACH_FILES"], description: "Fetch a someone's profile on AniList.", - usage: "[set|search|user:usersearch] [username:str]", usageDelim: " ", + usage: "[set|remove|search|user:usersearch] [username:str]", usageDelim: " ", extendedHelp: "Note: The user must set their own account name in Margarine in order to search by a Discord user. For general searching, use the search keyword before the username." }); } async run(msg, [user, username]) { - if (user === "set") { + if (user === "set" || user === "remove") { var data = this.client.dataManager("select", msg.author.id, "users"); if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } var profiles = JSON.parse(data.profiles); - profiles.Anilist = username; + profiles.Anilist = (user === "set") ? username : null; this.client.dataManager("update", [`profiles='${JSON.stringify(profiles)}'`, msg.author.id], "users"); - return msg.channel.send(this.client.speech(msg, ["anilist", "setProfile"])); //Success of setting profile. + + //Action success. Send message and return. + if (user === "set") { return msg.channel.send(this.client.speech(msg, ["anilist", "setProfile"])); } + if (user === "remove") { return msg.channel.send(this.client.speech(msg, ["anilist", "removeProfile"])); } } if (user === null) { return; } //Return for failed usersearch. diff --git a/commands/General/award.js b/commands/General/award.js index 3abe409..64e6db2 100644 --- a/commands/General/award.js +++ b/commands/General/award.js @@ -1,82 +1,36 @@ -exports.run = async (client, msg, [user, type, ...text]) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database(client.database.general); - const settings = client.ownerSetting; - - const embed = new client.methods.Embed() - .setColor(0x04d5fd) - .setTimestamp(); - - if (user !== undefined && msg.author.id === client.owner.id) { - if (!type) { return msg.reply(client.speech(msg, ["award", "noType"])); } - if (!text) { return msg.reply(client.speech(msg, ["award", "noText"])); } - - var data = await client.funcs.userSearch(client, msg, user, ["bot"]); - if (data === false) { return; } - - db.get(`SELECT credits FROM scores WHERE userId = "${data.id}"`, [], (err, row) => { - if (err) { return console.log(err); } - if (!row) { return msg.reply(client.speech(msg, ["award", "noRow"])); } - - type = type.toLowerCase(); - - const awards = { - suggest: ["suggest", settings.awards.suggest], - bug: ["bug", settings.awards.bug], - minor: ["minor", settings.awards.minor], - major: ["major", settings.awards.major] - }; - - db.get(`SELECT ${awards[type][0]} FROM awards WHERE userId = "Overall"`, [], (err, row) => { - db.run(`UPDATE awards SET ${awards[type][0]} = ${Object.values(row)[0] + 1} WHERE userId = "Overall"`); - }); - - db.get(`SELECT ${awards[type][0]} FROM awards WHERE userId = "${data.id}"`, [], (err, row) => { - db.run(`UPDATE awards SET ${awards[type][0]} = ${Object.values(row)[0] + 1} WHERE userId = "${data.id}"`); - }); - - embed.setTitle(":tada: Award Notification! :tada:") - .addField(`To ${data.user.tag} for the reason of ${text.join(" ")}`, `User has been awarded ${awards[type][1]} credits!`) - .setFooter("Awarded to: " + data.user.tag + " (" + data.id + ") on:", data.user.displayAvatarURL()); - - msg.reply(client.speech(msg, ["award", "success"]).replace(/-id/g, data.id).replace("-credit", awards[type][1])); - - client.channels.get(settings.channels.award).send({embed}); - db.run(`UPDATE scores SET credits = ${row.credits + awards[type][1]} WHERE userId = "${data.id}"`); - }); - } else { - db.get("SELECT * FROM awards WHERE userID = 'Overall'", [], (err, row) => { - if (err) { return console.log(err); } - let award = settings.awards; - var sum = row.suggest + row.bugs + row.minor + row.major; - var reward = (row.suggest * award.suggest) + (row.bugs * award.bug) + (row.minor * award.minor) + (row.major * award.major); - - embed.setTitle(client.user.username + "'s Award System") - .setDescription(sum + " awards given equaling " + reward + " credits") - .setFooter(msg.guild.name, msg.guild.iconURL()) - .addField("Description:", "For those who have signed up with the daily command, there is a way in which users can earn more credits. By suggesting or bug and issue finding and reporting them with the report command, users can earn an amount of credits once the item is added or fixed.") - .addField("Improvements (" + award.suggest + "):", row.suggest, true) - .addField("Bugs (" + award.bug + "):", row.bugs, true) - .addField("Minor Issues (" + award.minor + "):", row.minor, true) - .addField("Major Issues (" + award.major + "):", row.major, true); - msg.channel.send({embed}); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "award", + enabled: true, + runIn: ["text"], + requiredPermissions: ["EMBED_LINKS"], + description: "Information on the awards given out." }); } - db.close(); -}; -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: [], - requiredFuncs: ["userSearch"] -}; - -exports.help = { - name: "award", - description: "Information on the awards given out.", - usage: "[user:str] [suggest|bug|minor|major] [text:str][...]", - usageDelim: " ", humanUse: " " + async run(msg) { + var statData = this.client.dataManager("select", "Overall", "awards"); + var awardAmt = this.client.ownerSetting.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); + + const embed = new MessageEmbed() + .setColor(0x04d5fd) + .setTimestamp() + .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(`Suggestions (${awardAmt.suggest}):`, statData.suggest, true) + .addField(`Bugs (${awardAmt.bug}):`, statData.bug, true) + .addField(`Minor Issues (${awardAmt.minor}):`, statData.minor, true) + .addField(`Major Issues (${awardAmt.major}):`, statData.major, true); + + msg.channel.send({embed}); + } }; \ No newline at end of file diff --git a/commands/General/emoji.js b/commands/General/emoji.js index 5000098..ab8319e 100644 --- a/commands/General/emoji.js +++ b/commands/General/emoji.js @@ -14,15 +14,14 @@ module.exports = class extends Command { name: "emoji", enabled: true, runIn: ["text"], - cooldown: 0, aliases: ["emote", "see", "react"], requiredPermissions: ["ATTACH_FILES", "ADD_REACTIONS"], description: "Bring in your pool of emotes from other servers! Either use the big image or use the alias of react and add a message ID to react to a message instead!", - usage: "[Name:str] [messageID:str]", usageDelim: " " + usage: "[react|Name:str] [messageID:str]", usageDelim: " " }); } - async run(msg, [Name, messageID]) { + async run(msg, [Name, ID]) { const prefix = msg.guild.settings.prefix; if (msg.channel.permissionsFor(this.client.user).has("MANAGE_MESSAGES")) { msg.delete(); } @@ -30,8 +29,7 @@ module.exports = class extends Command { if (msg.content.slice(prefix.length).startsWith("react") && (!ID)) { return errMsg(msg, "noID"); } if (Name.startsWith("<")) { Name = Name.slice(2, -20); } - let emotes = Array.from(this.client.emojis); - let emoji = emotes.filter((element) => { + let emoji = Array.from(this.client.emojis).filter((element) => { if (element[1].name === Name) { return element; } }); diff --git a/commands/General/mal.js b/commands/General/mal.js index 0a353a1..c595c8f 100644 --- a/commands/General/mal.js +++ b/commands/General/mal.js @@ -12,21 +12,23 @@ module.exports = class extends Command { cooldown: 60, requiredPermissions: ["ATTACH_FILES"], description: "Fetch a user's profile on MyAnimeList", - usage: "[set|search|user:usersearch] [username:str]", usageDelim: " ", + usage: "[set|remove|search|user:usersearch] [username:str]", usageDelim: " ", extendedHelp: "Note: The user must set their own account name in Margarine in order to search by a Discord user. For general searching, use the search keyword before the username." }); } async run(msg, [user, username]) { - if (user === "set") { + if (user === "set" || user === "remove") { var data = this.client.dataManager("select", msg.author.id, "users"); if (!data) { return msg.channel.send(this.client.speech(msg, ["func-dataCheck", "noAccount"])); } var profiles = JSON.parse(data.profiles); - profiles.MAL = username; + profiles.MAL = (user === "set") ? username : null; this.client.dataManager("update", [`profiles='${JSON.stringify(profiles)}'`, msg.author.id], "users"); - return msg.channel.send(this.client.speech(msg, ["mal", "setProfile"])); //Success of setting profile. + + if (user === "set") { return msg.channel.send(this.client.speech(msg, ["mal", "setProfile"])); } + if (user === "remove") { return msg.channel.send(this.client.speech(msg, ["mal", "removeProfile"])); } } if (user === null) { return; } //Return for failed usersearch. diff --git a/commands/General/manga.js b/commands/General/manga.js index f0943af..3c76b23 100644 --- a/commands/General/manga.js +++ b/commands/General/manga.js @@ -1,46 +1,53 @@ -const AniListNode = require("anilist-node"); -const anilist = new AniListNode(); +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); +const AnilistNode = require("anilist-node"); +const anilist = new AnilistNode(); -exports.run = async (client, msg, [term]) => { - if (!term) { return msg.channel.send(client.speech(msg, ["manga", "noSearch"])); } - var data = await anilist.search("manga", term, 1, 3); - data = await anilist.media.manga(data.media[0].id); +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "manga", + enabled: true, + runIn: ["text"], + cooldown: 30, + requiredPermissions: ["ATTACH_FILES"], + description: "Search for manga on AniList", + usage: "[term:str]", + extendedHelp: "There is a 60 second cooldown for each search to not spam the site." + }); + } + + async run(msg, [term]) { + if (!term) { return msg.channel.send(this.client.speech(msg, ["manga", "noSearch"])); } + + var data = await anilist.search("manga", term, 1, 3); + if (!data || !data.media) { return msg.channel.send(this.client.speech(msg, ["manga", "searchErr"])); } + data = await anilist.media.manga(data.media[0].id); + + if (!msg.channel.nsfw && data.isAdult) { return this.client.speech(msg, ["manga, nsfw"]); } + + var title = data.title.romaji; + if (data.title.english) { title = `${title} | ${data.title.english}`; } + + var chapCount = (data.status === "RELEASING") ? "" : `**Chapters:** ${data.chapters} - **Volumes:** ${data.volumes}\n`; + var desc = `[Anilist](${data.siteUrl}) | [MyAnimeList](https://myanimelist.net/anime/${data.idMal})\n + **Format:** ${data.format.charAt(0) + data.format.substring(1).toLowerCase()}\n**Released:** ${data.startDate.year}\n${chapCount}`; + + if (data.status === "NOT_YET_RELEASED") { + desc = `${desc}**Status:** Not yet released\n\n${data.description.replace(/
/g, "").replace(/<(i|\/i)>/g, "").replace(/—/g, "-")}`; + } else { + desc = `${desc}**Status:** ${data.status.charAt(0) + data.status.substring(1).toLowerCase()} + **Average Score:** ${data.meanScore} out of 100\n\n${data.description.replace(/
/g, "").replace(/<(i|\/i)>/g, "").replace(/—/g, "-")}`; + } + + const embed = new MessageEmbed() + .setTitle(title) + .setColor(0x2E51A2) + .setTimestamp() + .setThumbnail(data.coverImage.medium) + .setFooter("Data pulled from AniList") + .setDescription(desc); - if (!msg.channel.nsfw && data.isAdult) { return msg.channel.send(client.speech(msg, ["manga, nsfw"])); } - - title = data.title.romaji + " "; - - if (data.title.english) { title = title + "| " + data.title.english; } - - chapCount = (data.status === "RELEASING") ? "" : `**Chapters:** ${data.chapters} - **Volumes:** ${data.volumes}\n`; - - const embed = new client.methods.Embed() - .setTitle(title) - .setColor(0x2E51A2) - .setTimestamp() - .setThumbnail(data.coverImage.medium) - .setFooter("Data pulled from AniList"); - - embed.setDescription(`[Anilist](${data.siteUrl}) | [MyAnimeList](https://myanimelist.net/anime/${data.idMal})\n\n**Format:** ` - + data.format.charAt(0) + data.format.substring(1).toLowerCase() + `\n**Released:** ${data.startDate.year}\n` + chapCount - + "**Status:** " + data.status.charAt(0) + data.status.substring(1).toLowerCase() + "\n**Average Score:** " + data.meanScore - + " out of 100\n\n" + data.description.replace(/
/g, "").replace(/—/g, "-")); - - msg.channel.send({embed}); -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 0, - botPerms: ["ATTACH_FILES"], - cooldown: 30 -}; - -exports.help = { - name: "manga", - description: "Search for manga on AniList.", - usage: "[term:str]", humanUse: "(Search term)", - extendedHelp: "There is a 30 second cooldown for searches to not spam the site." + msg.channel.send({embed}); + } }; \ No newline at end of file diff --git a/commands/Music/queueadd.js b/commands/Music/queueadd.js index a06c1bc..1e0a81b 100644 --- a/commands/Music/queueadd.js +++ b/commands/Music/queueadd.js @@ -33,7 +33,7 @@ module.exports = class extends Command { for (var x = 0; x < id.length; x++) { try { - var info = await getInfoAsync("https://youtu.be/" + id[x]); + var info = await getInfoAsync(`https://youtu.be/${id[x]}`); handler.queue.push({ url: `https://youtu.be/${id[x]}`, diff --git a/commands/Owner/ecoedit.js b/commands/Owner/ecoedit.js deleted file mode 100644 index 3a9b735..0000000 --- a/commands/Owner/ecoedit.js +++ /dev/null @@ -1,34 +0,0 @@ -exports.run = async (client, message, [member, option, amount]) => { - const sqlite3 = require("sqlite3").verbose(); - let db = new sqlite3.Database("./assets/data/score.sqlite"); - - var data = await client.funcs.userSearch(message, {user: [member], tags: ["bot"], name: this.help.name}); - if (data.valid === false) { return; } - - db.get(`SELECT * FROM scores WHERE userId = "${data.user[0].id}"`, [], (err, row) => { - if (err) { return console.log(err); } - if (!row) { return message.reply("That user does not have any data within the database."); } - else { - db.run(`UPDATE scores SET ${option} = ${amount} WHERE userId ="${data.user[0].id}"`); - return message.reply(`Table updated. I have updated the table so that ${user.prefered}'s ${option} has been set to ${amount}!`); - } - }); - - if (user.bot === true) { return message.reply("You can't change or add data about a bot user!"); } -}; - -exports.conf = { - enabled: true, - runIn: ["text"], - aliases: [], - permLevel: 10, - botPerms: [], - requiredFuncs: ["userSearch"], -}; - -exports.help = { - name: "ecoedit", - description: "Edits a user's economy values.", - usage: "[member:str] [option:str] [amount:int]", - usageDelim: " ", -}; \ No newline at end of file diff --git a/commands/Owner/giveAward.js b/commands/Owner/giveAward.js new file mode 100644 index 0000000..ea9b887 --- /dev/null +++ b/commands/Owner/giveAward.js @@ -0,0 +1,48 @@ +const { Command } = require("klasa"); +const { MessageEmbed } = require("discord.js"); + +module.exports = class extends Command { + constructor(...args) { + super(...args, { + name: "giveAward", + enabled: true, + runIn: ["text"], + permissionLevel: 9, + requiredPermissions: ["EMBED_LINKS"], + description: "Award a user based on their efforts", + usage: " [suggest|bug|minor|major] [text:str][...]", + usageDelim: " " + }); + + this.humanUse = " "; + } + + async run(msg, [user, type, ...text]) { + if (user === null) { return; } + if (!type) { return msg.channel.send(this.client.speech(msg, ["func-system", "award", "noType"])); } + if (!text) { return msg.channel.send(this.client.speech(msg, ["func-system", "award", "noText"])); } + + 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"])); } + + type = type.toLowerCase(); + const awards = this.client.ownerSetting.get("awards"); + + this.client.dataManager("update", [`${type}=${overallData[type] + 1}`, "Overall"], "awards"); + this.client.dataManager("update", [`${type}=${userData[type] + 1}`, user.id], "awards"); + + var userAccData = this.client.dataManager("select", user.id, "users"); + this.client.dataManager("update", [`credits=${userAccData.credits + awards[type]}`, user.id], "users"); + + const embed = new MessageEmbed() + .setColor(0x04d5fd) + .setTimestamp() + .setTitle("šŸŽ‰ Award Notification! šŸŽ‰") + .addField(`To ${user.tag} for the reason of ${text.join(" ")}`, `User has been awarded ${awards[type]} credits!`) + .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}); + } +}; \ No newline at end of file diff --git a/events/ready.js b/events/ready.js index 6f86253..06bfe89 100644 --- a/events/ready.js +++ b/events/ready.js @@ -1,4 +1,5 @@ const { Event } = require("klasa"); +const { Collection } = require("discord.js"); module.exports = class extends Event { constructor(...args) { @@ -10,5 +11,6 @@ module.exports = class extends Event { async run() { this.client.util.presenceHelper(this.client, "-start"); //Initialize presence + this.client.settings.usedDaily = new Collection(); //A collection to store a tuple with a userID and a timestamp. } }; \ No newline at end of file diff --git a/languages/en-CA.js b/languages/en-CA.js new file mode 100644 index 0000000..0f93dbe --- /dev/null +++ b/languages/en-CA.js @@ -0,0 +1,15 @@ +const { Language } = require('klasa'); + +module.exports = class extends Language { + constructor(...args) { + super(...args, { + name: 'en-CA', + enabled: true + }); + + this.language = { + DEFAULT: (key) => `${key} has not been localized for en-CA yet.`, + DEFAULT_LANGUAGE: 'Default Language' + }; + } +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7a0062a..077c563 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,9 +34,9 @@ } }, "anilist-node": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/anilist-node/-/anilist-node-1.2.2.tgz", - "integrity": "sha512-r7LZfcoyX/kzaGk0H0p2MqfKplabsjy7u53WXVuFrPTrM92L5JcpsQkmXsGPq9hzvCG0WV2Wz3pmdFdw28VxTw==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/anilist-node/-/anilist-node-1.2.3.tgz", + "integrity": "sha512-56J0VqL1hJyf4G0yNEt4OjCnyO/TbYUEwGu3b8cN838tCFR6PAza0kEyUGhdjFeOoNQPiXwAfeyWsZf9+QjCvQ==", "requires": { "node-fetch": "^2.6.0" } @@ -177,8 +177,8 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "discord.js": { - "version": "github:hydrabolt/discord.js#45b89710008d207da22000dcb633c0c0236db17e", - "from": "github:hydrabolt/discord.js", + "version": "github:discordjs/discord.js#1b1289b35e2f8cd21341351549e6ac52fd08cb34", + "from": "github:discordjs/discord.js", "requires": { "@discordjs/collection": "^0.1.1", "abort-controller": "^3.0.0", @@ -449,7 +449,7 @@ }, "klasa": { "version": "github:dirigeants/klasa#0e9174cab0df7d28f3a7b8ca78b6344fef2611c9", - "from": "github:dirigeants/klasa", + "from": "github:dirigeants/klasa#master", "requires": { "fs-nextra": "^0.4.5" } @@ -465,9 +465,9 @@ "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" }, "m3u8stream": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.6.3.tgz", - "integrity": "sha512-HNUco8ef9kOvMRH7tYxJqbk9IuRA+AuZG8a/dQwqI+jfuEs1/DUaPbfTIlUDB4JmTZNkTOZHvZI5TvnQGR8nKA==", + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.6.4.tgz", + "integrity": "sha512-9WLF1VAtbVij03HWJKbVZ8L0orsoZiP53UljR5EwaDrozQFMsTGRDPe3PbzWV73He8a+j5H/hWZNoI2VkUSsiw==", "requires": { "miniget": "^1.6.1", "sax": "^1.2.4" @@ -554,6 +554,11 @@ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, + "opusscript": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/opusscript/-/opusscript-0.0.7.tgz", + "integrity": "sha512-DcBadTdYTUuH9zQtepsLjQn4Ll6rs3dmeFvN+SD0ThPnxRBRm/WC1zXWPg+wgAJimB784gdZvUMA57gDP7FdVg==" + }, "parse5": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", @@ -811,9 +816,9 @@ } }, "ytdl-core": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-1.0.3.tgz", - "integrity": "sha512-sBOVokjrAigKTEn248MJ+JpS5ifay/vBzYGMDeZhG61xmgthev6yHXBgEgm+M8ySDQXXVjOTmUtY3GHbX988KA==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-1.0.7.tgz", + "integrity": "sha512-gECPN5g5JnSy8hIq11xHIGe1T/Xzy0mWxQin3zhlJ3nG/YjPcEVEejrdd2XmA4Vv2Zw3+b1ZyDjmt37XfZri6A==", "requires": { "html-entities": "^1.1.3", "m3u8stream": "^0.6.3", diff --git a/package.json b/package.json index 5882421..450e476 100644 --- a/package.json +++ b/package.json @@ -4,21 +4,22 @@ "description": "Javascript bot using the Klasa framework", "main": "index.js", "dependencies": { - "anilist-node": "^1.2.2", + "anilist-node": "^1.2.3", "better-sqlite3": "^5.4.3", "cheerio": "^1.0.0-rc.3", - "discord.js": "github:hydrabolt/discord.js", + "discord.js": "github:discordjs/discord.js", "ffmpeg": "0.0.4", - "klasa": "github:dirigeants/klasa", + "klasa": "github:dirigeants/klasa#master", "moment": "^2.24.0", "moment-duration-format": "^2.3.2", "ms": "^2.1.2", "node-fetch": "^2.6.0", + "opusscript": "0.0.7", "querystring": "^0.2.0", "request": "^2.88.0", "snekfetch": "^4.0.4", "youtube-playlist": "^1.0.2", - "ytdl-core": "^1.0.0" + "ytdl-core": "^1.0.7" }, "devDependencies": {}, "repository": { @@ -26,8 +27,7 @@ "url": "git+https://github.com/butterstroke/MargarineBot" }, "scripts": { - "start": "node index.js", - "envCheck": "node ./utilities/envCheck.js" + "start": "node index.js" }, "author": { "name": "Frederick Katsura", diff --git a/utilities/dataManager.js b/utilities/dataManager.js index a1543b7..c96f55f 100644 --- a/utilities/dataManager.js +++ b/utilities/dataManager.js @@ -4,7 +4,7 @@ const dbDir = require("../assets/settings.json")["database"]; /** * Manages the SQLite database * @param { string } args - An action for the database. Either init, add, select, update, or delete - * @param { string[] } values - An array of values for the add, select, and update actions. + * @param { string|string[] } values - An array of values for the add, select, and update actions. * Select needs one value, while both add and update need two. * @param { string } table - Target table in the database. * @returns {Object} If action was select. Returns null for all other options. diff --git a/utilities/presenceHelper.js b/utilities/presenceHelper.js index df12f7e..c1c0151 100644 --- a/utilities/presenceHelper.js +++ b/utilities/presenceHelper.js @@ -6,7 +6,7 @@ function Presence(client, type, name, status) { name = (name !== "-null") ? `${client.ownerSetting.get("globalPrefix")}help | ${name}` : null; client.user.setPresence({ activity: { name, type }, status }); -}; +} /** * Sets the presence for Margarine and starts a 15 minute interval for automatic change diff --git a/utilities/speechHelper.js b/utilities/speechHelper.js index 971e109..0e56831 100644 --- a/utilities/speechHelper.js +++ b/utilities/speechHelper.js @@ -17,14 +17,19 @@ module.exports = function speech(msg, keys, replace=[]) { category = category[category.length - 1].toLowerCase(); } - var PATH = `${msg.client.userBaseDirectory}/assets/speech/${msg.guild.settings.langSpeech}/${category}.js`; + var baseLocation = `${msg.client.userBaseDirectory}/assets/speech/`; + var speechLocation = existsSync(baseLocation + msg.guild.settings.langSpeech) ? `${baseLocation}${msg.guild.settings.langSpeech}` : `${baseLocation}${msg.client.gateways.guilds.schema.get("langSpeech").default}`; - if (existsSync(PATH) === false) { - throw new Error(`Localization file is missing.\nLanguage: ${msg.guild.settings.langSpeech}\nCategory: ${category}\nCommand: ${name}\n${PATH}`); + var PATH = `${speechLocation}/${category}.js`; + + if (!existsSync(baseLocation + msg.guild.settings.langSpeech)) { + msg.channel.send("Whoops! Your langSpeech settings on here don't exist in my records. I've defaulted to the default as a backup."); + + console.error(`Localization file is missing. Defaulted to the original language.\nLanguage: ${msg.guild.settings.langSpeech}\nCategory: ${category}\nCommand: ${name}\n${PATH}\n\n`); } var t = require(PATH); var n; - if (name.startsWith("func-") === false) { t = t[name]; n = 1; } + if (!name.startsWith("func-")) { t = t[name]; n = 1; } else { t = t[keys[1]]; n = 2; } for (var x = n; x < keys.length; x++) { t = t[keys[x]]; } var text = t[Math.floor(Math.random() * t.length)]; From bfdcd8a77af6ba798bfc923f051f5226b07675bf Mon Sep 17 00:00:00 2001 From: Frederick Katsura Date: Thu, 30 Jan 2020 14:52:35 -0400 Subject: [PATCH 38/38] Edited README file --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7bc08cc..e493a8b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# MargarineBot - Version: Release 1.0 (Klasa Rewrite - Beta) +# MargarineBot - Version: Release 1.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 @@ -20,11 +20,10 @@ Created through part-desire, part-what can I do in Discord, part-I'm going to le - Server/User/role info commands - Economy system using a SQLite database -Invite me! -Not available at the current moment as the bot is in development. + Invite me to your server! Contact For issues, please use the issue tracker on this repository. -For any thing else, either contact me by email katsurinstudios@protonmail.ch or through Discord at Butterstroke#7150. +For any thing else, either contact me by email katsurinstudios@protonmail.ch or in my [Discord server](https://discord.gg/TJJ6KGd) in the #margarine-bot channel.