Skip to content
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

added models #43

Merged
merged 9 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.javadiscord.jdi.internal.gateway.GatewayEvent;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventDecoder;
import com.javadiscord.jdi.internal.models.channel.Thread;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.Thread;

public class ThreadDecoder implements EventDecoder<Thread> {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.javadiscord.jdi.internal.gateway.GatewayEvent;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventDecoder;
import com.javadiscord.jdi.internal.models.channel.ThreadSync;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.ThreadSync;

public class ThreadListSyncDecoder implements EventDecoder<ThreadSync> {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.javadiscord.jdi.internal.gateway.GatewayEvent;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventDecoder;
import com.javadiscord.jdi.internal.models.channel.ThreadMember;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.ThreadMember;

public class ThreadMemberDecoder implements EventDecoder<ThreadMember> {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.javadiscord.jdi.internal.gateway.GatewayEvent;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventDecoder;
import com.javadiscord.jdi.internal.models.channel.ThreadMemberUpdate;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.ThreadMemberUpdate;

public class ThreadMemberUpdateDecoder implements EventDecoder<ThreadMemberUpdate> {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.javadiscord.jdi.core.Discord;
import com.javadiscord.jdi.internal.gateway.ConnectionMediator;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventHandler;
import com.javadiscord.jdi.internal.models.channel.Thread;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.Thread;

public class ThreadCreateHandler implements EventHandler<Thread> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.javadiscord.jdi.core.Discord;
import com.javadiscord.jdi.internal.gateway.ConnectionMediator;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventHandler;
import com.javadiscord.jdi.internal.models.channel.Thread;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.Thread;

public class ThreadDeleteHandler implements EventHandler<Thread> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.javadiscord.jdi.core.Discord;
import com.javadiscord.jdi.internal.gateway.ConnectionMediator;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventHandler;
import com.javadiscord.jdi.internal.models.channel.ThreadSync;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.ThreadSync;

public class ThreadListSyncHandler implements EventHandler<ThreadSync> {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.javadiscord.jdi.core.Discord;
import com.javadiscord.jdi.internal.gateway.ConnectionMediator;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventHandler;
import com.javadiscord.jdi.internal.models.channel.ThreadMember;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.ThreadMember;

public class ThreadMemberHandler implements EventHandler<ThreadMember> {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.javadiscord.jdi.core.Discord;
import com.javadiscord.jdi.internal.gateway.ConnectionMediator;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventHandler;
import com.javadiscord.jdi.internal.models.channel.ThreadMemberUpdate;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.ThreadMemberUpdate;

public class ThreadMemberUpdateHandler implements EventHandler<ThreadMemberUpdate> {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.javadiscord.jdi.core.Discord;
import com.javadiscord.jdi.internal.gateway.ConnectionMediator;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.EventHandler;
import com.javadiscord.jdi.internal.models.channel.Thread;
import com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel.Thread;

public class ThreadUpdateHandler implements EventHandler<Thread> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.javadiscord.jdi.internal.models.channel;
package com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.javadiscord.jdi.internal.models.channel.ThreadMetadata;

@JsonIgnoreProperties(ignoreUnknown = true)
public record Thread(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public record ThreadMember(
@JsonProperty("id") long id,
@JsonProperty("guild_id") long guildId,
@JsonProperty("member_count") int memberCount,
@JsonProperty("added_members") List<ThreadMember> addedMembers,
@JsonProperty("removed_member_ids") List<Long> removedMemberIds) {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.javadiscord.jdi.internal.models.channel;
package com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.javadiscord.jdi.internal.models.channel;
package com.javadiscord.jdi.internal.gateway.handlers.events.codec.models.channel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.javadiscord.jdi.internal.models.channel.Channel;
import com.javadiscord.jdi.internal.models.user.Member;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public record ThreadSync(
@JsonProperty("guild_id") String guildId,
@JsonProperty("channel_ids") long[] channelIds,
@JsonProperty("channel_ids") List<Long> channelIds,
List<Channel> threads,
List<Member> members) {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public record Channel(
@JsonProperty("topic") String topic,
@JsonProperty("nsfw") boolean nsfw,
@JsonProperty("last_message_id") long lastMessageId,
@JsonProperty("bitRate") int bitRate,
@JsonProperty("bitrate") int bitrate,
@JsonProperty("user_limit") int userLimit,
@JsonProperty("rate_limit_per_user") int rateLimitPerUser,
@JsonProperty("recipients") List<User> recipients,
Expand All @@ -31,4 +31,15 @@ public record Channel(
@JsonProperty("video_quality_mode") int videoQualityMode,
@JsonProperty("message_count") int messageCount,
@JsonProperty("member_count") int memberCount,
@JsonProperty("thread_metadata") ThreadMetadata threadMetadata) {}
@JsonProperty("thread_metadata") ThreadMetadata threadMetadata,
@JsonProperty("member") ThreadMember member,
@JsonProperty("default_auto_archive_duration") int defaultAutoArchiveDuration,
@JsonProperty("permissions") String permissions,
@JsonProperty("flags") int flags,
@JsonProperty("total_message_sent") int threadMessageSent,
@JsonProperty("available_tags") List<ForumTag> availableTags,
@JsonProperty("applied_tags") List<Long> appliedTags,
@JsonProperty("default_reaction_emoji") DefaultReaction defaultReactionEmoji,
@JsonProperty("default_thread_rate_limit_per_user") int defaultThreadRateLimitPerUser,
@JsonProperty("default_sort_order") int defaultSortOrder,
@JsonProperty("default_forum_layout") int defaultForumLayout) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.javadiscord.jdi.internal.models.channel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
public record DefaultReaction(
@JsonProperty("emoji_id") long emojiId, @JsonProperty("emoji_name") String emojiName) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.javadiscord.jdi.internal.models.channel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
public record ForumTag(
@JsonProperty("id") long id,
@JsonProperty("name") String name,
@JsonProperty("moderated") boolean moderated,
@JsonProperty("emoji_id") long emojiId,
@JsonProperty("emoji_name") String emojiName) {}
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.javadiscord.jdi.internal.models.channel;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.javadiscord.jdi.internal.models.guild.Member;

import java.util.List;
import java.time.OffsetDateTime;

@JsonIgnoreProperties(ignoreUnknown = true)
public record ThreadMember(
@JsonProperty("id") long id,
@JsonProperty("guild_id") long guildId,
@JsonProperty("member_count") int memberCount,
@JsonProperty("added_members") List<ThreadMember> addedMembers,
@JsonProperty("removed_member_ids") long[] removedMemberIds) {}
@JsonProperty("id") long threadId,
@JsonProperty("user_id") long userId,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
@JsonProperty("join_timestamp")
OffsetDateTime joinTime,
@JsonProperty("flags") int flags,
@JsonProperty("member") Member member) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.javadiscord.jdi.internal.models.guild;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.javadiscord.jdi.internal.models.user.User;

import java.time.OffsetDateTime;

// TODO: finish implementation
// https://discord.com/developers/docs/resources/guild#integration-object
@JsonIgnoreProperties(ignoreUnknown = true)
public record Integration(
@JsonProperty("id") long id,
@JsonProperty("name") String name,
@JsonProperty("type") String type,
@JsonProperty("enabled") boolean enabled,
@JsonProperty("syncing") boolean syncing,
@JsonProperty("role_id") long roleId,
@JsonProperty("enable_emoticons") boolean enableEmoticons,
@JsonProperty("expire_behaviour") int expireBehaviour,
@JsonProperty("expire_grace_period") int expireGracePeriod,
@JsonProperty("user") User user,
@JsonProperty("account") IntegrationAccount account,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
@JsonProperty("synced_at")
OffsetDateTime syncedAt,
@JsonProperty("subscriber_count") int subscriberCount,
@JsonProperty("revoked") boolean revoked,
@JsonProperty("application") IntegrationApplication application) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.javadiscord.jdi.internal.models.guild;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
public record IntegrationAccount(
@JsonProperty("id") String id, @JsonProperty("name") String name) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.javadiscord.jdi.internal.models.guild;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.javadiscord.jdi.internal.models.user.User;

@JsonIgnoreProperties(ignoreUnknown = true)
public record IntegrationApplication(
@JsonProperty("id") long id,
@JsonProperty("name") String name,
@JsonProperty("icon") String icon,
@JsonProperty("description") String description,
@JsonProperty("bot") User bot) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.javadiscord.jdi.internal.models.guild;

public enum IntegrationExpireBehaviour {
REMOVE_ROLE(0),
KICK(1);

private final int value;

private IntegrationExpireBehaviour(int value) {
this.value = value;
}

public int value() {
return value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.javadiscord.jdi.internal.models.guild;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.javadiscord.jdi.internal.models.user.User;

import java.time.OffsetDateTime;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public record Member(
@JsonProperty("user") User user,
@JsonProperty("nick") String nick,
@JsonProperty("avatar") String avatar,
@JsonProperty("roles") List<Long> roles,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
@JsonProperty("joined_at")
OffsetDateTime joinedAt,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
@JsonProperty("premium_since")
OffsetDateTime premiumSince,
@JsonProperty("deaf") boolean deaf,
@JsonProperty("mute") boolean mute,
@JsonProperty("flags") int flags,
@JsonProperty("pending") boolean pending,
@JsonProperty("permissions") String permissions,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
@JsonProperty("communication_disabled_until")
OffsetDateTime communicationDisabledUntil) {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.javadiscord.jdi.internal.models.guild.Integration;

@JsonIgnoreProperties(ignoreUnknown = true)
public record Connection(
@JsonProperty("id") String id,
@JsonProperty("name") String name,
@JsonProperty("type") String type,
@JsonProperty("revoked") boolean revoked,
// private List<?> integration;
@JsonProperty("integrations") Integration integrations,
@JsonProperty("verified") boolean verified,
@JsonProperty("friend_sync") boolean friendSync,
@JsonProperty("show_activity") boolean showActivity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ public record User(
@JsonProperty("email") String email,
@JsonProperty("flags") int flags,
@JsonProperty("premium_type") int premiumType,
@JsonProperty("public_flags") int publicFlags) {}
@JsonProperty("public_flags") int publicFlags,
@JsonProperty("avtar_decoration") String avatarDecoration) {}
Loading