import { formGuildInfoMessage, formGuildLeaderboardMessage, formGuildOnlineMessage } from "#/bot/common/guild" import { WYNN_GUILD_ID } from "#/constants" import { inject, injectable } from "@needle-di/core" import { SlashHandler } from "./types" import { PG } from "#/services/pg" import { ApplicationCommandOptionTypes, ApplicationCommandTypes, CreateApplicationCommand } from "discordeno" @injectable() export class SlashCommandHandler { constructor( public readonly db = inject(PG) ) { } commands(): CreateApplicationCommand[] { return [ { name: `guild`, description: "guild commands", type: ApplicationCommandTypes.ChatInput, options: [ { name: "leaderboard", description: "view the current leaderboard", type: ApplicationCommandOptionTypes.SubCommand, }, { name: "info", description: "view guild information", type: ApplicationCommandOptionTypes.SubCommand, }, { name: "online", description: "show online players", type: ApplicationCommandOptionTypes.SubCommand, }, ], }, { name: "admin", description: "admin commands", type: ApplicationCommandTypes.ChatInput, defaultMemberPermissions: [ "ADMINISTRATOR", ], options: [ { name: "set_wynn_guild", description: "set the default wynncraft guild for the server", type: ApplicationCommandOptionTypes.SubCommand, }, ], } ] } root(): SlashHandler { return { guild: { info: async (interaction) => { const msg = await formGuildInfoMessage( WYNN_GUILD_ID, this.db.sql, ) await interaction.respond(msg, { withResponse: true, }) }, online: async (interaction) => { const msg = await formGuildOnlineMessage( WYNN_GUILD_ID, this.db.sql, ) await interaction.respond(msg, { withResponse: true, }) }, leaderboard: async (interaction) => { const leaderboard = await formGuildLeaderboardMessage( WYNN_GUILD_ID, this.db.sql, ) await interaction.respond(leaderboard, { withResponse: true, }) }, }, admin: { set_wynn_guild: async (interaction) => { }, } } } }