Adds some more polish
This commit is contained in:
parent
b3d0b3a90c
commit
11bd836ec3
18 changed files with 272 additions and 29 deletions
60
source/Discord/Commands/Bot.ts
Normal file
60
source/Discord/Commands/Bot.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import {CacheType, ChatInputCommandInteraction, hyperlink, PermissionFlagsBits, SlashCommandBuilder} from "discord.js";
|
||||
import {ChatInteractionCommand, Command} from "./Command";
|
||||
import * as fs from "node:fs";
|
||||
import {UserError} from "../UserError";
|
||||
import {ifError} from "node:assert";
|
||||
import {BuildContextGetter} from "../../Utilities/BuildContext";
|
||||
import {EmbedLibrary} from "../EmbedLibrary";
|
||||
|
||||
export class BotCommand implements Command, ChatInteractionCommand {
|
||||
definition(): SlashCommandBuilder {
|
||||
return new SlashCommandBuilder()
|
||||
.setName("bot")
|
||||
.setDescription("Offers some information about the bot")
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addSubcommand(command => command
|
||||
.setName("build")
|
||||
.setDescription("Displays some information about the build the bot is running on.")
|
||||
)
|
||||
}
|
||||
|
||||
execute(interaction: ChatInputCommandInteraction<CacheType>): Promise<void> {
|
||||
switch (interaction.options.getSubcommand()) {
|
||||
case "build":
|
||||
this.displayBuildInfos(interaction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private displayBuildInfos(interaction: ChatInputCommandInteraction<CacheType>) {
|
||||
const buildContext = new BuildContextGetter().getContext();
|
||||
if (!buildContext) {
|
||||
throw new UserError("Can't find required deploy information", "Using a valid docker image or (when running on a dev build) running `npm run build` once.");
|
||||
}
|
||||
|
||||
const embed = EmbedLibrary.base("Current Build")
|
||||
.setFields(
|
||||
[
|
||||
{
|
||||
name: "Build Target",
|
||||
value: buildContext.target,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Build Label",
|
||||
value: buildContext.label,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Latest Commit",
|
||||
value: hyperlink(buildContext.commitHash, buildContext.commitLink)
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
interaction.reply({
|
||||
embeds: [embed]
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue