Search in sources :

Example 1 with MessageAttachment

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

the class MessageBuilderBaseDelegateImpl method copy.

/**
 * Fill the builder's values with a message.
 *
 * @param message The message to copy.
 */
@Override
public void copy(Message message) {
    this.getStringBuilder().append(message.getContent());
    message.getEmbeds().forEach(embed -> addEmbed(embed.toBuilder()));
    for (MessageAttachment attachment : message.getAttachments()) {
        // Since spoiler status is encoded in the file name, it is copied automatically.
        this.addAttachment(attachment.getUrl());
    }
    for (HighLevelComponent component : message.getComponents()) {
        if (component.getType() == ComponentType.ACTION_ROW) {
            ActionRowBuilder builder = new ActionRowBuilder();
            builder.copy((ActionRow) component);
            this.addComponents(builder.build());
        }
    }
    contentChanged = false;
    componentsChanged = false;
    attachmentsChanged = false;
    embedsChanged = false;
}
Also used : HighLevelComponent(org.javacord.api.entity.message.component.HighLevelComponent) ActionRowBuilder(org.javacord.api.entity.message.component.ActionRowBuilder) MessageAttachment(org.javacord.api.entity.message.MessageAttachment)

Aggregations

MessageAttachment (org.javacord.api.entity.message.MessageAttachment)1 ActionRowBuilder (org.javacord.api.entity.message.component.ActionRowBuilder)1 HighLevelComponent (org.javacord.api.entity.message.component.HighLevelComponent)1