You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
vore-rpg/src/commands/bot/shutdown.ts

39 lines
1.3 KiB

import {SubcommandData} from "../types"
import {ApplicationCommandOptionType, ApplicationCommandSubCommandData, ChatInputCommandInteraction} from "discord.js"
import {UsersManager} from "../../managers/users";
export class BotShutdownCommand extends SubcommandData {
private readonly _users: UsersManager
private readonly _cleanUp: () => Promise<void>
constructor({users, cleanUp}: { users: UsersManager, cleanUp(): Promise<void> }) {
super()
this._users = users
this._cleanUp = cleanUp
}
readonly definition: ApplicationCommandSubCommandData = {
name: "shutdown",
type: ApplicationCommandOptionType.Subcommand,
description: "Tells the bot to shut down.",
}
async execute(b: ChatInputCommandInteraction): Promise<void> {
if (await this._users.isSnowflakeAdmin(b.user.id)) {
await b.reply({
ephemeral: true,
content: "Good night =w=",
})
b.client.user.presence.set({
status: "invisible",
activities: [],
})
await this._cleanUp()
} else {
await b.reply({
ephemeral: true,
content: "Heeey... I don't gotta do what you say...",
})
}
}
}