Interface MessageAction

All Superinterfaces:
AllowedMentions<MessageAction>, Appendable, RestAction<Message>

public interface MessageAction extends RestAction<Message>, Appendable, AllowedMentions<MessageAction>
Extension of a default RestAction that allows setting message information before sending!

This is available as return type of all sendMessage/sendFile methods in MessageChannel.

When updating a Message, unset fields will be ignored by default. To override existing fields with no value (remove content) you can use override(true). Setting this to true will cause all fields to be considered and will override the Message entirely causing unset values to be removed from that message.
This can be used to remove existing embeds from a message:
message.editMessage("This message had an embed").override(true).queue()

When this RestAction has been executed all provided files will be closed. If you decide not to execute this action, you should call clearFiles() to free resources.
Note that the garbage collector also frees opened file streams when it finalizes the stream object.

Example


 @Override
  public void onMessageReceived(MessageReceivedEvent event)
  {
      MessageChannel channel = event.getChannel();
      channel.sendMessage("This has an embed with an image!")
             .addFile(new File("dog.png"))
             .setEmbeds(new EmbedBuilder()
                 .setImage("attachment://dog.png")
                 .build())
             .queue(); // this actually sends the information to discord
  }
 
Since:
3.4.0
See Also: