-
-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Application Emoji (#2726)
- Loading branch information
1 parent
8ccfc56
commit 52c69c9
Showing
16 changed files
with
779 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/main/java/net/dv8tion/jda/api/entities/emoji/ApplicationEmoji.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2024 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dv8tion.jda.api.entities.emoji; | ||
|
||
import net.dv8tion.jda.api.JDA; | ||
import net.dv8tion.jda.api.entities.Icon; | ||
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#createApplicationEmoji(String, Icon) | ||
* @see JDA#retrieveApplicationEmojiById(long) | ||
* @see JDA#retrieveApplicationEmojis() | ||
*/ | ||
public interface ApplicationEmoji extends CustomEmoji | ||
{ | ||
int APPLICATION_EMOJI_CAP = 2000; | ||
|
||
/** | ||
* 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 | ||
* | ||
* @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. | ||
*/ | ||
@Nonnull | ||
@CheckReturnValue | ||
RestAction<Void> delete(); | ||
|
||
/** | ||
* 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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/main/java/net/dv8tion/jda/api/managers/ApplicationEmojiManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright 2024 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dv8tion.jda.api.managers; | ||
|
||
import net.dv8tion.jda.api.entities.emoji.ApplicationEmoji; | ||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji; | ||
|
||
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 | ||
@CheckReturnValue | ||
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 | ||
@CheckReturnValue | ||
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-{@value CustomEmoji#EMOJI_NAME_MAX_LENGTH} 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} | ||
* | ||
* @throws IllegalArgumentException | ||
* If the provided name is null, not alphanumeric, or not between 2 and {@value CustomEmoji#EMOJI_NAME_MAX_LENGTH} characters long | ||
* | ||
* @return ApplicationEmojiManager for chaining convenience. | ||
*/ | ||
@Nonnull | ||
@CheckReturnValue | ||
ApplicationEmojiManager setName(@Nonnull String name); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.