All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.neoforged.camelot.log.message.MessageData Maven / Gradle / Ivy

There is a newer version: 1.0.177
Show newest version
package net.neoforged.camelot.log.message;

import net.dv8tion.jda.api.entities.Message;
import org.jetbrains.annotations.Nullable;

// TODO - image attachments
public record MessageData(long id, String content, long author, String authorUsername, String authorAvatar,
                          long channel, @Nullable Long interactionAuthor) {
    public static MessageData from(Message message) {
        final long id = message.getIdLong();
        final String content = message.getContentRaw();
        final long authorId = message.getAuthor().getIdLong();
        final long channelId = message.getChannel().getIdLong();
        final String authorName = message.getMember() == null ? message.getAuthor().getName() : message.getMember().getEffectiveName();
        final String authorAvatar = message.getMember() == null ? message.getAuthor().getEffectiveAvatarUrl() : message.getMember().getEffectiveAvatarUrl();
        return new MessageData(id, content, authorId, authorName, authorAvatar, channelId, message.getInteraction() == null ? null : message.getInteraction().getUser().getIdLong());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy