Skip to content

Commit

Permalink
Implement termination command
Browse files Browse the repository at this point in the history
  • Loading branch information
Aizistral committed Sep 7, 2024
1 parent 1005cb8 commit af7843f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/main/java/com/aizistral/infmachine/InfiniteMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public class InfiniteMachine extends ListenerAdapter {
private InfiniteMachine() {
this.startupTime = System.currentTimeMillis();
this.domain = null;

Bootstrap.JDA.addEventListener(this);
}

public String getVersion() {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/aizistral/infmachine/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

public interface Command {

public String getName();

public SlashCommandData getData();

public void onEvent(SlashCommandInteractionEvent event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.Map;

import com.aizistral.infmachine.Bootstrap;
import com.aizistral.infmachine.commands.impl.KillCommand;
import com.aizistral.infmachine.commands.impl.PingCommand;
import com.aizistral.infmachine.config.Localization;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
Expand All @@ -30,6 +32,7 @@ private CommandRegistry() {

private void populate() {
this.register(new PingCommand());
this.register(new KillCommand());
}

private void register(Command command) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.aizistral.infmachine.commands.impl;

import com.aizistral.infmachine.InfiniteMachine;
import com.aizistral.infmachine.commands.Command;
import com.aizistral.infmachine.config.Localization;

import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
import net.dv8tion.jda.api.interactions.commands.build.Commands;
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;

public class KillCommand implements Command {

@Override
public SlashCommandData getData() {
return Commands.slash("terminate", Localization.get("cmd.terminate.desc"))
.setDefaultPermissions(DefaultMemberPermissions.DISABLED);
}

@Override
public void onEvent(SlashCommandInteractionEvent event) {
event.reply(Localization.get("msg.termination")).queue(hook -> {
InfiniteMachine.INSTANCE.terminate();
});
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.aizistral.infmachine.commands;
package com.aizistral.infmachine.commands.impl;

import com.aizistral.infmachine.commands.Command;
import com.aizistral.infmachine.config.Localization;

import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
Expand All @@ -8,11 +9,6 @@

public class PingCommand implements Command {

@Override
public String getName() {
return "ping";
}

@Override
public SlashCommandData getData() {
return Commands.slash("ping", Localization.get("cmd.ping.desc"));
Expand Down

0 comments on commit af7843f

Please # to comment.