remove paginator, it is extremely discord-specific

This commit is contained in:
murm 2023-03-19 06:42:07 -04:00
parent 7a76609e70
commit 9539ea32cd
8 changed files with 27 additions and 277 deletions

View file

@ -1,5 +1,5 @@
import Command from "../../classes/command.js";
import { clean } from "../../utils/misc.js";
import { clean, htmlescape } from "../../utils/misc.js";
class Base64Command extends Command {
static category = "general"
@ -13,7 +13,7 @@ class Base64Command extends Command {
this.success = true;
if (command === "decode") {
const b64Decoded = Buffer.from(string, "base64").toString("utf8");
return { html: `<pre><code>${await clean(b64Decoded)}</pre></code>` };
return { html: `<pre><code>${htmlescape(await clean(b64Decoded))}</pre></code>` };
} else if (command === "encode") {
const b64Encoded = Buffer.from(string, "utf8").toString("base64");
return { html: `<pre><code>${b64Encoded}</pre></code>` };

View file

@ -1,52 +1,33 @@
import paginator from "../../utils/pagination/pagination.js";
import database from "../../utils/database.js";
import Command from "../../classes/command.js";
import * as collections from "../../utils/collections.js";
import { htmlescape } from "../../utils/misc.js";
class CountCommand extends Command {
static category = "general"
async run() {
if (this.guild && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) {
this.success = false;
return "I don't have the `Embed Links` permission!";
}
const counts = await database.getCounts();
const countArray = [];
for (const entry of Object.entries(counts)) {
countArray.push(entry);
if (this.args.length !== 0) {
if (collections.commands.has(this.args[0].toLowerCase())) {
let html;
const command = collections.aliases.get(this.args[0].toLowerCase()) ?? this.args[0].toLowerCase();
// TODO: room-specific prefix
const prefix = htmlescape(process.env.PREFIX);
let amount = counts[command]
if (amount == 1) {
amount = `<b>${amount}</b> time!`
} else {
amount = `<b>${amount}</b> times!`
}
html = `The command <code>${prefix}${command}</code> has been used ${amount}`
return { html: html }
}
return "You need to specify a valid command to see its usage amount!"
}
const sortedValues = countArray.sort((a, b) => {
return b[1] - a[1];
});
const countArray2 = [];
for (const [key, value] of sortedValues) {
countArray2.push(`**${key}**: ${value}`);
}
const embeds = [];
const groups = countArray2.map((item, index) => {
return index % 15 === 0 ? countArray2.slice(index, index + 15) : null;
}).filter((item) => {
return item;
});
for (const [i, value] of groups.entries()) {
embeds.push({
embeds: [{
title: "Command Usage Counts",
color: 16711680,
footer: {
text: `Page ${i + 1} of ${groups.length}`
},
description: value.join("\n"),
author: {
name: this.author.username,
iconURL: this.author.avatarURL()
}
}]
});
}
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, embeds);
return "You need to specify a command to see its usage amount!"
}
static description = "Gets how many times every command was used";
static description = "Gets how many times a command was used";
static arguments = ["{mention/id}"];
static aliases = ["counts"];
static dbRequired = true;

View file

@ -1,8 +1,6 @@
// import { Constants } from "oceanic.js";
// import database from "../../utils/database.js";
import * as collections from "../../utils/collections.js";
import { htmlescape } from "../../utils/misc.js";
// import paginator from "../../utils/pagination/pagination.js";
import * as help from "../../utils/help.js";
import Command from "../../classes/command.js";
// const tips = ["You can change the bot's prefix using the prefix command.", "Image commands also work with images previously posted in that channel.", "You can use the tags commands to save things for later use.", "You can visit https://esmbot.net/help.html for a web version of this command list.", "You can view a command's aliases by putting the command name after the help command (e.g. help image).", "Parameters wrapped in [] are required, while parameters wrapped in {} are optional.", "esmBot is hosted and paid for completely out-of-pocket by the main developer. If you want to support development, please consider donating! https://patreon.com/TheEssem"];

View file

@ -1,4 +1,3 @@
import paginator from "../../utils/pagination/pagination.js";
import { readFileSync } from "fs";
const { searx } = JSON.parse(readFileSync(new URL("../../config/servers.json", import.meta.url)));
import { random } from "../../utils/misc.js";
@ -9,7 +8,6 @@ class ImageSearchCommand extends Command {
static category = "general"
async run() {
this.success = false;
// if (this.channel && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) return "I don't have the `Embed Links` permission!";
const query = this.options.query ?? this.args.join(" ");
if (!query || !query.trim()) return "You need to provide something to search for!";
// await this.acknowledge();