From 6f901aab2661242b2c1506ad7760abcfac6f98b2 Mon Sep 17 00:00:00 2001 From: Arnold Alejo Nunag Date: Wed, 2 Sep 2020 19:18:20 +0800 Subject: [PATCH] Add pong command --- .../java/sciwhiz12/janitor/commands/CommandRegistry.java | 3 ++- src/main/java/sciwhiz12/janitor/commands/PingCommand.java | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/sciwhiz12/janitor/commands/CommandRegistry.java b/src/main/java/sciwhiz12/janitor/commands/CommandRegistry.java index 37b0993..51efe1f 100644 --- a/src/main/java/sciwhiz12/janitor/commands/CommandRegistry.java +++ b/src/main/java/sciwhiz12/janitor/commands/CommandRegistry.java @@ -22,7 +22,8 @@ public class CommandRegistry extends BaseListener { super(bot); this.pattern = Pattern.compile("^" + prefix + "([A-Za-z0-9]+).*$"); - addCommand("ping", new PingCommand(this)); + addCommand("ping", new PingCommand(this, "Pong!")); + addCommand("pong", new PingCommand(this, "Ping!")); addCommand("ok", new OKCommand(this)); if (bot.getConfig().getOwnerID().isPresent()) { addCommand("shutdown", new ShutdownCommand(this, bot.getConfig().getOwnerID().get())); diff --git a/src/main/java/sciwhiz12/janitor/commands/PingCommand.java b/src/main/java/sciwhiz12/janitor/commands/PingCommand.java index 2071761..0124a56 100644 --- a/src/main/java/sciwhiz12/janitor/commands/PingCommand.java +++ b/src/main/java/sciwhiz12/janitor/commands/PingCommand.java @@ -3,12 +3,15 @@ package sciwhiz12.janitor.commands; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; public class PingCommand extends BaseCommand { - public PingCommand(CommandRegistry registry) { + private final String message; + + public PingCommand(CommandRegistry registry, String message) { super(registry); + this.message = message; } @Override public void onCommand(MessageReceivedEvent event) { - event.getMessage().getChannel().sendMessage("Pong!").queue(); + event.getMessage().getChannel().sendMessage(message).queue(); } }