aboutsummaryrefslogtreecommitdiff
path: root/commands/restart.ts
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-11-28 17:22:49 +0100
committerMinteck <contact@minteck.org>2022-11-28 17:22:49 +0100
commit006ed0f2b6ba65f691551c18138bb38a1bef44b6 (patch)
tree9218625a3ce812e928489623b0673fdf1c964b7f /commands/restart.ts
parentaf9b870d6fae7af96fc5ecb7e6e595cdbe167b51 (diff)
downloadcooler-pony-mane.tar.gz
cooler-pony-mane.tar.bz2
cooler-pony-mane.zip
UpdateHEADmane
Diffstat (limited to 'commands/restart.ts')
-rw-r--r--commands/restart.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/commands/restart.ts b/commands/restart.ts
new file mode 100644
index 0000000..0f4bcfd
--- /dev/null
+++ b/commands/restart.ts
@@ -0,0 +1,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", "");
+ });
+ }
+}