Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message Rework #2187

Merged
merged 85 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
5051ea4
Split send and edit requests
MinnDevelopment Jul 22, 2022
88c49aa
Add builder abstraction
MinnDevelopment Jul 22, 2022
fd72e13
Add new mixin interfaces
MinnDevelopment Jul 22, 2022
87a3638
Update code for interaction replies
MinnDevelopment Jul 22, 2022
27c7138
Update webhook actions
MinnDevelopment Jul 22, 2022
f4be70a
Fix some compiler issues
MinnDevelopment Jul 22, 2022
647933a
Improve consistency with rest actions
MinnDevelopment Jul 23, 2022
8fff536
Add more conversion methods
MinnDevelopment Jul 23, 2022
b86c56d
Add support for file descriptions
MinnDevelopment Jul 23, 2022
bf2e91a
Varargs factories
MinnDevelopment Jul 23, 2022
73d934d
Replace file sending methods with FileUpload variants
MinnDevelopment Jul 23, 2022
e6509fd
Fix docs issues by removing docs
MinnDevelopment Jul 23, 2022
e2f2063
Delete MessageAction and MessageBuilder
MinnDevelopment Jul 23, 2022
c2801ce
Remove some old comments
MinnDevelopment Jul 23, 2022
fb2fe70
Rename setter
MinnDevelopment Jul 23, 2022
7a945dc
Improve checks
MinnDevelopment Jul 23, 2022
b0d9030
Delete AttachmentOption
MinnDevelopment Jul 23, 2022
76b2af0
Add some getters
MinnDevelopment Jul 23, 2022
a0f7a2f
Add FluentRestAction abstraction
MinnDevelopment Jul 23, 2022
9d22172
Make max description length a constant
MinnDevelopment Jul 23, 2022
acad294
Implement finalize in BufferedRequestBody
MinnDevelopment Jul 23, 2022
4842d4a
Add some docs to MessageRequest and MessageEditRequest
MinnDevelopment Jul 24, 2022
55e9926
Add docs for MessageCreateRequest
MinnDevelopment Jul 24, 2022
146b903
Fix copy-paste error
MinnDevelopment Jul 24, 2022
67da470
Add builder documentation
MinnDevelopment Jul 24, 2022
e5ea237
Add docs for data classes
MinnDevelopment Jul 24, 2022
5474a01
Add more docs
MinnDevelopment Jul 24, 2022
ce3388a
Add missing docs for Message
MinnDevelopment Jul 24, 2022
9663f48
Delete DataMessage and add Message#editMessageAttachments
MinnDevelopment Jul 24, 2022
1f69e75
Add SplitUtil
MinnDevelopment Jul 24, 2022
3a51c34
Use lastIndexOf
MinnDevelopment Jul 24, 2022
db07102
Iterate backwards in onChar
MinnDevelopment Jul 24, 2022
b691ff2
Fix issue with success callbacks on MessageCreate/EditAction
MinnDevelopment Jul 24, 2022
df09c72
Fix some accumulative methods not being accumulative
MinnDevelopment Jul 24, 2022
b73e9e4
Fix typo
MinnDevelopment Jul 24, 2022
58dc5e0
Fix ephemeral deferReply
MinnDevelopment Jul 24, 2022
41b769c
Improve docs for AllowedMentions
MinnDevelopment Jul 25, 2022
bc379ea
Add MessageCreateRequest#setSuppressEmbeds
MinnDevelopment Jul 25, 2022
ff9b1d9
Downgrade gateway api to version 9 until deadline
MinnDevelopment Jul 26, 2022
42c2fd1
Remove ReceivedMessage#withHook
MinnDevelopment Jul 26, 2022
44000bf
Add Message#getComponents
MinnDevelopment Jul 26, 2022
19f27d8
Make getButtons use getComponents
MinnDevelopment Jul 26, 2022
e71933e
Fix files on webhook message action and rename sendFile to sendFiles
MinnDevelopment Jul 31, 2022
bab21fd
Use try-with-resources
MinnDevelopment Jul 31, 2022
9e9c97f
Improve handling of FileUpload#close
MinnDevelopment Jul 31, 2022
e12fac6
Fix check
MinnDevelopment Jul 31, 2022
ca93e60
Add Request#cleanup to handle cancelled request cleanup
MinnDevelopment Jul 31, 2022
03d142d
Make close synchronized
MinnDevelopment Jul 31, 2022
d04df7c
Add missing docs
MinnDevelopment Jul 31, 2022
9a51f77
Add back some missing context in the docs
MinnDevelopment Jul 31, 2022
b26b777
Rename WebhookMessageAction to WebhookMessageCreateAction
MinnDevelopment Jul 31, 2022
c2b9b1e
Rename to assPoiler
MinnDevelopment Jul 31, 2022
7d76105
Add FileUpload#setName
MinnDevelopment Jul 31, 2022
020390a
Update src/main/java/net/dv8tion/jda/api/entities/Message.java
MinnDevelopment Jul 31, 2022
5706623
Update src/main/java/net/dv8tion/jda/api/entities/Message.java
MinnDevelopment Jul 31, 2022
08a63ba
Use isSet for applying edit data
MinnDevelopment Jul 31, 2022
8bd2184
Use constants for list initialization
MinnDevelopment Jul 31, 2022
1fd3f10
Use flag enum where appropriate
MinnDevelopment Jul 31, 2022
952decf
Add examples to SplitUtil
MinnDevelopment Jul 31, 2022
f720ba6
Add more docs for MessageCreateBuilder
MinnDevelopment Jul 31, 2022
7bb7c5c
Add note about mentions
MinnDevelopment Jul 31, 2022
269abfb
Make MessageEditBuilder#applyData accumulative
MinnDevelopment Aug 1, 2022
9f86bd6
Add check for app flags for message content
MinnDevelopment Aug 1, 2022
2a2e83b
Update note for resource handling
MinnDevelopment Aug 6, 2022
80be3a7
Rename replace(...) to setReplace(...)
MinnDevelopment Aug 6, 2022
e46d187
Allow suppressing embeds on edits too
MinnDevelopment Aug 6, 2022
bb048a7
Make max nonce length a constant
MinnDevelopment Aug 6, 2022
00bab0e
Make example for varargs
MinnDevelopment Aug 6, 2022
c252302
Rework allowed mentions and add MessageData interface
MinnDevelopment Aug 6, 2022
50a30ad
Merge remote-tracking branch 'origin/master' into feature/message-rework
MinnDevelopment Aug 10, 2022
f219d9b
Use flag enum
MinnDevelopment Aug 10, 2022
f685927
Remove flags check
MinnDevelopment Aug 13, 2022
406ce05
Pass payload json into createMultipartBody for webhook messages
MinnDevelopment Aug 13, 2022
851d75a
Improve consistency for multipart body requests
MinnDevelopment Aug 13, 2022
f9a102c
Remove unused data array
MinnDevelopment Aug 13, 2022
4aaf5cb
Use collections for mentions
MinnDevelopment Aug 13, 2022
68d4729
Cleanup usage of mentions and generic bounds
MinnDevelopment Aug 13, 2022
d348eab
Fix example
MinnDevelopment Aug 13, 2022
8d80b19
Add new examples
MinnDevelopment Aug 13, 2022
f823e79
Fix return type
MinnDevelopment Aug 13, 2022
4ae9376
Change the type check for mentions to UserSnowflake
MinnDevelopment Aug 13, 2022
95a1f70
Update docs for clear() and closeFiles()
MinnDevelopment Aug 13, 2022
c838479
Rename set and flags for clarity
MinnDevelopment Aug 13, 2022
4da7c59
Fix comment in docs
MinnDevelopment Aug 13, 2022
c24c591
Fix annotations
MinnDevelopment Aug 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import net.dv8tion.jda.api.exceptions.MissingAccessException;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.MessageAction;
import net.dv8tion.jda.api.requests.restaction.MessageCreateAction;
import net.dv8tion.jda.internal.utils.Checks;

