import {adminId, SubcommandData} from "../types.js"
import {ApplicationCommandOptionType, ApplicationCommandSubCommandData, ChatInputCommandInteraction} from "discord.js"

class ShutdownCommand extends SubcommandData {
    readonly definition: ApplicationCommandSubCommandData = {
        name: "shutdown",
        type: ApplicationCommandOptionType.Subcommand,
        description: "Tells the bot to shut down.",
    }

    async execute(b: ChatInputCommandInteraction): Promise<void> {
        const user = b.user || b.member
        if (!!user && user.id === adminId) {
            await b.reply("Good night =w=")
            const self = b.client.user
            self.presence.set({
                status: "invisible",
                activities: [],
            })
            b.client.destroy()
        } else {
            await b.reply("Heeey... I don't gotta do what you say...")
        }
    }
}

export const commandBotShutdown = new ShutdownCommand()