Skip to content

Commit

Permalink
Implement AuditLog Entry Create event data (#132)
Browse files Browse the repository at this point in the history
* Implement AuditLog Entry Create data

* Handle GUILD_AUDIT_LOG_ENTRY_CREATE with the new data

* bad copy and paste in guildId

* Remove unused import
  • Loading branch information
Doc94 committed Jan 29, 2023
1 parent ef953aa commit e942d3f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import discord4j.discordjson.json.AuditLogEntryData;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableAuditLogEntryCreate.class)
@JsonDeserialize(as = ImmutableAuditLogEntryCreate.class)
public interface AuditLogEntryCreate extends Dispatch, AuditLogEntryData {

static ImmutableAuditLogEntryCreate.Builder builder() {
return ImmutableAuditLogEntryCreate.builder();
}

@JsonProperty("guild_id")
Id guildId();

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public void testChannelUpdate() throws IOException {
log.info("{}", json.getData());
}

@Test
public void testAuditLogEntryCreate() throws IOException {
GatewayPayload<?> json = read("/gateway/AuditLogEntryCreate.json", new TypeReference<GatewayPayload<?>>() {});
log.info("{}", json.getData());
}

@Test
public void testGuildBanAdd() throws IOException {
GatewayPayload<?> json = read("/gateway/GuildBanAdd.json", new TypeReference<GatewayPayload<?>>() {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class PayloadDeserializer extends StdDeserializer<GatewayPayload<?>> {
dispatchTypes.put("INTEGRATION_CREATE", IntegrationCreate.class);
dispatchTypes.put("INTEGRATION_UPDATE", IntegrationUpdate.class);
dispatchTypes.put("INTEGRATION_DELETE", IntegrationDelete.class);
dispatchTypes.put("GUILD_AUDIT_LOG_ENTRY_CREATE", AuditLogEntryCreate.class);

// Ignored
dispatchTypes.put("PRESENCES_REPLACE", null);
Expand Down
27 changes: 27 additions & 0 deletions src/test/resources/gateway/AuditLogEntryCreate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"d": {
"action_type": 25,
"changes": [
{
"key": "$add",
"new_value": [
{
"id": "983184100192030760",
"name": "A role"
},
{
"id": "911398373213495346",
"name": "Another role"
}
]
}
],
"guild_id": "405699020564987914",
"id": "1063915417652973640",
"target_id": "729374111482249276",
"user_id": "729374111482249276"
},
"op": 0,
"s": 211724,
"t": "GUILD_AUDIT_LOG_ENTRY_CREATE"
}

0 comments on commit e942d3f

Please sign in to comment.