2025-03-02 11:49:36 +00:00
|
|
|
import { formGuildInfoMessage, formGuildLeaderboardMessage, formGuildOnlineMessage } from "#/bot/common/guild"
|
2025-03-01 21:10:31 +00:00
|
|
|
import { WYNN_GUILD_ID } from "#/constants"
|
|
|
|
|
import { inject, injectable } from "@needle-di/core"
|
|
|
|
|
import { SlashHandler } from "./types"
|
|
|
|
|
import { PG } from "#/services/pg"
|
2025-03-02 11:49:36 +00:00
|
|
|
import { ApplicationCommandOptionTypes, ApplicationCommandTypes, CreateApplicationCommand } from "discordeno"
|
2025-03-01 21:10:31 +00:00
|
|
|
|
|
|
|
|
@injectable()
|
|
|
|
|
export class SlashCommandHandler {
|
|
|
|
|
constructor(
|
|
|
|
|
public readonly db = inject(PG)
|
|
|
|
|
) {
|
|
|
|
|
}
|
2025-03-02 11:49:36 +00:00
|
|
|
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,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2025-03-01 21:10:31 +00:00
|
|
|
root(): SlashHandler {
|
|
|
|
|
return {
|
|
|
|
|
guild: {
|
|
|
|
|
info: async (interaction) => {
|
2025-03-02 11:49:36 +00:00
|
|
|
const msg = await formGuildInfoMessage(
|
|
|
|
|
WYNN_GUILD_ID,
|
|
|
|
|
this.db.sql,
|
|
|
|
|
)
|
|
|
|
|
await interaction.respond(msg, {
|
|
|
|
|
withResponse: true,
|
|
|
|
|
})
|
2025-03-01 21:10:31 +00:00
|
|
|
},
|
|
|
|
|
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) => {
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|