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..a32301dab --- /dev/null +++ b/src/main/java/net/javadiscord/javabot/systems/staff/RedeployCommand.java @@ -0,0 +1,25 @@ +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. + * + * I have explained how we do it in https://github.com/Java-Discord/JavaBot/pull/195 + */ +@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