From 1c1756d180840488dca1d42571ab90e4173dc711 Mon Sep 17 00:00:00 2001 From: Lio Young Date: Wed, 5 May 2021 14:57:42 +0200 Subject: [PATCH] push latest --- src/handler/client/Client.ts | 3 ++- src/modules/misc/invite.ts | 22 ++++++++++++++++++++++ src/modules/misc/stats.ts | 31 +++++++++++++++++++++++++++++++ src/utils/command.usage.ts | 14 ++++++++++++++ src/utils/types.ts | 6 ++++-- variables.ts | 3 ++- 6 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 src/modules/misc/invite.ts create mode 100644 src/modules/misc/stats.ts create mode 100644 src/utils/command.usage.ts diff --git a/src/handler/client/Client.ts b/src/handler/client/Client.ts index f17eb8f..0efa01f 100755 --- a/src/handler/client/Client.ts +++ b/src/handler/client/Client.ts @@ -1,11 +1,12 @@ import { Client, Collection } from "discord.js"; import { readdirSync as read } from "fs"; import path from "path"; +import { Command } from "../../utils/types"; import Logger from "../../utils/logger"; // const server = require('../../website/server'); export default class Thaldrin extends Client { - commands: Collection; + commands: Collection; cooldowns: Collection; config: any; lastEval: any; diff --git a/src/modules/misc/invite.ts b/src/modules/misc/invite.ts new file mode 100644 index 0000000..ad8d371 --- /dev/null +++ b/src/modules/misc/invite.ts @@ -0,0 +1,22 @@ +import Command from '../../handler/structures/Command'; +import { Context } from '../../utils/types'; +import lingua from '../../utils/lingua'; +import embed from '../../utils/embed'; + +export = class Invite extends Command { + constructor() { + super({ + name: "invite", + description: "Invite the bot to your server", + aliases: ["inv"], + cooldown: 1, + }) + } + + async command(ctx: Context) { + // TODO: generate custom invites for every server + // @ts-ignore + ctx.channel.send(`${lingua[ctx.settings.locale].INVITE_STRING}:\n<${ctx.config.variables.invite}>`) + + } +} \ No newline at end of file diff --git a/src/modules/misc/stats.ts b/src/modules/misc/stats.ts new file mode 100644 index 0000000..4348fdf --- /dev/null +++ b/src/modules/misc/stats.ts @@ -0,0 +1,31 @@ +import Command from '../../handler/structures/Command'; +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() { + super({ + name: "stats", + description: "See the Bot's Stats", + aliases: ["statistics"], + cooldown: 1, + }) + } + + 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) + + } +} \ No newline at end of file diff --git a/src/utils/command.usage.ts b/src/utils/command.usage.ts new file mode 100644 index 0000000..3169cce --- /dev/null +++ b/src/utils/command.usage.ts @@ -0,0 +1,14 @@ +import supabase from "./database" +import { Command, Usage } from "./types" + +export default async function usage(c: Map) { + let commands: string[] = [] + + let { data, error } = await supabase.from("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 +} \ No newline at end of file diff --git a/src/utils/types.ts b/src/utils/types.ts index f83b8f2..56693c1 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,6 +1,6 @@ import { SupabaseClient } from "@supabase/supabase-js"; import { Client, Guild, GuildMember, Message, NewsChannel, TextChannel, User } from "discord.js"; - +import Thaldrin from "../handler/client/Client"; export type Server = { readonly id: string server_id: string @@ -34,8 +34,9 @@ export type Command = { hidden?: boolean; } + export type Context = { - client: Client; + client: Thaldrin; args: string[] guild: Guild | null; message: Message; @@ -161,6 +162,7 @@ export interface Variables { invite: string } website: string + invite: any; } export interface Pkg { diff --git a/variables.ts b/variables.ts index 237f0c6..6efc4aa 100644 --- a/variables.ts +++ b/variables.ts @@ -44,5 +44,6 @@ export default { }, tagline: "A Random Image and Utility Bot", color: "#ff995d", - website: "thaldr.in" + website: "thaldr.in", + invite: "https://t8.pm/legacy-invite" } \ No newline at end of file