diff --git a/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/CreateEmojiRequest.java b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/CreateEmojiRequest.java new file mode 100644 index 00000000..c25c33e8 --- /dev/null +++ b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/CreateEmojiRequest.java @@ -0,0 +1,27 @@ +package com.javadiscord.jdi.internal.api.impl.emojis; + +import com.javadiscord.jdi.internal.api.DiscordRequest; +import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; + +import java.util.List; +import java.util.Map; + +public record CreateEmojiRequest( + long guildId, + String name, + String image, // https://discord.com/developers/docs/reference#image-data + List roles) + implements DiscordRequest { + + @Override + public DiscordRequestBuilder create() { + return new DiscordRequestBuilder() + .post() + .path("/guilds/%s/emojis".formatted(guildId)) + .body( + Map.of( + "name", name, + "image", image, + "roles", roles)); + } +} diff --git a/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/DeleteEmojiRequest.java b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/DeleteEmojiRequest.java new file mode 100644 index 00000000..6ded5419 --- /dev/null +++ b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/DeleteEmojiRequest.java @@ -0,0 +1,14 @@ +package com.javadiscord.jdi.internal.api.impl.emojis; + +import com.javadiscord.jdi.internal.api.DiscordRequest; +import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; + +public record DeleteEmojiRequest(long guildId, long emojiId) implements DiscordRequest { + + @Override + public DiscordRequestBuilder create() { + return new DiscordRequestBuilder() + .delete() + .path("/guilds/%s/emojis/%s".formatted(guildId, emojiId)); + } +} diff --git a/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/GetEmojiRequest.java b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/GetEmojiRequest.java new file mode 100644 index 00000000..f512504e --- /dev/null +++ b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/GetEmojiRequest.java @@ -0,0 +1,14 @@ +package com.javadiscord.jdi.internal.api.impl.emojis; + +import com.javadiscord.jdi.internal.api.DiscordRequest; +import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; + +public record GetEmojiRequest(long guildId, long emojiId) implements DiscordRequest { + + @Override + public DiscordRequestBuilder create() { + return new DiscordRequestBuilder() + .get() + .path("/guilds/%s/emojis/%s".formatted(guildId, emojiId)); + } +} diff --git a/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/GetEmojisRequest.java b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/GetEmojisRequest.java new file mode 100644 index 00000000..8903951f --- /dev/null +++ b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/GetEmojisRequest.java @@ -0,0 +1,12 @@ +package com.javadiscord.jdi.internal.api.impl.emojis; + +import com.javadiscord.jdi.internal.api.DiscordRequest; +import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; + +public record GetEmojisRequest(long guildId) implements DiscordRequest { + + @Override + public DiscordRequestBuilder create() { + return new DiscordRequestBuilder().get().path("/guilds/%s/emojis".formatted(guildId)); + } +} diff --git a/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/ModifyEmojiRequest.java b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/ModifyEmojiRequest.java new file mode 100644 index 00000000..4b33993b --- /dev/null +++ b/src/main/java/com/javadiscord/jdi/internal/api/impl/emojis/ModifyEmojiRequest.java @@ -0,0 +1,26 @@ +package com.javadiscord.jdi.internal.api.impl.emojis; + +import com.javadiscord.jdi.internal.api.DiscordRequest; +import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public record ModifyEmojiRequest( + long guildId, long emojiId, Optional name, Optional> roles) + implements DiscordRequest { + + @Override + public DiscordRequestBuilder create() { + Map body = new HashMap<>(); + name.ifPresent(val -> body.put("name", val)); + roles.ifPresent(val -> body.put("roles", val)); + + return new DiscordRequestBuilder() + .patch() + .path("/guilds/%s/emojis/%s".formatted(guildId, emojiId)) + .body(body); + } +} diff --git a/src/main/java/com/javadiscord/jdi/internal/models/guild/Guild.java b/src/main/java/com/javadiscord/jdi/internal/models/guild/Guild.java index bc48f6f7..7a96c99d 100644 --- a/src/main/java/com/javadiscord/jdi/internal/models/guild/Guild.java +++ b/src/main/java/com/javadiscord/jdi/internal/models/guild/Guild.java @@ -12,7 +12,7 @@ public record Guild( @JsonProperty("id") long id, @JsonProperty("name") String name, @JsonProperty("icon") String icon, - @JsonProperty("slash") String slash, + @JsonProperty("splash") String splash, @JsonProperty("discovery_splash") String discoverySplash, @JsonProperty("owner") boolean owner, @JsonProperty("ownerId") long ownerId, diff --git a/src/main/java/com/javadiscord/jdi/internal/models/guild/Role.java b/src/main/java/com/javadiscord/jdi/internal/models/guild/Role.java index 9357a31d..a095cf95 100644 --- a/src/main/java/com/javadiscord/jdi/internal/models/guild/Role.java +++ b/src/main/java/com/javadiscord/jdi/internal/models/guild/Role.java @@ -5,15 +5,15 @@ @JsonIgnoreProperties(ignoreUnknown = true) public record Role( - long id, - String name, - String color, - boolean hoist, - String icon, + @JsonProperty("id") long id, + @JsonProperty("name") String name, + @JsonProperty("color") String color, + @JsonProperty("color") boolean hoist, + @JsonProperty("icon") String icon, @JsonProperty("unicode_emoji") String unicodeEmoji, - int position, - String permissions, - boolean managed, - boolean mentionable, - Tags tags, - int flags) {} + @JsonProperty("position") int position, + @JsonProperty("permissions") String permissions, + @JsonProperty("managed") boolean managed, + @JsonProperty("mentionable") boolean mentionable, + @JsonProperty("tags") Tags tags, + @JsonProperty("flags") int flags) {}