2023-03-15 14:09:09 +00:00
|
|
|
import database from "../../utils/database.js";
|
|
|
|
import Command from "../../classes/command.js";
|
2023-03-19 10:42:07 +00:00
|
|
|
import * as collections from "../../utils/collections.js";
|
|
|
|
import { htmlescape } from "../../utils/misc.js";
|
2023-03-15 14:09:09 +00:00
|
|
|
|
|
|
|
class CountCommand extends Command {
|
|
|
|
async run() {
|
|
|
|
const counts = await database.getCounts();
|
2023-03-19 10:42:07 +00:00
|
|
|
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!"
|
2023-03-15 14:09:09 +00:00
|
|
|
}
|
2023-03-19 10:42:07 +00:00
|
|
|
return "You need to specify a command to see its usage amount!"
|
2023-03-15 14:09:09 +00:00
|
|
|
}
|
2023-03-22 08:49:03 +00:00
|
|
|
|
|
|
|
static category = "general"
|
2023-03-19 10:42:07 +00:00
|
|
|
static description = "Gets how many times a command was used";
|
2023-03-15 14:09:09 +00:00
|
|
|
static arguments = ["{mention/id}"];
|
|
|
|
static aliases = ["counts"];
|
|
|
|
static dbRequired = true;
|
|
|
|
}
|
|
|
|
|
2021-08-19 14:19:14 +00:00
|
|
|
export default CountCommand;
|