-
-
Notifications
You must be signed in to change notification settings - Fork 718
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
Adds support for user's avatar decorations #2668
Open
ItsTheSky
wants to merge
14
commits into
discord-jda:master
Choose a base branch
from
ItsTheSky:user-decorations
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0f90dec
Adds support for user's avatar decorations
ItsTheSky 434f9fb
Fixed AvatarDecoration's JavaDocs to be more precise
ItsTheSky 573ba58
Used streams to get the avatar decoration object
ItsTheSky d4ac641
Fixed brackets formatting & AvatarDecoration's JavaDocs
ItsTheSky 4ff7ae6
Fixed DECORATION_AVATAR_URL's field JavaDocs
ItsTheSky 6a78c63
Fixed getDecorationAvatarUrl nullability and added way to get the dec…
ItsTheSky 52a21f4
Formatted avatar decoration getter in EntityBuilder
ItsTheSky cde84c6
Used Helpers instead of String to format decoration avatar URL
ItsTheSky ba87a94
Merge branch 'discord-jda:master' into user-decorations
ItsTheSky 5eef4c8
Added events for avatar decorations update
ItsTheSky 23e7b32
Added toString method to AvatarDecoration
ItsTheSky ba3c9f1
Merge branch 'discord-jda:master' into user-decorations
ItsTheSky 3440015
Merge remote-tracking branch 'origin/user-decorations' into user-deco…
ItsTheSky 1285d43
Added support for per-member avatar decoration
ItsTheSky File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
58 changes: 58 additions & 0 deletions
58
...et/dv8tion/jda/api/events/guild/member/update/GuildMemberUpdateAvatarDecorationEvent.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,58 @@ | ||
package net.dv8tion.jda.api.events.guild.member.update; | ||
|
||
import net.dv8tion.jda.api.JDA; | ||
import net.dv8tion.jda.api.entities.Member; | ||
import net.dv8tion.jda.api.entities.User; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Indicates that a {@link net.dv8tion.jda.api.entities.Member Member} updated their {@link net.dv8tion.jda.api.entities.Guild Guild} {@link User.AvatarDecoration avatar decoration}. | ||
* | ||
* <p>Can be used to retrieve members who change their per guild avatar decoration, the triggering guild, the old avatar decoration and the new avatar decoration. | ||
* | ||
* <p>Identifier: {@code avatar_decoration} | ||
* | ||
* <p><b>Requirements</b><br> | ||
* | ||
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_MEMBERS GUILD_MEMBERS} intent to be enabled. | ||
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and | ||
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default! | ||
* | ||
* <p>Additionally, this event requires the {@link net.dv8tion.jda.api.utils.MemberCachePolicy MemberCachePolicy} | ||
* to cache the updated members. Discord does not specifically tell us about the updates, but merely tells us the | ||
* member was updated and gives us the updated member object. In order to fire a specific event like this we | ||
* need to have the old member cached to compare against. | ||
*/ | ||
public class GuildMemberUpdateAvatarDecorationEvent extends GenericGuildMemberUpdateEvent<User.AvatarDecoration> { | ||
|
||
public static final String IDENTIFIER = "avatar_decoration"; | ||
|
||
public GuildMemberUpdateAvatarDecorationEvent(@NotNull JDA api, long responseNumber, @NotNull Member member, @Nullable User.AvatarDecoration next) | ||
{ | ||
super(api, responseNumber, member, member.getAvatarDecoration(), next, IDENTIFIER); | ||
} | ||
|
||
/** | ||
* The old avatar decoration | ||
* | ||
* @return The old avatar decoration | ||
*/ | ||
@Nullable | ||
public User.AvatarDecoration getOldAvatarDecoration() | ||
{ | ||
return getOldValue(); | ||
} | ||
|
||
/** | ||
* The new avatar decoration | ||
* | ||
* @return The new avatar decoration | ||
*/ | ||
@Nullable | ||
public User.AvatarDecoration getNewAvatarDecoration() | ||
{ | ||
return getNewValue(); | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateAvatarDecorationEvent.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,55 @@ | ||
package net.dv8tion.jda.api.events.user.update; | ||
|
||
import net.dv8tion.jda.api.JDA; | ||
import net.dv8tion.jda.api.entities.User; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Indicates that the {@link net.dv8tion.jda.api.entities.User.AvatarDecoration AvatarDecoration} of a {@link net.dv8tion.jda.api.entities.User User} changed. | ||
* | ||
* <p>Can be used to retrieve the User who changed their avatar and their previous Avatar Decoration object. | ||
* | ||
* <p>Identifier: {@code avatar_decoration} | ||
* | ||
* <p><b>Requirements</b><br> | ||
* | ||
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_MEMBERS GUILD_MEMBERS} intent to be enabled. | ||
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and | ||
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default! | ||
* | ||
* <p>Additionally, this event requires the {@link net.dv8tion.jda.api.utils.MemberCachePolicy MemberCachePolicy} | ||
* to cache the updated members. Discord does not specifically tell us about the updates, but merely tells us the | ||
* member was updated and gives us the updated member object. In order to fire a specific event like this we | ||
* need to have the old member cached to compare against. | ||
*/ | ||
public class UserUpdateAvatarDecorationEvent extends GenericUserUpdateEvent<User.AvatarDecoration> | ||
{ | ||
public static final String IDENTIFIER = "avatar_decoration"; | ||
|
||
public UserUpdateAvatarDecorationEvent(@NotNull JDA api, long responseNumber, @NotNull User user, @Nullable User.AvatarDecoration oldAvatarDecoration) | ||
{ | ||
super(api, responseNumber, user, oldAvatarDecoration, user.getAvatarDecoration(), IDENTIFIER); | ||
} | ||
|
||
/** | ||
* The old avatar decoration | ||
* @return The old avatar decoration | ||
*/ | ||
@Nullable | ||
public User.AvatarDecoration getOldAvatarDecoration() | ||
{ | ||
return getOldValue(); | ||
} | ||
|
||
/** | ||
* The new avatar decoration | ||
* @return The new avatar decoration | ||
*/ | ||
@Nullable | ||
public User.AvatarDecoration getNewAvatarDecoration() | ||
{ | ||
return getNewValue(); | ||
} | ||
|
||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How is this useful to a bot?
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.
I'm not sure how for now, but maybe JDA will add support for SKU later on? Should I just remove that entirely?