diff --git a/src/main/java/org/togetherjava/discordbot/commands/CommandListener.java b/src/main/java/org/togetherjava/discordbot/commands/CommandListener.java index 5cbf9cd..a7b2820 100644 --- a/src/main/java/org/togetherjava/discordbot/commands/CommandListener.java +++ b/src/main/java/org/togetherjava/discordbot/commands/CommandListener.java @@ -11,6 +11,7 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import org.togetherjava.discordbot.commands.CommandContext.JdaRequestContext; +import org.togetherjava.discordbot.util.Messages; /** * A command listener for JDA. It is responsible for listening to messages an invoking commands. @@ -18,16 +19,19 @@ @Singleton public class CommandListener extends ListenerAdapter { - private JdaExecutor executor; + private final JdaExecutor executor; + private final Messages messages; /** * Creates a new command listener. * * @param executor the jda executor + * @param messages the messages container */ @Inject - public CommandListener(JdaExecutor executor) { + public CommandListener(JdaExecutor executor, Messages messages) { this.executor = executor; + this.messages = messages; } @Override @@ -44,6 +48,9 @@ public void onMessageReceived(@Nonnull MessageReceivedEvent event) { ); executor.execute(content, context); } catch (CommandNotFoundException | NoSeparatorException ignored) { + if (event.getMessage().getMentionedUsers().contains(event.getJDA().getSelfUser())) { + event.getChannel().sendMessage(messages.tr("commands.on-mention.response")).queue(); + } } catch (ParseException | AbnormalCommandResultException | CommandException e) { if (e.getCause() != null && e.getCause().getMessage() != null) { event.getChannel() diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index a96cf44..ae77e47 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -14,4 +14,6 @@ commands: usage: "ban [reason]" free: short-description: "Shows the time since the last message in help channels." - usage: "free" \ No newline at end of file + usage: "free" + on-mention: + response: "I'm available! Please use '>help' to get a list of commands." \ No newline at end of file