JDA icon indicating copy to clipboard operation
JDA copied to clipboard

Sticker-related in Audit Log Events

Open book000 opened this issue 3 years ago • 1 comments

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_CREATE
  • STICKER_UPDATE
  • STICKER_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);
}

book000 avatar Jul 29 '22 08:07 book000

For those who have seen this Issue: This issue has been addressed in #2198. It will be resolved in the next version.

book000 avatar Aug 02 '22 11:08 book000

Available in alpha 18

MinnDevelopment avatar Aug 21 '22 19:08 MinnDevelopment