-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to listen for replies to specific messages
- Loading branch information
1 parent
242a25f
commit 954d789
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
javacord-api/src/main/java/org/javacord/api/event/message/MessageReplyEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.javacord.api.event.message; | ||
|
||
import org.javacord.api.entity.message.Message; | ||
|
||
/** | ||
* A message reply event. | ||
*/ | ||
public interface MessageReplyEvent extends CertainMessageEvent { | ||
|
||
/** | ||
* Gets the message referenced by the message of this event. | ||
* | ||
* @return The message which was referenced. | ||
*/ | ||
Message getReferencedMessage(); | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
javacord-api/src/main/java/org/javacord/api/listener/message/MessageReplyListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.javacord.api.listener.message; | ||
|
||
import org.javacord.api.event.message.MessageReplyEvent; | ||
import org.javacord.api.listener.GloballyAttachableListener; | ||
import org.javacord.api.listener.ObjectAttachableListener; | ||
import org.javacord.api.listener.channel.TextChannelAttachableListener; | ||
import org.javacord.api.listener.server.ServerAttachableListener; | ||
import org.javacord.api.listener.user.UserAttachableListener; | ||
import org.javacord.api.listener.webhook.WebhookAttachableListener; | ||
|
||
/** | ||
* This listener listens to message replies. | ||
*/ | ||
@FunctionalInterface | ||
public interface MessageReplyListener extends ServerAttachableListener, UserAttachableListener, | ||
WebhookAttachableListener, TextChannelAttachableListener, MessageAttachableListener, | ||
GloballyAttachableListener, ObjectAttachableListener { | ||
|
||
/** | ||
* This method is called when a message is created which replies to another. | ||
* | ||
* @param event The event. | ||
*/ | ||
void onMessageReply(MessageReplyEvent event); | ||
} |
29 changes: 29 additions & 0 deletions
29
javacord-core/src/main/java/org/javacord/core/event/message/MessageReplyEventImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.javacord.core.event.message; | ||
|
||
import org.javacord.api.entity.message.Message; | ||
import org.javacord.api.event.message.MessageReplyEvent; | ||
|
||
/** | ||
* The implementation of {@link MessageReplyEvent}. | ||
*/ | ||
public class MessageReplyEventImpl extends CertainMessageEventImpl implements MessageReplyEvent { | ||
|
||
private final Message referencedMessage; | ||
|
||
/** | ||
* Creates a new event instance. | ||
* | ||
* @param message The created message. | ||
* @param referencedMessage The message which is being replied to. | ||
*/ | ||
public MessageReplyEventImpl(Message message, Message referencedMessage) { | ||
super(message); | ||
this.referencedMessage = referencedMessage; | ||
} | ||
|
||
@Override | ||
public Message getReferencedMessage() { | ||
return referencedMessage; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters