diff --git a/Discord/src/main/java/de/com/baseband/bot/Main.java b/Discord/src/main/java/de/com/baseband/bot/Main.java index 4531476..bea2f95 100644 --- a/Discord/src/main/java/de/com/baseband/bot/Main.java +++ b/Discord/src/main/java/de/com/baseband/bot/Main.java @@ -48,6 +48,16 @@ public class Main extends ListenerAdapter { .setDefaultPermissions(DefaultMemberPermissions.DISABLED) ); + commands.addCommands( + Commands.slash("ban", "Ban the given user.") + .addOptions(new OptionData(USER, "user", "The user who's HWID we should reset.") + .setRequired(true)) + .addOptions(new OptionData(STRING, "password", "The admin password.") + .setRequired(true)) + .setGuildOnly(true) + .setDefaultPermissions(DefaultMemberPermissions.DISABLED) + ); + commands.addCommands( Commands.slash("branch", "Set branch of a given user.") .addOptions(new OptionData(USER, "user", "The user who's branch we should change.") @@ -127,6 +137,29 @@ public class Main extends ListenerAdapter { break; } + + case "ban": { + User user = event.getOption("user").getAsUser(); + String password = event.getOption("password").getAsString(); + + TCN tcn = new TCN(); + tcn.set("action", "ban"); + tcn.set("authorisation", Hasher.sha512hex(password)); + tcn.set("discord-id", user.getIdLong()); + tos.writeString(tcn.toString()); + + if(processReply(event, tis)) { + if(tis.readBoolean()) { + event.getChannel().sendMessage("Successfully banned **`" + user.getName() + "`**.").queue(); + } else { + event.getChannel().sendMessage("Successfully unbanned **`" + user.getName() + "`**.").queue(); + } + event.reply("`Success.`").setEphemeral(true).queue(); + } + + break; + } + case "list-data": { User user = event.getOption("user").getAsUser(); String password = event.getOption("password").getAsString(); diff --git a/Server/src/main/java/de/com/baseband/server/BotServiceHandler.java b/Server/src/main/java/de/com/baseband/server/BotServiceHandler.java index fc8dbfc..f19c98c 100644 --- a/Server/src/main/java/de/com/baseband/server/BotServiceHandler.java +++ b/Server/src/main/java/de/com/baseband/server/BotServiceHandler.java @@ -60,6 +60,22 @@ public class BotServiceHandler { break; } + case "ban": { + TCN user = (TCN) UserHandler.users.stream() + .filter( + a -> ((TCN) a).getLong("discord-id").equals(tcn.getLong("discord-id")) + ).findFirst().orElse(null); + + if(user != null) { + user.set("disabled", !user.getBoolean("disabled")); + tos.writeInt(201); + tos.writeBoolean(user.getBoolean("disabled")); + } else { + tos.writeInt(404); + } + break; + } + case "list-data": { TCN user = (TCN) UserHandler.users.stream() .filter(