aboutsummaryrefslogtreecommitdiff
path: root/commands/restart.ts
blob: 0f4bcfdf72a0f8bce95b3a532c4cf5209cfe98be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import {CommandBase} from "../core/CommandBase";
import {SlashCommandBuilder} from "@discordjs/builders";
import * as fs from 'fs';
import {CommandAction} from "../core/CommandAction";
import {MessageEmbed} from "discord.js";

export class RestartCommand extends CommandBase {
    constructor() {
        super();
        this.slashCommandData = new SlashCommandBuilder()
            .setName("restart")
            .setDescription("Restarts the bot")
    }

    public handle(action: CommandAction) {
        let interaction = action.getInteraction();

        if (!interaction.memberPermissions.has("ADMINISTRATOR")) {
            interaction.reply({
                embeds: [
                    new MessageEmbed()
                        .setDescription(":x: You need to have the server administrator permission.")
                ]
            });
            return;
        }

        interaction.reply({
            embeds: [
                new MessageEmbed()
                    .setDescription(":white_check_mark: The bot is now restarting")
            ]
        }).then(() => {
            fs.writeFileSync("./RESTART-FORCE", "");
        });
    }
}