Added sticker, reimplemented reload, removed user count from stats

This commit is contained in:
Essem 2021-08-23 00:37:09 -05:00
parent 7009ff339f
commit f0e19d6ad3
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
7 changed files with 50 additions and 74 deletions

View file

@ -4,7 +4,7 @@ class ReloadCommand extends Command {
// quite possibly one of the hackiest commands in the bot // quite possibly one of the hackiest commands in the bot
run() { run() {
return new Promise((resolve) => { return new Promise((resolve) => {
/*if (this.message.author.id !== process.env.OWNER) resolve("Only the bot owner can reload commands!"); if (this.message.author.id !== process.env.OWNER) resolve("Only the bot owner can reload commands!");
if (this.args.length === 0) resolve("You need to provide a command to reload!"); if (this.args.length === 0) resolve("You need to provide a command to reload!");
this.ipc.broadcast("reload", this.args[0]); this.ipc.broadcast("reload", this.args[0]);
this.ipc.register("reloadSuccess", () => { this.ipc.register("reloadSuccess", () => {
@ -16,8 +16,7 @@ class ReloadCommand extends Command {
this.ipc.unregister("reloadSuccess"); this.ipc.unregister("reloadSuccess");
this.ipc.unregister("reloadFail"); this.ipc.unregister("reloadFail");
resolve(message); resolve(message);
});*/ });
resolve("This command is currently disabled until the ECMAScript module format supports unloading imported files.");
}); });
} }

View file

@ -42,7 +42,8 @@ class StatsCommand extends Command {
}, },
{ {
"name": "Host", "name": "Host",
"value": `${os.type()} ${os.release()} (${os.arch()})` "value": `${os.type()} ${os.release()} (${os.arch()})`,
"inline": true
}, },
{ {
"name": "Library", "name": "Library",
@ -68,11 +69,6 @@ class StatsCommand extends Command {
"name": "Servers", "name": "Servers",
"value": stats && stats.guilds ? stats.guilds : `${this.client.guilds.size} (for this cluster only)`, "value": stats && stats.guilds ? stats.guilds : `${this.client.guilds.size} (for this cluster only)`,
"inline": true "inline": true
},
{
"name": "Users (approximation)",
"value": stats && stats.users ? stats.users : `${this.client.users.size} (for this cluster only)`,
"inline": true
} }
] ]
} }

View file

@ -0,0 +1,31 @@
import Command from "../../classes/command.js";
class StickerCommand extends Command {
async run() {
if (!this.message.stickerItems) return "You need to provide a sticker!";
const sticker = this.message.stickerItems[0];
if (sticker.format_type === 1) { // PNG
return `https://cdn.discordapp.com/stickers/${sticker.id}.png`;
} else if (sticker.format_type === 2) { // APNG
return {
embed: {
color: 16711680,
description: `[This sticker is an APNG; however, since Discord doesn't allow displaying APNGs outside of stickers, you'll have to save it or open it in your browser to view it.](https://cdn.discordapp.com/stickers/${sticker.id}.png)`,
image: {
url: `https://cdn.discordapp.com/stickers/${sticker.id}.png`
}
}
};
} else if (sticker.format_type === 3) { // Lottie
return `I can't display this sticker because it uses the Lottie animation format; however, I can give you the raw JSON link to it: https://cdn.discordapp.com/stickers/${sticker.id}.json`;
} else {
return "I don't recognize that sticker format!";
}
}
static description = "Gets a raw sticker image";
static aliases = ["s", "stick"];
static arguments = ["[sticker]"];
}
export default StickerCommand;

17
package-lock.json generated
View file