import javax.annotation.CheckReturnValue;
Expand Down Expand Up @@ -423,13 +423,13 @@ default RestAction<Void> clearReactionsById(long messageId, @Nonnull Emoji emoji
* <li>If null is provided</li>
* </ul>
*
* @return {@link MessageAction}
* @return {@link MessageCreateAction}
*
* @see Sticker#fromId(long)
*/
@Nonnull
@CheckReturnValue
MessageAction sendStickers(@Nonnull Collection<? extends StickerSnowflake> stickers);
MessageCreateAction sendStickers(@Nonnull Collection<? extends StickerSnowflake> stickers);

/**
* Send up to 3 stickers in this channel.
Expand All @@ -454,13 +454,13 @@ default RestAction<Void> clearReactionsById(long messageId, @Nonnull Emoji emoji
* <li>If null is provided</li>
* </ul>
*
* @return {@link MessageAction}
* @return {@link MessageCreateAction}
*
* @see Sticker#fromId(long)
*/
@Nonnull
@CheckReturnValue
default MessageAction sendStickers(@Nonnull StickerSnowflake... stickers)
default MessageCreateAction sendStickers(@Nonnull StickerSnowflake... stickers)
{
Checks.notEmpty(stickers, "Stickers");
return sendStickers(Arrays.asList(stickers));
Expand Down
84 changes: 38 additions & 46 deletions src/main/java/net/dv8tion/jda/api/entities/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.selections.SelectMenu;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
import net.dv8tion.jda.api.requests.restaction.MessageAction;
import net.dv8tion.jda.api.requests.restaction.ThreadChannelAction;
import net.dv8tion.jda.api.requests.restaction.*;
import net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction;
import net.dv8tion.jda.api.utils.AttachmentOption;
import net.dv8tion.jda.api.utils.AttachmentProxy;
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
import net.dv8tion.jda.api.utils.messages.MessageEditData;
import net.dv8tion.jda.internal.JDAImpl;
import net.dv8tion.jda.internal.entities.ReceivedMessage;
import net.dv8tion.jda.internal.requests.FunctionalCallback;
Expand Down Expand Up @@ -117,7 +117,6 @@
* <p>More information on formatting syntax can be found in the {@link java.util.Formatter format syntax documentation}!
*
* @see MessageBuilder MessageBuilder
* @see MessageChannel#sendMessage(Message)
*
* @see MessageChannel#getIterableHistory()
* @see MessageChannel#getHistory()
Expand Down Expand Up @@ -187,6 +186,11 @@ public interface Message extends ISnowflake, Formattable
*/
int MAX_STICKER_COUNT = 3;

/**
* The maximum amount of {@link LayoutComponent LayoutComponents} that can be added to a message ({@value})
*/
int MAX_COMPONENT_COUNT = 5;

/**
* Pattern used to find instant invites in strings.
*
Expand Down Expand Up @@ -756,7 +760,7 @@ default List<Button> getButtonsByLabel(@Nonnull String label, boolean ignoreCase
*/
@Nonnull
@CheckReturnValue
MessageAction editMessage(@Nonnull CharSequence newContent);
MessageEditAction editMessage(@Nonnull CharSequence newContent);

/**
* Edits this Message's content to the provided {@link net.dv8tion.jda.api.entities.MessageEmbed MessageEmbeds}.
Expand Down Expand Up @@ -793,7 +797,7 @@ default List<Button> getButtonsByLabel(@Nonnull String label, boolean ignoreCase
*/
@Nonnull
@CheckReturnValue
MessageAction editMessageEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds);
MessageEditAction editMessageEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds);

