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/restart.ts

52 lines
1.6 KiB

import {SubcommandData} from "../types"
import {
ActivityType,
ApplicationCommandOptionType,
ApplicationCommandSubCommandData,
ChatInputCommandInteraction,
} from "discord.js"
import {wrappedRestart} from "../../ipc/restart"
import {UsersManager} from "../../managers/users";
export class BotRestartCommand 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: "restart",
type: ApplicationCommandOptionType.Subcommand,
description: "Tells the bot to restart.",
}
async execute(b: ChatInputCommandInteraction): Promise<void> {
if (await this._users.isSnowflakeAdmin(b.user.id)) {
await b.reply({
ephemeral: true,
content: "Yaaaawwn... Okay... Just a quick nap then...",
})
const self = b.client.user
self.setPresence({
status: "idle",
afk: true,
activities: [
{
type: ActivityType.Listening,
name: "A New Day",
},
],
})
await wrappedRestart(b, this._cleanUp)
} else {
await b.reply({
ephemeral: true,
content: "Heeey... I don't gotta do what you say...",
})
}
}
}