From 70c4ff298fff76190adf725e050e679633cee068 Mon Sep 17 00:00:00 2001 From: TheEssem Date: Wed, 29 Jul 2020 18:06:34 -0500 Subject: [PATCH] Added command usage count to help, remove nonexistent commands from database, add build method to package.json --- commands/help.js | 13 ++++++++++--- events/ready.js | 9 ++++++++- natives/caption.cc | 1 - natives/caption2.cc | 2 -- natives/spin.cc | 2 +- package.json | 3 ++- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/commands/help.js b/commands/help.js index 0089617..60c0b41 100644 --- a/commands/help.js +++ b/commands/help.js @@ -10,23 +10,30 @@ exports.run = async (message, args) => { const commands = collections.commands; const aliases = collections.aliases; if (args.length !== 0 && (commands.has(args[0].toLowerCase()) || aliases.has(args[0].toLowerCase()))) { - const info = aliases.has(args[0].toLowerCase()) ? collections.info.get(collections.aliases.get(args[0].toLowerCase())) : collections.info.get(args[0].toLowerCase()); + const command = aliases.has(args[0].toLowerCase()) ? collections.aliases.get(args[0].toLowerCase()) : args[0].toLowerCase(); + const info = collections.info.get(command); + const counts = (await database.global.findOne({})).cmdCounts; const embed = { "embed": { "author": { "name": "esmBot Help", "icon_url": client.user.avatarURL }, - "title": `${guild.prefix}${aliases.has(args[0].toLowerCase()) ? collections.aliases.get(args[0].toLowerCase()) : args[0].toLowerCase()}`, + "title": `${guild.prefix}${command}`, "url": "https://projectlounge.pw/esmBot/help.html", "description": info.description, "color": 16711680, "fields": [{ "name": "Aliases", "value": info.aliases ? info.aliases.join(", ") : "None" + }, { + "name": "Times Used", + "value": counts.get(command), + "inline": true }, { "name": "Parameters", - "value": info.params ? info.params : "None" + "value": info.params ? info.params : "None", + "inline": true }] } }; diff --git a/events/ready.js b/events/ready.js index f49eca7..f9836f6 100644 --- a/events/ready.js +++ b/events/ready.js @@ -70,12 +70,19 @@ module.exports = async () => { }); await newGlobal.save(); } else { + const exists = []; for (const command of collections.commands.keys()) { if (!global.cmdCounts.has(command)) { global.cmdCounts.set(command, 0); - await global.save(); + } + exists.push(command); + } + for (const command of global.cmdCounts.keys()) { + if (!exists.includes(command)) { + global.cmdCounts.set(command, undefined); } } + await global.save(); } // generate docs diff --git a/natives/caption.cc b/natives/caption.cc index 6cffa4c..65c41fb 100644 --- a/natives/caption.cc +++ b/natives/caption.cc @@ -20,7 +20,6 @@ class CaptionWorker : public Napi::AsyncWorker { readImages(&frames, in_path); size_t width = frames.front().baseColumns(); - size_t height = frames.front().baseRows(); string query(to_string(width - ((width / 25) * 2)) + "x"); Image caption_image(Geometry(query), Color("white")); caption_image.fillColor("black"); diff --git a/natives/caption2.cc b/natives/caption2.cc index cbf79da..d96e052 100644 --- a/natives/caption2.cc +++ b/natives/caption2.cc @@ -20,7 +20,6 @@ class CaptionTwoWorker : public Napi::AsyncWorker { readImages(&frames, in_path); size_t width = frames.front().baseColumns(); - size_t height = frames.front().baseRows(); string query(to_string(width - ((width / 25) * 2)) + "x"); Image caption_image(Geometry(query), Color("white")); caption_image.fillColor("black"); @@ -31,7 +30,6 @@ class CaptionTwoWorker : public Napi::AsyncWorker { coalesceImages(&coalesced, frames.begin(), frames.end()); - int iterator = 0; for (Image &image : coalesced) { Image appended; list images; diff --git a/natives/spin.cc b/natives/spin.cc index f52853e..3642c8c 100644 --- a/natives/spin.cc +++ b/natives/spin.cc @@ -52,7 +52,7 @@ class SpinWorker : public Napi::AsyncWorker { private: string in_path, type; - int delay, wordlength, n; + int delay; Blob blob; }; diff --git a/package.json b/package.json index 2a4e659..386c12f 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,10 @@ "description": "A Discord bot with miscellaneous features", "main": "app.js", "engines": { - "node": ">=8" + "node": ">=12" }, "scripts": { + "build": "node-gyp configure build", "docker:build": "docker build -t headless-chrome-alpine --no-cache ./utils/screenshot", "docker:run-ss": "docker run --rm --shm-size=128m headless-chrome-alpine", "docker:run-lava": "docker run --rm --network host -v \"$(pwd)\"/application.yml:/opt/Lavalink/application.yml -v \"$(pwd)\"/assets:/opt/Lavalink/assets fredboat/lavalink:dev"