/**
* Edits this Message's content to the provided {@link net.dv8tion.jda.api.entities.MessageEmbed MessageEmbeds}.
Expand Down Expand Up @@ -830,7 +834,7 @@ default List<Button> getButtonsByLabel(@Nonnull String label, boolean ignoreCase
*/
@Nonnull
@CheckReturnValue
default MessageAction editMessageEmbeds(@Nonnull MessageEmbed... embeds)
default MessageEditAction editMessageEmbeds(@Nonnull MessageEmbed... embeds)
{
Checks.noneNull(embeds, "MessageEmbeds");
return editMessageEmbeds(Arrays.asList(embeds));
Expand Down Expand Up @@ -888,7 +892,7 @@ default MessageAction editMessageEmbeds(@Nonnull MessageEmbed... embeds)
*/
@Nonnull
@CheckReturnValue
MessageAction editMessageComponents(@Nonnull Collection<? extends LayoutComponent> components);
MessageEditAction editMessageComponents(@Nonnull Collection<? extends LayoutComponent> components);

/**
* Edits this Message's content to the provided {@link LayoutComponent LayoutComponents}.
Expand Down Expand Up @@ -941,7 +945,7 @@ default MessageAction editMessageEmbeds(@Nonnull MessageEmbed... embeds)
*/
@Nonnull
@CheckReturnValue
default MessageAction editMessageComponents(@Nonnull LayoutComponent... components)
default MessageEditAction editMessageComponents(@Nonnull LayoutComponent... components)
{
Checks.noneNull(components, "Components");
return editMessageComponents(Arrays.asList(components));
Expand Down Expand Up @@ -994,7 +998,7 @@ default MessageAction editMessageComponents(@Nonnull LayoutComponent... componen
*/
@Nonnull
@CheckReturnValue
MessageAction editMessageFormat(@Nonnull String format, @Nonnull Object... args);
MessageEditAction editMessageFormat(@Nonnull String format, @Nonnull Object... args);

/**
* Edits this Message's content to the provided {@link net.dv8tion.jda.api.entities.Message Message}.
Expand Down Expand Up @@ -1033,7 +1037,7 @@ default MessageAction editMessageComponents(@Nonnull LayoutComponent... componen
*/
@Nonnull
@CheckReturnValue
MessageAction editMessage(@Nonnull Message newContent);
MessageEditAction editMessage(@Nonnull MessageEditData newContent);

/**
* Replies and references this message.
Expand Down Expand Up @@ -1070,9 +1074,9 @@ default MessageAction editMessageComponents(@Nonnull LayoutComponent... componen
*/
@Nonnull
@CheckReturnValue
default MessageAction replyStickers(@Nonnull Collection<? extends StickerSnowflake> stickers)
default MessageCreateAction replyStickers(@Nonnull Collection<? extends StickerSnowflake> stickers)
{
return getGuildChannel().sendStickers(stickers).reference(this);
return getGuildChannel().sendStickers(stickers).setMessageReference(this);
}

/**
Expand Down Expand Up @@ -1110,9 +1114,9 @@ default MessageAction replyStickers(@Nonnull Collection<? extends StickerSnowfla
*/
@Nonnull
@CheckReturnValue
default MessageAction replyStickers(@Nonnull StickerSnowflake... stickers)
default MessageCreateAction replyStickers(@Nonnull StickerSnowflake... stickers)
{
return getGuildChannel().sendStickers(stickers).reference(this);
return getGuildChannel().sendStickers(stickers).setMessageReference(this);
}

/**
Expand All @@ -1139,9 +1143,9 @@ default MessageAction replyStickers(@Nonnull StickerSnowflake... stickers)
*/
@Nonnull
@CheckReturnValue
default MessageAction reply(@Nonnull CharSequence content)
default MessageCreateAction reply(@Nonnull CharSequence content)
{
return getChannel().sendMessage(content).reference(this);
return getChannel().sendMessage(content).setMessageReference(this);
}

/**
Expand Down Expand Up @@ -1171,7 +1175,7 @@ default MessageAction reply(@Nonnull CharSequence content)
*/
@Nonnull
@CheckReturnValue
default MessageAction replyEmbeds(@Nonnull MessageEmbed embed, @Nonnull MessageEmbed... other)
default MessageCreateAction replyEmbeds(@Nonnull MessageEmbed embed, @Nonnull MessageEmbed... other)
{
Checks.notNull(embed, "MessageEmbeds");
Checks.noneNull(other, "MessageEmbeds");
Expand Down Expand Up @@ -1206,9 +1210,9 @@ default MessageAction replyEmbeds(@Nonnull MessageEmbed embed, @Nonnull MessageE
*/
@Nonnull
@CheckReturnValue
default MessageAction replyEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds)
default MessageCreateAction replyEmbeds(@Nonnull Collection<? extends MessageEmbed> embeds)
{
return getChannel().sendMessageEmbeds(embeds).reference(this);
return getChannel().sendMessageEmbeds(embeds).setMessageReference(this);
}

/**
Expand All @@ -1218,9 +1222,9 @@ default MessageAction replyEmbeds(@Nonnull Collection<? extends MessageEmbed> em
* <br>By default there won't be any error thrown if the referenced message does not exist.
* This behavior can be changed with {@link MessageAction#failOnInvalidReply(boolean)}.
*
* <p>For further info, see {@link MessageChannel#sendMessage(Message)} and {@link MessageAction#reference(Message)}.
* <p>For further info, see {@link MessageChannel#sendMessage(MessageCreateData)} and {@link MessageAction#reference(Message)}.
*
* @param content
* @param msg
* The content of the reply message
*
* @throws UnsupportedOperationException
Expand All @@ -1232,14 +1236,12 @@ default MessageAction replyEmbeds(@Nonnull Collection<? extends MessageEmbed> em
* If null is provided
*
* @return {@link MessageAction} Providing the {@link Message} created from this upload.
*
* @since 4.2.1
*/
@Nonnull
@CheckReturnValue
default MessageAction reply(@Nonnull Message content)
default MessageCreateAction reply(@Nonnull MessageCreateData msg)
{
return getChannel().sendMessage(content).reference(this);
return getChannel().sendMessage(msg).setMessageReference(this);
}

/**
Expand All @@ -1265,14 +1267,12 @@ default MessageAction reply(@Nonnull Message content)
* If null is provided
*
* @return {@link MessageAction} Providing the {@link Message} created from this upload.
*
* @since 4.2.1
*/
@Nonnull
@CheckReturnValue
default MessageAction replyFormat(@Nonnull String format, @Nonnull Object... args)
default MessageCreateAction replyFormat(@Nonnull String format, @Nonnull Object... args)
{
return getChannel().sendMessageFormat(format, args).reference(this);
return getChannel().sendMessageFormat(format, args).setMessageReference(this);
}

/**
Expand All @@ -1298,14 +1298,12 @@ default MessageAction replyFormat(@Nonnull String format, @Nonnull Object... arg
* If null is provided
*
* @return {@link MessageAction} Providing the {@link Message} created from this upload.
*
* @since 4.2.1
*/
@Nonnull
@CheckReturnValue
default MessageAction reply(@Nonnull File file, @Nonnull AttachmentOption... options)
default MessageCreateAction reply(@Nonnull File file, @Nonnull AttachmentOption... options)
{
return getChannel().sendFile(file, options).reference(this);
return getChannel().sendFile(file, options).setMessageReference(this);
}

/**
Expand Down Expand Up @@ -1333,14 +1331,12 @@ default MessageAction reply(@Nonnull File file, @Nonnull AttachmentOption... opt
* If null is provided
*
* @return {@link MessageAction} Providing the {@link Message} created from this upload.
*
* @since 4.2.1
*/
@Nonnull
@CheckReturnValue
default MessageAction reply(@Nonnull File data, @Nonnull String name, @Nonnull AttachmentOption... options)
default MessageCreateAction reply(@Nonnull File data, @Nonnull String name, @Nonnull AttachmentOption... options)
{
return getChannel().sendFile(data, name, options).reference(this);
return getChannel().sendFile(data, name, options).setMessageReference(this);
}

/**
Expand Down Expand Up @@ -1368,14 +1364,12 @@ default MessageAction reply(@Nonnull File data, @Nonnull String name, @Nonnull A
* If null is provided
*
* @return {@link MessageAction} Providing the {@link Message} created from this upload.
*
* @since 4.2.1
*/
@Nonnull
@CheckReturnValue
default MessageAction reply(@Nonnull InputStream data, @Nonnull String name, @Nonnull AttachmentOption... options)
default MessageCreateAction reply(@Nonnull InputStream data, @Nonnull String name, @Nonnull AttachmentOption... options)
{
return getChannel().sendFile(data, name, options).reference(this);
return getChannel().sendFile(data, name, options).setMessageReference(this);
}

/**
Expand Down Expand Up @@ -1403,14 +1397,12 @@ default MessageAction reply(@Nonnull InputStream data, @Nonnull String name, @No
* If null is provided
*
* @return {@link MessageAction} Providing the {@link Message} created from this upload.
*
* @since 4.2.1
*/
@Nonnull
@CheckReturnValue
default MessageAction reply(@Nonnull byte[] data, @Nonnull String name, @Nonnull AttachmentOption... options)
default MessageCreateAction reply(@Nonnull byte[] data, @Nonnull String name, @Nonnull AttachmentOption... options)
{
return getChannel().sendFile(data, name, options).reference(this);
return getChannel().sendFile(data, name, options).setMessageReference(this);
}

/**
Expand Down
Loading