diff options
author | Minteck <contact@minteck.org> | 2022-07-13 23:34:21 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-07-13 23:34:21 +0200 |
commit | 7b5df4ca0a5bd6fcf033ef40563599593b156910 (patch) | |
tree | 56cb89f3900adde9da67e7558793a20fb40d7197 /commands | |
download | cooler-pony-7b5df4ca0a5bd6fcf033ef40563599593b156910.tar.gz cooler-pony-7b5df4ca0a5bd6fcf033ef40563599593b156910.tar.bz2 cooler-pony-7b5df4ca0a5bd6fcf033ef40563599593b156910.zip |
Initial commit
Diffstat (limited to 'commands')
-rw-r--r-- | commands/about.ts | 62 | ||||
-rw-r--r-- | commands/ping.ts | 33 |
2 files changed, 95 insertions, 0 deletions
diff --git a/commands/about.ts b/commands/about.ts new file mode 100644 index 0000000..96ba94a --- /dev/null +++ b/commands/about.ts @@ -0,0 +1,62 @@ +import {CommandBase} from "../core/CommandBase"; +import {SlashCommandBuilder} from "@discordjs/builders"; +import * as os from 'os'; +import * as fs from 'fs'; +import {CommandAction} from "../core/CommandAction"; +import {MessageActionRow, MessageButton, MessageEmbed} from "discord.js"; +import {LogManager} from "../core/LogManager"; + +export class AboutCommand extends CommandBase { + constructor() { + super(); + this.slashCommandData = new SlashCommandBuilder() + .setName("about") + .setDescription("Gets diagnostics information from the bot") + } + + public handle(action: CommandAction) { + let interaction = action.getInteraction(); + + interaction.reply({ + embeds: [ + new MessageEmbed() + .setTitle(":sos: Diagnostics Information") + .setDescription(global.client.user.username + " version " + global.version + ", build " + global.build + "\n on Node.js " + process.versions.node + " " + process.arch + "\n on " + os.type() + " " + os.arch() + " " + os.release() + "\n on " + os.hostname() + "\n" + ( + fs.existsSync("./RESTART") ? ( + ":warning: Update to version " + (fs.existsSync("./.git/refs/heads/mane") ? fs.readFileSync("./.git/refs/heads/mane").toString().trim().substring(0, 8) : (fs.existsSync("../.git/refs/heads/mane") ? fs.readFileSync("../.git/refs/heads/mane").toString().trim().substring(0, 8) : (fs.existsSync("./version.txt") ? fs.readFileSync("./version.txt").toString().trim() : (fs.existsSync("../version.txt") ? fs.readFileSync("../version.txt").toString().trim() : "live")))) + ", build " + (fs.existsSync("./build.txt") ? fs.readFileSync("./build.txt").toString().trim() : (fs.existsSync("../build.txt") ? fs.readFileSync("../build.txt").toString().trim() : "dev")) + " pending." + ) : ("") + )) + .addField("System Information", "" + + "**PID:** " + process.pid + ", running as " + os.userInfo().username + " (" + os.userInfo().uid + ":" + os.userInfo().gid + ")\n" + + "**Path:** " + global.systemRoot + "\n" + ) + .addField("Bot Information", "" + + "**User ID:** " + global.client.user.id + "\n" + + "**Imported modules:** " + Object.keys(require.cache).length + "\n" + + "**Used RAM:** " + Math.round(process.memoryUsage().heapTotal / (1024 ** 2)) + " MiB\n" + + "**Connection date:** " + global.client.readyAt.toISOString() + ) + ], + components: [ + new MessageActionRow() + .addComponents( + new MessageButton() + .setLabel('Source Code') + .setStyle('LINK') + .setURL("https://git.equestria.dev/equestria.dev/dj-pon-3"), + new MessageButton() + .setLabel('Roadmap') + .setStyle('LINK') + .setURL("https://git.equestria.dev/equestria.dev/dj-pon-3/src/branch/mane/TODO.md"), + new MessageButton() + .setLabel('General Information') + .setStyle('LINK') + .setURL("https://git.equestria.dev/equestria.dev/dj-pon-3/src/branch/mane/README.md"), + ) + ] + }).then(() => { + LogManager.info("/about: dispatched GUI info"); + }) + return; + } +} diff --git a/commands/ping.ts b/commands/ping.ts new file mode 100644 index 0000000..5b79231 --- /dev/null +++ b/commands/ping.ts @@ -0,0 +1,33 @@ +import {CommandBase} from "../core/CommandBase"; +import {MessageEmbed} from "discord.js"; +import {SlashCommandBuilder} from "@discordjs/builders"; +import {CommandAction} from "../core/CommandAction"; + +export class PingCommand extends CommandBase { + constructor() { + super(); + this.slashCommandData = new SlashCommandBuilder() + .setName("ping") + .setDescription("Shows the latency between the bot and Discord") + } + + public handle(action: CommandAction) { + let interaction = action.getInteraction(); + let VoiceBase = global.VoiceBase; + let processing = new Date().getTime() - global.processingStart; + let interactionTime = new Date().getTime() - interaction.createdAt.getTime(); + let apiTime = global.client.ws.ping; + + interaction.reply({ + embeds: [ + new MessageEmbed() + .setTitle(":rocket: Pong!") + .addFields( + {name: "Processing", value: processing.toFixed(2) + "ms", inline: true}, + {name: "Interaction", value: interactionTime.toFixed(2) + "ms", inline: true}, + {name: "API", value: apiTime.toFixed(2) + "ms", inline: true} + ) + ] + }); + } +}
\ No newline at end of file |