-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
Application hosted Emoji support #2712
Changes from all commits
e7a99f7
fef5347
fd4bec1
dac7087
5105d1b
8d0f45c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -23,6 +23,7 @@ | |||||||
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel; | ||||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; | ||||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; | ||||||||
import net.dv8tion.jda.api.entities.emoji.ApplicationEmoji; | ||||||||
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji; | ||||||||
import net.dv8tion.jda.api.entities.sticker.*; | ||||||||
import net.dv8tion.jda.api.events.GenericEvent; | ||||||||
|
@@ -1747,6 +1748,44 @@ default List<RichCustomEmoji> getEmojisByName(@Nonnull String name, boolean igno | |||||||
return getEmojiCache().getElementsByName(name, ignoreCase); | ||||||||
} | ||||||||
|
||||||||
@Nonnull | ||||||||
@CheckReturnValue | ||||||||
RestAction<ApplicationEmoji> createApplicationEmoji(@Nonnull String name, @Nonnull Icon icon); | ||||||||
|
||||||||
@CheckReturnValue | ||||||||
RestAction<List<ApplicationEmoji>> retrieveApplicationEmojis(); | ||||||||
|
||||||||
@Nullable | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
@CheckReturnValue | ||||||||
RestAction<ApplicationEmoji> retrieveApplicationEmojiById(long emojiId); | ||||||||
|
||||||||
@Nullable | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
@CheckReturnValue | ||||||||
default RestAction<ApplicationEmoji> retrieveApplicationEmojiById(@Nonnull String emojiId) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||
{ | ||||||||
return retrieveApplicationEmojiById(MiscUtil.parseSnowflake(emojiId)); | ||||||||
} | ||||||||
|
||||||||
@Nullable | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
@CheckReturnValue | ||||||||
RestAction<ApplicationEmoji> updateApplicationEmojiName(long emojiId, @Nonnull String name); | ||||||||
|
||||||||
@Nullable | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
@CheckReturnValue | ||||||||
default RestAction<ApplicationEmoji> updateApplicationEmojiName(@Nonnull String emojiId, @Nonnull String name) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||
{ | ||||||||
return updateApplicationEmojiName(MiscUtil.parseSnowflake(emojiId), name); | ||||||||
} | ||||||||
|
||||||||
@CheckReturnValue | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
RestAction<Void> deleteApplicationEmojiById(long emojiId); | ||||||||
|
||||||||
@CheckReturnValue | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
default RestAction<Void> deleteApplicationEmojiById(@Nonnull String emojiId) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||
{ | ||||||||
return deleteApplicationEmojiById(MiscUtil.parseSnowflake(emojiId)); | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
* Attempts to retrieve a {@link Sticker} object based on the provided snowflake reference. | ||||||||
* <br>This works for both {@link StandardSticker} and {@link GuildSticker}, and you can resolve them using the provided {@link StickerUnion}. | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,62 @@ | ||||||||||||||
package net.dv8tion.jda.api.entities.emoji; | ||||||||||||||
|
||||||||||||||
import net.dv8tion.jda.api.JDA; | ||||||||||||||
import net.dv8tion.jda.api.entities.User; | ||||||||||||||
import net.dv8tion.jda.api.managers.ApplicationEmojiManager; | ||||||||||||||
import net.dv8tion.jda.api.requests.RestAction; | ||||||||||||||
|
||||||||||||||
import javax.annotation.CheckReturnValue; | ||||||||||||||
import javax.annotation.Nonnull; | ||||||||||||||
import javax.annotation.Nullable; | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* Represents a Custom Emoji hosted on the Bot Account. | ||||||||||||||
* | ||||||||||||||
* <p><b>This does not represent unicode emojis like they are used in the official client! | ||||||||||||||
* The format {@code :smiley:} is a client-side alias which is replaced by the unicode emoji, not a custom emoji.</b> | ||||||||||||||
* | ||||||||||||||
* @see JDA#retrieveApplicationEmojiById(long) | ||||||||||||||
* @see JDA#retrieveApplicationEmojis() | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps also add |
||||||||||||||
*/ | ||||||||||||||
public interface ApplicationEmoji extends CustomEmoji | ||||||||||||||
{ | ||||||||||||||
/** | ||||||||||||||
* The {@link net.dv8tion.jda.api.JDA JDA} instance of this emoji | ||||||||||||||
* | ||||||||||||||
* @return The JDA instance of this emoji | ||||||||||||||
*/ | ||||||||||||||
@Nonnull | ||||||||||||||
JDA getJDA(); | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* The user who created this emoji | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably tell when this is null, which to my knowledge is only after creating it |
||||||||||||||
* | ||||||||||||||
* @return The user who created this emoji | ||||||||||||||
*/ | ||||||||||||||
@Nullable | ||||||||||||||
User getOwner(); | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* Deletes this emoji. | ||||||||||||||
* | ||||||||||||||
* <p>Possible ErrorResponses include: | ||||||||||||||
* <ul> | ||||||||||||||
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI} | ||||||||||||||
* <br>If this emoji was already removed</li> | ||||||||||||||
* </ul> | ||||||||||||||
* | ||||||||||||||
* @return {@link net.dv8tion.jda.api.requests.RestAction RestAction} | ||||||||||||||
* The RestAction to delete this emoji. | ||||||||||||||
*/ | ||||||||||||||
RestAction<Void> delete(); | ||||||||||||||
Comment on lines
+50
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* The {@link ApplicationEmojiManager Manager} for this emoji, used to modify | ||||||||||||||
* properties of the emoji like name. | ||||||||||||||
* | ||||||||||||||
* @return The ApplicationEmojiManager for this emoji | ||||||||||||||
*/ | ||||||||||||||
@Nonnull | ||||||||||||||
@CheckReturnValue | ||||||||||||||
ApplicationEmojiManager getManager(); | ||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package net.dv8tion.jda.api.managers; | ||
|
||
import net.dv8tion.jda.api.entities.emoji.ApplicationEmoji; | ||
|
||
import javax.annotation.CheckReturnValue; | ||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Manager providing functionality to update the name field for an {@link ApplicationEmoji}. | ||
* | ||
* <p><b>Example</b> | ||
* <pre>{@code | ||
* manager.setName("minn") | ||
* .queue(); | ||
* }</pre> | ||
* | ||
* @see ApplicationEmoji#getManager() | ||
*/ | ||
public interface ApplicationEmojiManager extends Manager<ApplicationEmojiManager> | ||
{ | ||
/** Used to reset the name field */ | ||
long NAME = 1; | ||
|
||
/** | ||
* Resets the fields specified by the provided bit-flag pattern. | ||
* You can specify a combination by using a bitwise OR concat of the flag constants. | ||
* | ||
* <p><b>Flag Constants:</b> | ||
* <ul> | ||
* <li>{@link #NAME}</li> | ||
* </ul> | ||
* | ||
* @param fields | ||
* Integer value containing the flags to reset. | ||
* | ||
* @return ApplicationEmojiManager for chaining convenience. | ||
*/ | ||
@Nonnull | ||
@Override | ||
ApplicationEmojiManager reset(long fields); | ||
|
||
/** | ||
* Resets the fields specified by the provided bit-flag patterns. | ||
* | ||
* <p><b>Flag Constants:</b> | ||
* <ul> | ||
* <li>{@link #NAME}</li> | ||
* </ul> | ||
* | ||
* @param fields | ||
* Integer values containing the flags to reset. | ||
* | ||
* @return ApplicationEmojiManager for chaining convenience. | ||
*/ | ||
@Nonnull | ||
@Override | ||
ApplicationEmojiManager reset(long... fields); | ||
|
||
/** | ||
* The target {@link ApplicationEmoji} that will be modified by this Manager | ||
* | ||
* @return The target emoji | ||
*/ | ||
@Nonnull | ||
ApplicationEmoji getEmoji(); | ||
|
||
/** | ||
* Sets the <b><u>name</u></b> of the selected {@link ApplicationEmoji}. | ||
* | ||
* <p>An emoji name <b>must</b> be between 2-32 characters long! | ||
* <br>Emoji names may only be populated with alphanumeric (with underscore and dash). | ||
* | ||
* <p><b>Example</b>: {@code tatDab} or {@code fmgSUP} | ||
* | ||
* @param name | ||
* The new name for the selected {@link ApplicationEmoji} | ||
* | ||
* @return ApplicationEmojiManager for chaining convenience. | ||
*/ | ||
@Nonnull | ||
@CheckReturnValue | ||
ApplicationEmojiManager setName(@Nonnull String name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.