Search in sources :

Example 1 with MessageAuthor

use of org.javacord.api.entity.message.MessageAuthor in project Javacord by BtoBastian.

the class MessageCreateHandler method handle.

private void handle(TextChannel channel, JsonNode packet) {
    Message message = api.getOrCreateMessage(channel, packet);
    MessageCreateEvent event = new MessageCreateEventImpl(message);
    Optional<Server> optionalServer = channel.asServerChannel().map(ServerChannel::getServer);
    MessageAuthor author = message.getAuthor();
    api.getEventDispatcher().dispatchMessageCreateEvent(optionalServer.map(DispatchQueueSelector.class::cast).orElse(api), optionalServer.orElse(null), channel, author.asUser().orElse(null), author.isWebhook() ? author.getId() : null, event);
}
Also used : MessageCreateEvent(org.javacord.api.event.message.MessageCreateEvent) Message(org.javacord.api.entity.message.Message) MessageCreateEventImpl(org.javacord.core.event.message.MessageCreateEventImpl) Server(org.javacord.api.entity.server.Server) MessageAuthor(org.javacord.api.entity.message.MessageAuthor) ServerChannel(org.javacord.api.entity.channel.ServerChannel) DispatchQueueSelector(org.javacord.core.util.event.DispatchQueueSelector)

Aggregations

ServerChannel (org.javacord.api.entity.channel.ServerChannel)1 Message (org.javacord.api.entity.message.Message)1 MessageAuthor (org.javacord.api.entity.message.MessageAuthor)1 Server (org.javacord.api.entity.server.Server)1 MessageCreateEvent (org.javacord.api.event.message.MessageCreateEvent)1 MessageCreateEventImpl (org.javacord.core.event.message.MessageCreateEventImpl)1 DispatchQueueSelector (org.javacord.core.util.event.DispatchQueueSelector)1