From e777ae462176ebe8e44c60f43a9f3607ff58c8f6 Mon Sep 17 00:00:00 2001 From: MoonTM Date: Mon, 31 Jan 2022 12:45:52 +0100 Subject: [PATCH 1/3] Added redeploy command --- .../systems/staff/redeployCommand.java | 23 +++++++++++++++++++ src/main/resources/commands/staff.yaml | 9 ++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java diff --git a/src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java b/src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java new file mode 100644 index 000000000..e5eafcb5e --- /dev/null +++ b/src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java @@ -0,0 +1,23 @@ +package net.javadiscord.javabot.systems.staff; + +import lombok.extern.slf4j.Slf4j; +import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction; +import net.javadiscord.javabot.command.SlashCommandHandler; + +/** + * Command that lets staff-members redeploy the bot. + * + * This only works if the way the bot is hosted is set up correctly, for example with a bash script that handles + * compilation and a service set up with that bash script running before the bot gets started. + */ +@Slf4j +public class redeployCommand implements SlashCommandHandler { + @Override + public ReplyAction handle(SlashCommandEvent event) { + log.warn("Redeploying... Requested by: " + event.getUser().getAsTag()); + event.reply("Redeploying... this can take up to 2 Minutes.").queue(); + System.exit(0); + return null; + } +} \ No newline at end of file diff --git a/src/main/resources/commands/staff.yaml b/src/main/resources/commands/staff.yaml index 48abc8acd..173b94d59 100644 --- a/src/main/resources/commands/staff.yaml +++ b/src/main/resources/commands/staff.yaml @@ -136,6 +136,15 @@ id: moderation.staffRoleId handler: net.javadiscord.javabot.systems.staff.SayCommand +# /redeploy +- name: redeploy + description: Makes the bot redeploy + enabledByDefault: false + privileges: + - type: ROLE + id: moderation.staffRoleId + handler: net.javadiscord.javabot.systems.staff.redeployCommand + # /kick - name: kick description: Kicks a member From db8ed8713b0d6384a90e2ba4e892137f9bfd780b Mon Sep 17 00:00:00 2001 From: MoonTM Date: Mon, 31 Jan 2022 13:04:10 +0100 Subject: [PATCH 2/3] Added link to this PR to explain service/script setup --- .../net/javadiscord/javabot/systems/staff/redeployCommand.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java b/src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java index e5eafcb5e..a5a7d4d28 100644 --- a/src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java +++ b/src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java @@ -10,6 +10,8 @@ * * This only works if the way the bot is hosted is set up correctly, for example with a bash script that handles * compilation and a service set up with that bash script running before the bot gets started. + * + * I have explained how we do it in https://github.com/Java-Discord/JavaBot/pull/195 */ @Slf4j public class redeployCommand implements SlashCommandHandler { From 6749e5b76a0969e28f78f9838a8273d9229f1889 Mon Sep 17 00:00:00 2001 From: MoonTM Date: Mon, 31 Jan 2022 13:18:38 +0100 Subject: [PATCH 3/3] Fix capitalization of RedeployCommand class --- .../staff/{redeployCommand.java => RedeployCommand.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/net/javadiscord/javabot/systems/staff/{redeployCommand.java => RedeployCommand.java} (93%) diff --git a/src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java b/src/main/java/net/javadiscord/javabot/systems/staff/RedeployCommand.java similarity index 93% rename from src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java rename to src/main/java/net/javadiscord/javabot/systems/staff/RedeployCommand.java index a5a7d4d28..a32301dab 100644 --- a/src/main/java/net/javadiscord/javabot/systems/staff/redeployCommand.java +++ b/src/main/java/net/javadiscord/javabot/systems/staff/RedeployCommand.java @@ -14,7 +14,7 @@ * I have explained how we do it in https://github.com/Java-Discord/JavaBot/pull/195 */ @Slf4j -public class redeployCommand implements SlashCommandHandler { +public class RedeployCommand implements SlashCommandHandler { @Override public ReplyAction handle(SlashCommandEvent event) { log.warn("Redeploying... Requested by: " + event.getUser().getAsTag());