mirror of https://github.com/thaldrin/thaldrin.git
Compare commits
4 Commits
96696ff901
...
9139a73745
Author | SHA1 | Date |
---|---|---|
Lio Young | 9139a73745 | |
Lio Young | 0176a3d1fc | |
Lio Young | 053dcdf236 | |
Lio Young | 3660503ecc |
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"name": "thaldrin",
|
||||
"version": "4.0-dev",
|
||||
"version": "4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "4.0-dev",
|
||||
"version": "4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@supabase/supabase-js": "^1.7.7",
|
||||
|
@ -27,7 +27,8 @@
|
|||
"@types/js-yaml": "^4.0.2",
|
||||
"@types/node": "^14.14.37",
|
||||
"@types/roll": "^1.2.0",
|
||||
"@types/ws": "^7.4.1"
|
||||
"@types/ws": "^7.4.1",
|
||||
"typescript": "^4.3.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@dabh/diagnostics": {
|
||||
|
@ -1138,6 +1139,19 @@
|
|||
"is-typedarray": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "4.3.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz",
|
||||
"integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
@ -2248,6 +2262,12 @@
|
|||
"is-typedarray": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.3.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz",
|
||||
"integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==",
|
||||
"dev": true
|
||||
},
|
||||
"uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "thaldrin",
|
||||
"version": "4.0-dev",
|
||||
"version": "4",
|
||||
"description": "",
|
||||
"main": "build/shard.js",
|
||||
"scripts": {
|
||||
|
@ -45,6 +45,7 @@
|
|||
"@types/js-yaml": "^4.0.2",
|
||||
"@types/node": "^14.14.37",
|
||||
"@types/roll": "^1.2.0",
|
||||
"@types/ws": "^7.4.1"
|
||||
"@types/ws": "^7.4.1",
|
||||
"typescript": "^4.3.5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import Logger from "../utils/logger"
|
||||
import config from "../../config"
|
||||
import { Guild } from "discord.js"
|
||||
import Prom from "../utils/init.prometheus";
|
||||
// import Prom from "../utils/init.prometheus";
|
||||
export = {
|
||||
name: "guildCreate",
|
||||
// @ts-ignore
|
||||
run: async (client, guild: Guild) => {
|
||||
Prom.guildCount.inc()
|
||||
Prom.totalGuilds.set(client.guilds.cache.size)
|
||||
// Prom.guildCount.inc()
|
||||
// Prom.totalGuilds.set(client.guilds.cache.size)
|
||||
Logger.info({
|
||||
type: "event:guildCreate",
|
||||
message: `New Guild: ${guild.name} [${guild.id}]`
|
||||
|
|
|
@ -8,13 +8,13 @@ import { Commands, Shortlink, SourceFinder } from "../utils/wrapper.features";
|
|||
import language from "../utils/language";
|
||||
import replace from "../utils/replace";
|
||||
import chalk from "chalk";
|
||||
import Prom from "../utils/init.prometheus";
|
||||
// import Prom from "../utils/init.prometheus";
|
||||
|
||||
|
||||
//
|
||||
export = {
|
||||
name: "message",
|
||||
run: async (client: Client, message: Message) => {
|
||||
Prom.messagesSeen.inc()
|
||||
// Prom.messagesSeen.inc()
|
||||
if (message.author.bot) return
|
||||
if (message.channel.type === "dm") return
|
||||
|
||||
|
@ -124,7 +124,7 @@ export = {
|
|||
|
||||
}
|
||||
|
||||
Prom.commandsExecuted.inc()
|
||||
// Prom.commandsExecuted.inc()
|
||||
let { data: command_usage_data, command_usage_error } = await supabase.from<Usage>('usage').update({ amount: (usage_check_data[0] || { amount: 0 }).amount + 1 }).select().eq("name", cmd.name)
|
||||
Logger.info({
|
||||
type: "command:executed",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import Logger from "../utils/logger"
|
||||
import config from "../../config"
|
||||
import prom from "../utils/init.prometheus"
|
||||
// import prom from "../utils/init.prometheus"
|
||||
export = {
|
||||
name: "ready",
|
||||
// @ts-ignore
|
||||
run: async (client: any) => {
|
||||
prom.totalGuilds.set(client.guilds.cache.size)
|
||||
// prom.totalGuilds.set(client.guilds.cache.size)
|
||||
Logger.info({
|
||||
type: "event:ready",
|
||||
message: `${config.variables.name} has started`
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import Logger from "../utils/logger"
|
||||
import { Guild } from "discord.js"
|
||||
import Prom from "../utils/init.prometheus";
|
||||
// import Prom from "../utils/init.prometheus";
|
||||
export = {
|
||||
name: "guildDelete",
|
||||
// @ts-ignore
|
||||
run: async (client, guild: Guild) => {
|
||||
Prom.guildCount.dec()
|
||||
Prom.totalGuilds.set(client.guilds.cache.size)
|
||||
// Prom.guildCount.dec()
|
||||
// Prom.totalGuilds.set(client.guilds.cache.size)
|
||||
Logger.info({
|
||||
type: "event:guildDelete",
|
||||
message: `Left Guild: ${guild.name} [${guild.id}]`
|
||||
|
|
|
@ -3,7 +3,7 @@ import { readdirSync as read } from "fs";
|
|||
import path from "path";
|
||||
import { Command } from "../../utils/types";
|
||||
import Logger from "../../utils/logger";
|
||||
import { Prom } from "../../utils/prometheus";
|
||||
// import { Prom } from "../../utils/prometheus";
|
||||
// const server = require('../../website/server');
|
||||
|
||||
export default class Thaldrin extends Client {
|
||||
|
@ -26,9 +26,9 @@ export default class Thaldrin extends Client {
|
|||
|
||||
this.lastEval = null;
|
||||
// @ts-ignore
|
||||
this.on("raw", packet => {
|
||||
Prom.events.labels(packet.t).inc()
|
||||
})
|
||||
// this.on("raw", packet => {
|
||||
// Prom.events.labels(packet.t).inc()
|
||||
// })
|
||||
|
||||
this.login(config.token);
|
||||
this.load();
|
||||
|
|
|
@ -7,7 +7,7 @@ import language from '../../utils/language';
|
|||
|
||||
function enabled(a: boolean, lang: string) {
|
||||
// @ts-ignore
|
||||
return a ? language.get(lang).misc.enabled : language.get(lang).misc.disabled;
|
||||
return a ? language.get(lang).misc.enabled : language.get(lang).misc.disabled; w
|
||||
}
|
||||
|
||||
export = class Settings extends Command {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Command from '../../handler/structures/Command';
|
||||
import { Context, Usage } from '../../utils/types';
|
||||
import lingua from '../../utils/lingua';
|
||||
// import lingua from '../../utils/lingua';
|
||||
import { MessageEmbed } from 'discord.js';
|
||||
import CommandUsage from '../../utils/command.usage';
|
||||
import { commitHash } from "../../utils/git"
|
||||
|
@ -42,8 +42,8 @@ export = class Stats extends Command {
|
|||
|
||||
let embed = new MessageEmbed().setColor(ctx.config.variables.color).setFooter(`${ctx.config.variables.name} v${ctx.config.pkg.version} [${commitHash}]`, ctx.config.variables.avatar)
|
||||
.setTitle(`Statistics`)
|
||||
.setDescription(`Visit [our System Dashboard](https://system.thaldr.in) for more in-depth stats`)
|
||||
.addField(`Misc`, MiscValues.map((value) => `${value}`))
|
||||
.setDescription(MiscValues.map((value) => `${value}`))
|
||||
// .addField(`Misc`, )
|
||||
|
||||
|
||||
ctx.channel.send(embed)
|
||||
|
|
|
@ -30,13 +30,13 @@ export = class Help extends Command {
|
|||
}
|
||||
let arg = ctx.args[0]
|
||||
if (await (await Folders()).includes(arg)) {
|
||||
if (arg === 'developer') return
|
||||
if (arg === 'developer' && !ctx.isDeveloper) return
|
||||
let commands = await (await Commands(arg, ctx.client)).map(command => `\`${command.name}\` - ${command.description}`)
|
||||
embed.addField("Commands", commands.join("\n"))
|
||||
// @ts-ignore
|
||||
embed.setTitle(`${language.get(ctx.settings.locale).categories[folder.toLowerCase()].name || arg}`)
|
||||
embed.setTitle(`${language.get(ctx.settings.locale).categories[arg].name || arg}`)
|
||||
// @ts-ignore
|
||||
embed.setDescription(`${language.get(ctx.settings.locale).categories[folder.toLowerCase()].desc || ""}\n\nTotal Commands: **${commands.length}**`)
|
||||
embed.setDescription(`${language.get(ctx.settings.locale).categories[arg].desc || ""}\n\nTotal Commands: **${commands.length}**`)
|
||||
return ctx.channel.send(embed)
|
||||
}
|
||||
// @ts-ignore
|
||||
|
@ -46,7 +46,7 @@ export = class Help extends Command {
|
|||
embed.setTitle("Command Help")
|
||||
if (command.aliases?.length !== 0) embed.addField("Aliases", `⇒\`${command.aliases?.join("`\n⇒`")}\``, true)
|
||||
// @ts-ignore
|
||||
embed.setDescription(`**Cooldown:** ${command.cooldown}s\n**Module:** ${language.get(ctx.settings.locale).categories[folder.toLowerCase()].name || command.module}\n**NSFW:** ${command.nsfw}`)
|
||||
embed.setDescription(`**Cooldown:** ${command.cooldown}s\n**Module:** ${language.get(ctx.settings.locale).categories[command?.module.toLowerCase()].name || command.module}\n**NSFW:** ${command.nsfw}`)
|
||||
embed.addField("Usage", `\`thal ${command.name}\` ${command.usage}`, true)
|
||||
ctx.channel.send(embed)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Prom } from "./prometheus";
|
||||
// import { Prom } from "./prometheus";
|
||||
|
||||
Prom.load()
|
||||
// Prom.load()
|
||||
|
||||
export default Prom
|
||||
// export default Prom
|
|
@ -1,67 +1,67 @@
|
|||
//! Code taken from NinoDiscord/Nino
|
||||
import prom from "prom-client"
|
||||
import { createServer, IncomingMessage, ServerResponse } from 'http'
|
||||
import vars from "../../variables"
|
||||
import Logger from "./logger"
|
||||
// //! Code taken from NinoDiscord/Nino
|
||||
// import prom from "prom-client"
|
||||
// import { createServer, IncomingMessage, ServerResponse } from 'http'
|
||||
// import vars from "../../variables"
|
||||
// import Logger from "./logger"
|
||||
|
||||
export default class Prometheus {
|
||||
public commandsExecuted!: prom.Counter<string>
|
||||
public messagesSeen!: prom.Counter<string>
|
||||
public guildCount!: prom.Gauge<string>
|
||||
public totalGuilds!: prom.Gauge<string>
|
||||
public uptime!: prom.Gauge<string>
|
||||
public events!: prom.Counter<string>
|
||||
#server!: ReturnType<typeof createServer>
|
||||
// export default class Prometheus {
|
||||
// public commandsExecuted!: prom.Counter<string>
|
||||
// public messagesSeen!: prom.Counter<string>
|
||||
// public guildCount!: prom.Gauge<string>
|
||||
// public totalGuilds!: prom.Gauge<string>
|
||||
// public uptime!: prom.Gauge<string>
|
||||
// public events!: prom.Counter<string>
|
||||
// #server!: ReturnType<typeof createServer>
|
||||
|
||||
load() {
|
||||
prom.collectDefaultMetrics()
|
||||
this.commandsExecuted = new prom.Counter({
|
||||
labelNames: ['command'],
|
||||
name: "thaldrin_commands_executed",
|
||||
help: "How many commands Thaldrin has executed successfully"
|
||||
})
|
||||
this.messagesSeen = new prom.Counter({
|
||||
name: "thaldrin_messages_seen",
|
||||
help: "How many Messages Thaldrin has seen throughout the process lifespan"
|
||||
})
|
||||
this.guildCount = new prom.Gauge({
|
||||
name: "thaldrin_guild_count",
|
||||
help: "Number of Guilds Thaldrin joined this Lifecycle"
|
||||
})
|
||||
this.totalGuilds = new prom.Gauge({
|
||||
name: "thaldrin_guilds_total",
|
||||
help: "Total Number of Guilds Thaldrin is in"
|
||||
})
|
||||
this.events = new prom.Counter({
|
||||
labelNames: ['event'],
|
||||
name: "thaldrin_discord_events",
|
||||
help: "Received WebSocket events from Discord"
|
||||
})
|
||||
this.uptime = new prom.Gauge({
|
||||
name: "thaldrin_uptime",
|
||||
help: "Thaldrin's Uptime"
|
||||
})
|
||||
// load() {
|
||||
// prom.collectDefaultMetrics()
|
||||
// this.commandsExecuted = new prom.Counter({
|
||||
// labelNames: ['command'],
|
||||
// name: "thaldrin_commands_executed",
|
||||
// help: "How many commands Thaldrin has executed successfully"
|
||||
// })
|
||||
// this.messagesSeen = new prom.Counter({
|
||||
// name: "thaldrin_messages_seen",
|
||||
// help: "How many Messages Thaldrin has seen throughout the process lifespan"
|
||||
// })
|
||||
// this.guildCount = new prom.Gauge({
|
||||
// name: "thaldrin_guild_count",
|
||||
// help: "Number of Guilds Thaldrin joined this Lifecycle"
|
||||
// })
|
||||
// this.totalGuilds = new prom.Gauge({
|
||||
// name: "thaldrin_guilds_total",
|
||||
// help: "Total Number of Guilds Thaldrin is in"
|
||||
// })
|
||||
// this.events = new prom.Counter({
|
||||
// labelNames: ['event'],
|
||||
// name: "thaldrin_discord_events",
|
||||
// help: "Received WebSocket events from Discord"
|
||||
// })
|
||||
// this.uptime = new prom.Gauge({
|
||||
// name: "thaldrin_uptime",
|
||||
// help: "Thaldrin's Uptime"
|
||||
// })
|
||||
|
||||
this.#server = createServer(this.onRequest.bind(this));
|
||||
this.#server.once('listening', () => Logger.info({ type: 'event:prometheusStart', message: `Prometheus: Listening at http://localhost:${vars.prometheus.port}` }));
|
||||
this.#server.on('error', error => console.error(error));
|
||||
this.#server.listen(vars.prometheus.port);
|
||||
}
|
||||
private async onRequest(req: IncomingMessage, res: ServerResponse) {
|
||||
this.uptime.set(process.uptime())
|
||||
if (req.url! === '/metrics') {
|
||||
res.writeHead(200, { 'Content-Type': prom.register.contentType });
|
||||
res.write(await prom.register.metrics());
|
||||
} else if (req.url! === '/favicon.ico') {
|
||||
res.writeHead(404, { 'Content-Type': 'application/json' });
|
||||
res.write('{"fuck":"you uwu"}');
|
||||
} else {
|
||||
res.writeHead(400, { 'Content-Type': 'application/json' });
|
||||
res.write('{"uwu":"owo"}');
|
||||
}
|
||||
// this.#server = createServer(this.onRequest.bind(this));
|
||||
// this.#server.once('listening', () => Logger.info({ type: 'event:prometheusStart', message: `Prometheus: Listening at http://localhost:${vars.prometheus.port}` }));
|
||||
// this.#server.on('error', error => console.error(error));
|
||||
// this.#server.listen(vars.prometheus.port);
|
||||
// }
|
||||
// private async onRequest(req: IncomingMessage, res: ServerResponse) {
|
||||
// this.uptime.set(process.uptime())
|
||||
// if (req.url! === '/metrics') {
|
||||
// res.writeHead(200, { 'Content-Type': prom.register.contentType });
|
||||
// res.write(await prom.register.metrics());
|
||||
// } else if (req.url! === '/favicon.ico') {
|
||||
// res.writeHead(404, { 'Content-Type': 'application/json' });
|
||||
// res.write('{"fuck":"you uwu"}');
|
||||
// } else {
|
||||
// res.writeHead(400, { 'Content-Type': 'application/json' });
|
||||
// res.write('{"uwu":"owo"}');
|
||||
// }
|
||||
|
||||
res.end();
|
||||
}
|
||||
}
|
||||
// res.end();
|
||||
// }
|
||||
// }
|
||||
|
||||
export const Prom = new Prometheus()
|
||||
// export const Prom = new Prometheus()
|
||||
|
|
Loading…
Reference in New Issue