Search in sources :

Example 1 with DataMessage

use of net.dv8tion.jda.internal.entities.DataMessage in project JDA by DV8FromTheWorld.

the class AllowedMentionsImpl method applyMessage.

@SuppressWarnings("ResultOfMethodCallIgnored")
public AllowedMentionsImpl applyMessage(Message message) {
    // Insert allowed mentions
    if (message instanceof DataMessage) {
        DataMessage data = (DataMessage) message;
        String[] mentionedRoles = data.getMentionedRolesWhitelist();
        String[] mentionedUsers = data.getMentionedUsersWhitelist();
        EnumSet<Message.MentionType> allowedMentions = data.getAllowedMentions();
        if (allowedMentions != null)
            allowedMentions(allowedMentions);
        mentionRoles(mentionedRoles);
        mentionUsers(mentionedUsers);
    } else {
        // Only ping everyone if the message also did
        if (message.mentionsEveryone()) {
            String content = message.getContentRaw();
            EnumSet<Message.MentionType> parse = EnumSet.noneOf(Message.MentionType.class);
            if (content.contains("@everyone"))
                parse.add(Message.MentionType.EVERYONE);
            if (content.contains("@here"))
                parse.add(Message.MentionType.HERE);
            this.parse = parse;
        } else {
            this.parse = EnumSet.noneOf(Message.MentionType.class);
        }
        this.mention(message.getMentionedUsers()).mention(message.getMentionedRoles());
    }
    return this;
}
Also used : DataMessage(net.dv8tion.jda.internal.entities.DataMessage) DataMessage(net.dv8tion.jda.internal.entities.DataMessage)

Aggregations

DataMessage (net.dv8tion.jda.internal.entities.DataMessage)1