JDA
JDA copied to clipboard
Sticker-related in Audit Log Events
General Troubleshooting
- [X] I have checked for similar issues on the Issue-tracker.
- [X] I have updated to the latest JDA version
- [X] I have checked the branches or the maintainers' PRs for upcoming features.
Feature Request
Thank you for developing this wonderful library.
I would like to request implementation of Sticker related ActionType in Audit Logs.
According to the Discord Developer Portal, the following Sticker-related events are available in Audit Logs Events (reference):
STICKER_CREATESTICKER_UPDATESTICKER_DELETE
These events do not appear to be implemented in JDA v5.0.0-alpha.17: net.dv8tion.jda.api.audit.ActionType
And, no Issue or PR related to this issue was found: Search sticker audit in Issue/PR
With these implemented, when a Sticker is changed, it will be possible to retrieve information from the audit log about the user who changed it.
Example Use-Case
/**
* Gets the user who recently changed the Sticker.
*
* @param sticker Target guild sticker
* @return User who changed the Sticker, or null if not found.
*/
User getChangedStickerUser(GuildSticker sticker) {
if (sticker.getGuild() == null) {
throw new IllegalArgumentException("sticker.getGuild() is null");
}
List<AuditLogEntry> entries = sticker
.getGuild()
.retrieveAuditLogs()
.type(ActionType.STICKER_UPDATE)
.limit(5)
.complete();
if (entries.isEmpty()) {
return null;
}
return entries
.stream()
.filter(entry -> entry.getTargetIdLong() == sticker.getIdLong())
.map(AuditLogEntry::getUser)
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
}
For those who have seen this Issue: This issue has been addressed in #2198. It will be resolved in the next version.
Available in alpha 18