@ -13,7 +13,7 @@
"cowsay2": "^2.0.4", "cowsay2": "^2.0.4",
"dotenv": "^9.0.2", "dotenv": "^9.0.2",
"emoji-regex": "^9.2.2", "emoji-regex": "^9.2.2",
"eris": "^0.15.1", "eris": "github:abalabahaha/eris#dev",
"eris-fleet": "github:esmBot/eris-fleet", "eris-fleet": "github:esmBot/eris-fleet",
"file-type": "^16.1.0", "file-type": "^16.1.0",
"format-duration": "^1.4.0", "format-duration": "^1.4.0",
@ -1232,11 +1232,11 @@
} }
}, },
"node_modules/eris": { "node_modules/eris": {
"version": "0.15.1", "version": "0.16.0-dev",
"resolved": "https://registry.npmjs.org/eris/-/eris-0.15.1.tgz", "resolved": "git+ssh://git@github.com/abalabahaha/eris.git#5246da9589bdc22d610d960202d1f84dc865c3a2",
"integrity": "sha512-IQ3BPW6OjgFoqjdh+irPOa1jFlkotk+WNu2GQQ7QAQfbzQEPZgn+F+hpOxfMUXPHOZMX4sPKLkVDkMHAssBYhw==", "license": "MIT",
"dependencies": { "dependencies": {
"ws": "^7.2.1" "ws": "^7.4.6"
}, },
"engines": { "engines": {
"node": ">=10.4.0" "node": ">=10.4.0"
@ -4990,13 +4990,12 @@
} }
}, },
"eris": { "eris": {
"version": "0.15.1", "version": "git+ssh://git@github.com/abalabahaha/eris.git#5246da9589bdc22d610d960202d1f84dc865c3a2",
"resolved": "https://registry.npmjs.org/eris/-/eris-0.15.1.tgz", "from": "eris@abalabahaha/eris#dev",
"integrity": "sha512-IQ3BPW6OjgFoqjdh+irPOa1jFlkotk+WNu2GQQ7QAQfbzQEPZgn+F+hpOxfMUXPHOZMX4sPKLkVDkMHAssBYhw==",
"requires": { "requires": {
"opusscript": "^0.0.8", "opusscript": "^0.0.8",
"tweetnacl": "^1.0.1", "tweetnacl": "^1.0.1",
"ws": "^7.2.1" "ws": "^7.4.6"
} }
}, },
"eris-fleet": { "eris-fleet": {

View file

@ -29,7 +29,7 @@
"cowsay2": "^2.0.4", "cowsay2": "^2.0.4",
"dotenv": "^9.0.2", "dotenv": "^9.0.2",
"emoji-regex": "^9.2.2", "emoji-regex": "^9.2.2",
"eris": "^0.15.1", "eris": "github:abalabahaha/eris#dev",
"eris-fleet": "github:esmBot/eris-fleet", "eris-fleet": "github:esmBot/eris-fleet",
"file-type": "^16.1.0", "file-type": "^16.1.0",
"format-duration": "^1.4.0", "format-duration": "^1.4.0",

View file

@ -62,10 +62,8 @@ class Shard extends BaseClusterWorker {
} }
this.ipc.register("reload", async (message) => { this.ipc.register("reload", async (message) => {
//const result = await unload(message.msg); const result = await load(paths.get(message.msg));
//if (result) return this.ipc.broadcast("reloadFail", { result: result }); if (result) return this.ipc.broadcast("reloadFail", { result });
const result2 = await load(paths.get(message.msg));
if (result2) return this.ipc.broadcast("reloadFail", { result: result2 });
return this.ipc.broadcast("reloadSuccess"); return this.ipc.broadcast("reloadSuccess");
}); });

View file

@ -1,27 +1,12 @@
import { paths, commands, info, aliases as _aliases } from "./collections.js"; import { paths, commands, info, aliases as _aliases } from "./collections.js";
import { log } from "./logger.js"; import { log } from "./logger.js";
//import { Worker, isMainThread, workerData, parentPort } from "worker_threads";
//import { join, dirname } from "path";
//import { fileURLToPath } from "url";
/*const importNoCache = (module) => { let queryValue = 0;
return new Promise((resolve, reject) => {
const worker = new Worker(new URL("./handler.js", import.meta.url), {
workerData: { module: module }
});
worker.once("message", (result) => {
resolve(result);
});
worker.once("error", (result) => {
reject(result);
});
});
};*/
// load command into memory // load command into memory
export async function load(command, soundStatus) { export async function load(command, soundStatus) {
//const props = await importNoCache(`../${command}`); const { default: props } = await import(`../${command}?v=${queryValue}`);
const { default: props } = await import(`../${command}`); queryValue++;
if (props.requires.includes("mashape") && process.env.MASHAPE === "") return log("warn", `Mashape/RapidAPI info not provided in config, skipped loading command ${command}...`); if (props.requires.includes("mashape") && process.env.MASHAPE === "") return log("warn", `Mashape/RapidAPI info not provided in config, skipped loading command ${command}...`);
if (props.requires.includes("sound") && soundStatus) return log("warn", `Failed to connect to some Lavalink nodes, skipped loading command ${command}...`); if (props.requires.includes("sound") && soundStatus) return log("warn", `Failed to connect to some Lavalink nodes, skipped loading command ${command}...`);
const commandArray = command.split("/"); const commandArray = command.split("/");
@ -46,35 +31,3 @@ export async function load(command, soundStatus) {
} }
return false; return false;
} }
// unload command from memory
/*export async function unload(command) {
let cmd;
if (commands.has(command)) {
cmd = commands.get(command);
} else if (_aliases.has(command)) {
cmd = commands.get(_aliases.get(command));
}
if (!cmd) return `The command \`${command}\` doesn't seem to exist, nor is it an alias.`;
const path = paths.get(command);
const mod = require.cache[require.resolve(`../${path}`)];
delete require.cache[require.resolve(`../${path}`)];
for (let i = 0; i < module.children.length; i++) {
if (module.children[i] === mod) {
module.children.splice(i, 1);
break;
}
}
return false;
}*/
/*if (!isMainThread) {
const getModule = async () => {
console.log("test");
const module = await import(workerData.module);
console.log("test 2");
parentPort.postMessage(module);
process.exit();
};
getModule();
}*/