Added command usage count to help, remove nonexistent commands from database, add build method to package.json

This commit is contained in:
TheEssem 2020-07-29 18:06:34 -05:00
parent f9c8d6b26d
commit 70c4ff298f
6 changed files with 21 additions and 9 deletions

View file

@ -10,23 +10,30 @@ exports.run = async (message, args) => {
const commands = collections.commands; const commands = collections.commands;
const aliases = collections.aliases; const aliases = collections.aliases;
if (args.length !== 0 && (commands.has(args[0].toLowerCase()) || aliases.has(args[0].toLowerCase()))) { 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 = { const embed = {
"embed": { "embed": {
"author": { "author": {
"name": "esmBot Help", "name": "esmBot Help",
"icon_url": client.user.avatarURL "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", "url": "https://projectlounge.pw/esmBot/help.html",
"description": info.description, "description": info.description,
"color": 16711680, "color": 16711680,
"fields": [{ "fields": [{
"name": "Aliases", "name": "Aliases",
"value": info.aliases ? info.aliases.join(", ") : "None" "value": info.aliases ? info.aliases.join(", ") : "None"
}, {
"name": "Times Used",
"value": counts.get(command),
"inline": true
}, { }, {
"name": "Parameters", "name": "Parameters",
"value": info.params ? info.params : "None" "value": info.params ? info.params : "None",
"inline": true
}] }]
} }
}; };

View file

@ -70,13 +70,20 @@ module.exports = async () => {
}); });
await newGlobal.save(); await newGlobal.save();
} else { } else {
const exists = [];
for (const command of collections.commands.keys()) { for (const command of collections.commands.keys()) {
if (!global.cmdCounts.has(command)) { if (!global.cmdCounts.has(command)) {
global.cmdCounts.set(command, 0); global.cmdCounts.set(command, 0);
}
exists.push(command);
}
for (const command of global.cmdCounts.keys()) {
if (!exists.includes(command)) {
global.cmdCounts.set(command, undefined);
}
}
await global.save(); await global.save();
} }
}
}
// generate docs // generate docs
if (helpGenerator && first) await helpGenerator(process.env.OUTPUT); if (helpGenerator && first) await helpGenerator(process.env.OUTPUT);

View file

@ -20,7 +20,6 @@ class CaptionWorker : public Napi::AsyncWorker {
readImages(&frames, in_path); readImages(&frames, in_path);
size_t width = frames.front().baseColumns(); size_t width = frames.front().baseColumns();
size_t height = frames.front().baseRows();
string query(to_string(width - ((width / 25) * 2)) + "x"); string query(to_string(width - ((width / 25) * 2)) + "x");
Image caption_image(Geometry(query), Color("white")); Image caption_image(Geometry(query), Color("white"));
caption_image.fillColor("black"); caption_image.fillColor("black");

View file

@ -20,7 +20,6 @@ class CaptionTwoWorker : public Napi::AsyncWorker {
readImages(&frames, in_path); readImages(&frames, in_path);
size_t width = frames.front().baseColumns(); size_t width = frames.front().baseColumns();
size_t height = frames.front().baseRows();
string query(to_string(width - ((width / 25) * 2)) + "x"); string query(to_string(width - ((width / 25) * 2)) + "x");
Image caption_image(Geometry(query), Color("white")); Image caption_image(Geometry(query), Color("white"));
caption_image.fillColor("black"); caption_image.fillColor("black");
@ -31,7 +30,6 @@ class CaptionTwoWorker : public Napi::AsyncWorker {
coalesceImages(&coalesced, frames.begin(), frames.end()); coalesceImages(&coalesced, frames.begin(), frames.end());
int iterator = 0;
for (Image &image : coalesced) { for (Image &image : coalesced) {
Image appended; Image appended;
list<Image> images; list<Image> images;

View file

@ -52,7 +52,7 @@ class SpinWorker : public Napi::AsyncWorker {
private: private:
string in_path, type; string in_path, type;
int delay, wordlength, n; int delay;
Blob blob; Blob blob;
}; };

View file

@ -4,9 +4,10 @@
"description": "A Discord bot with miscellaneous features", "description": "A Discord bot with miscellaneous features",
"main": "app.js", "main": "app.js",
"engines": { "engines": {
"node": ">=8" "node": ">=12"
}, },
"scripts": { "scripts": {
"build": "node-gyp configure build",
"docker:build": "docker build -t headless-chrome-alpine --no-cache ./utils/screenshot", "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-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" "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"