sort command usage and redo stat command

This commit is contained in:
Lio Young 2021-05-05 18:38:06 +02:00
parent 52a0491fb9
commit f0cfa0e6fa
2 changed files with 16 additions and 20 deletions

View File

@ -3,7 +3,6 @@ import { Context, Usage } from '../../utils/types';
import lingua from '../../utils/lingua';
import embed from '../../utils/embed';
import CommandUsage from '../../utils/command.usage';
import vega from "vega"
export = class Stats extends Command {
constructor() {
@ -17,15 +16,7 @@ export = class Stats extends Command {
async command(ctx: Context) {
let Stats = await CommandUsage(ctx.client.commands)
// @ts-ignore
let View = new vega.View(vega.parse(Stats), { renderer: "none" })
let Canvas = await View.toCanvas()
// return ctx.channel.send(Stats.join("\n"))
// @ts-ignore
let Image = View.createPNGStream()
// @ts-ignore
let Buffer = Image.toBuffer()
console.log(Buffer)
console.log(Stats)
}
}

View File

@ -1,14 +1,19 @@
import supabase from "./database"
import { Command, Usage } from "./types"
import supabase from "./database";
import { Command, Usage } from "./types";
type C = { name: string; amount: number };
export default async function usage(c: Map<string, Command>) {
let commands: string[] = []
let commands: C[] = [];
let { data, error } = await supabase.from<Usage>("usage").select().filter("type", "eq", "command")
for (const command in data) {
// @ts-ignore
commands.push({ name: data[command].name, amount: data[command].amount })
}
let { data, error } = await supabase
.from<Usage>("usage")
.select()
.filter("type", "eq", "command");
for (const command in data) {
// @ts-ignore
commands.push({ name: data[command].name, amount: data[command].amount });
}
return commands
}
return commands.sort((a, b) => a.amount - b.amount);
}