diff --git a/Fluxer.Net/Data/Gifs/FavouriteGif.cs b/Fluxer.Net/Data/Gifs/FavoriteGif.cs similarity index 85% rename from Fluxer.Net/Data/Gifs/FavouriteGif.cs rename to Fluxer.Net/Data/Gifs/FavoriteGif.cs index 322ee75..12aa027 100644 --- a/Fluxer.Net/Data/Gifs/FavouriteGif.cs +++ b/Fluxer.Net/Data/Gifs/FavoriteGif.cs @@ -1,7 +1,7 @@ namespace Fluxer.Net; /// -public class FavouriteGif : Entity, IFavouriteGif +public class FavoriteGif : Entity, IFavoriteGif { /// public string Id { get; internal set; } @@ -54,19 +54,19 @@ public class FavouriteGif : Entity, IFavouriteGif /// public string? TenorSlugId { get; internal set; } - internal FavouriteGif(FluxerBaseClient client) : base(client) + internal FavoriteGif(FluxerBaseClient client) : base(client) { } - public static FavouriteGif Create(FluxerBaseClient client, FavouriteGifJson json) + public static FavoriteGif Create(FluxerBaseClient client, FavoriteGifJson json) { - FavouriteGif data = new FavouriteGif(client); + FavoriteGif data = new FavoriteGif(client); data.Update(client, json); return data; } - internal void Update(FluxerBaseClient client, FavouriteGifJson json) + internal void Update(FluxerBaseClient client, FavoriteGifJson json) { Id = json.Id; UserId = json.UserId; diff --git a/Fluxer.Net/Data/Gifs/FavouriteGifJson.cs b/Fluxer.Net/Data/Gifs/FavoriteGifJson.cs similarity index 97% rename from Fluxer.Net/Data/Gifs/FavouriteGifJson.cs rename to Fluxer.Net/Data/Gifs/FavoriteGifJson.cs index 668d97a..5b82adb 100644 --- a/Fluxer.Net/Data/Gifs/FavouriteGifJson.cs +++ b/Fluxer.Net/Data/Gifs/FavoriteGifJson.cs @@ -3,7 +3,7 @@ namespace Fluxer.Net; /// -public class FavouriteGifJson : IFavouriteGif +public class FavoriteGifJson : IFavoriteGif { /// [JsonProperty("id")] diff --git a/Fluxer.Net/Data/Gifs/IFavouriteGif.cs b/Fluxer.Net/Data/Gifs/IFavoriteGif.cs similarity index 98% rename from Fluxer.Net/Data/Gifs/IFavouriteGif.cs rename to Fluxer.Net/Data/Gifs/IFavoriteGif.cs index 3b17148..2d9c5c1 100644 --- a/Fluxer.Net/Data/Gifs/IFavouriteGif.cs +++ b/Fluxer.Net/Data/Gifs/IFavoriteGif.cs @@ -1,6 +1,6 @@ namespace Fluxer.Net; -public interface IFavouriteGif +public interface IFavoriteGif { /// /// Unique identifier for the favorite gif. diff --git a/Fluxer.Net/Data/Guilds/Settings/MuteConfigurationJson.cs b/Fluxer.Net/Data/Guilds/Settings/MuteConfigurationJson.cs index cd03eef..8098081 100644 --- a/Fluxer.Net/Data/Guilds/Settings/MuteConfigurationJson.cs +++ b/Fluxer.Net/Data/Guilds/Settings/MuteConfigurationJson.cs @@ -5,8 +5,8 @@ namespace Fluxer.Net; public class MuteConfigurationJson { [JsonProperty("end_time")] - public DateTime? EndTime { get; set; } + public DateTime? EndAt { get; set; } [JsonProperty("selected_time_window")] - public int? SelectedTimeWindow { get; set; } + public int? SelectedTimeSeconds { get; set; } } diff --git a/Fluxer.Net/Data/Users/IUserGuildFolder.cs b/Fluxer.Net/Data/Users/IUserGuildFolder.cs new file mode 100644 index 0000000..2756894 --- /dev/null +++ b/Fluxer.Net/Data/Users/IUserGuildFolder.cs @@ -0,0 +1,12 @@ +namespace Fluxer.Net; + +public interface IUserGuildFolder +{ + int Id { get; } + + string? Name { get; } + + int? Color { get; } + + List? GuildIds { get; } +} diff --git a/Fluxer.Net/Data/Users/IUserGuildSettings.cs b/Fluxer.Net/Data/Users/IUserGuildSettings.cs new file mode 100644 index 0000000..7020877 --- /dev/null +++ b/Fluxer.Net/Data/Users/IUserGuildSettings.cs @@ -0,0 +1,24 @@ +namespace Fluxer.Net; + +public interface IUserGuildSettings +{ + Dictionary? ChannelOverrides { get; } + + ulong GuildId { get; } + + bool HideMutedChannels { get; } + + NotificationType MessageNotifications { get; } + + bool MobilePush { get; } + + MuteConfigurationJson? MuteConfig { get; } + + bool Muted { get; } + + bool SuppressEveryone { get; } + + bool SuppressRoles { get; } + + int Version { get; } +} diff --git a/Fluxer.Net/Data/Users/IUserSettings.cs b/Fluxer.Net/Data/Users/IUserSettings.cs index 8717e20..8a2b001 100644 --- a/Fluxer.Net/Data/Users/IUserSettings.cs +++ b/Fluxer.Net/Data/Users/IUserSettings.cs @@ -106,7 +106,7 @@ public interface IUserSettings /// /// The folder structure for organizing guilds in the sidebar. /// - List? GuildFolders { get; } + List? GuildFolders { get; } /// /// The idle timeout in seconds before going AFK. diff --git a/Fluxer.Net/Data/Users/NotificationType.cs b/Fluxer.Net/Data/Users/NotificationType.cs new file mode 100644 index 0000000..c21f5b3 --- /dev/null +++ b/Fluxer.Net/Data/Users/NotificationType.cs @@ -0,0 +1,9 @@ +namespace Fluxer.Net; + +public enum NotificationType +{ + AllMessages = 0, + MentionsOnly = 1, + NoMessages = 2, + InheritParent = 3, +} diff --git a/Fluxer.Net/Data/Users/RelationshipJson.cs b/Fluxer.Net/Data/Users/RelationshipJson.cs index c2294ae..1a271ce 100644 --- a/Fluxer.Net/Data/Users/RelationshipJson.cs +++ b/Fluxer.Net/Data/Users/RelationshipJson.cs @@ -4,18 +4,15 @@ namespace Fluxer.Net; public class RelationshipJson { - [JsonProperty("source_user_id")] - public ulong SourceUserId { get; set; } - - [JsonProperty("target_user_id")] - public ulong TargetUserId { get; set; } + [JsonProperty("id")] + public ulong Id { get; set; } [JsonProperty("type")] - public int Type { get; set; } + public RelationshipType Type { get; set; } [JsonProperty("nickname")] public string? Nickname { get; set; } [JsonProperty("since")] - public DateTime? Since { get; set; } + public DateTime? SinceAt { get; set; } } diff --git a/Fluxer.Net/Data/Users/UserGuildFolder.cs b/Fluxer.Net/Data/Users/UserGuildFolderJson.cs similarity index 54% rename from Fluxer.Net/Data/Users/UserGuildFolder.cs rename to Fluxer.Net/Data/Users/UserGuildFolderJson.cs index 95fd786..75f3570 100644 --- a/Fluxer.Net/Data/Users/UserGuildFolder.cs +++ b/Fluxer.Net/Data/Users/UserGuildFolderJson.cs @@ -2,17 +2,22 @@ namespace Fluxer.Net; -public class UserGuildFolder +/// +public class UserGuildFolderJson : IUserGuildFolder { - [JsonProperty("folder_id")] - public int FolderId { get; set; } + /// + [JsonProperty("id")] + public int Id { get; set; } + /// [JsonProperty("name")] public string? Name { get; set; } + /// [JsonProperty("color")] public int? Color { get; set; } + /// [JsonProperty("guild_ids")] public List? GuildIds { get; set; } } diff --git a/Fluxer.Net/Data/Users/UserGuildSettings.cs b/Fluxer.Net/Data/Users/UserGuildSettingsJson.cs similarity index 69% rename from Fluxer.Net/Data/Users/UserGuildSettings.cs rename to Fluxer.Net/Data/Users/UserGuildSettingsJson.cs index 390fd0a..e23deb5 100644 --- a/Fluxer.Net/Data/Users/UserGuildSettings.cs +++ b/Fluxer.Net/Data/Users/UserGuildSettingsJson.cs @@ -2,38 +2,46 @@ namespace Fluxer.Net; -public class UserGuildSettings +/// +public class UserGuildSettingsJson : IUserGuildSettings { - [JsonProperty("user_id")] - public ulong UserId { get; set; } + /// + [JsonProperty("channel_overrides")] + public Dictionary? ChannelOverrides { get; set; } + /// [JsonProperty("guild_id")] public ulong GuildId { get; set; } + /// + [JsonProperty("hide_muted_channels")] + public bool HideMutedChannels { get; set; } + + /// [JsonProperty("message_notifications")] - public int? MessageNotifications { get; set; } + public NotificationType MessageNotifications { get; set; } - [JsonProperty("muted")] - public bool Muted { get; set; } + /// + [JsonProperty("mobile_push")] + public bool MobilePush { get; set; } + /// [JsonProperty("mute_config")] public MuteConfigurationJson? MuteConfig { get; set; } - [JsonProperty("mobile_push")] - public bool MobilePush { get; set; } + /// + [JsonProperty("muted")] + public bool Muted { get; set; } + /// [JsonProperty("suppress_everyone")] public bool SuppressEveryone { get; set; } + /// [JsonProperty("suppress_roles")] public bool SuppressRoles { get; set; } - [JsonProperty("hide_muted_channels")] - public bool HideMutedChannels { get; set; } - - [JsonProperty("channel_overrides")] - public Dictionary? ChannelOverrides { get; set; } - + /// [JsonProperty("version")] public int Version { get; set; } } diff --git a/Fluxer.Net/Data/Users/UserSettings.cs b/Fluxer.Net/Data/Users/UserSettings.cs index d101ad1..662aeaf 100644 --- a/Fluxer.Net/Data/Users/UserSettings.cs +++ b/Fluxer.Net/Data/Users/UserSettings.cs @@ -70,7 +70,7 @@ public class UserSettings : Entity, IUserSettings public List? GuildPositions { get; set; } /// - public List? GuildFolders { get; set; } + public List? GuildFolders { get; set; } /// public int AfkTimeout { get; set; } diff --git a/Fluxer.Net/Data/Users/UserSettingsJson.cs b/Fluxer.Net/Data/Users/UserSettingsJson.cs index 538eb3c..be2a87a 100644 --- a/Fluxer.Net/Data/Users/UserSettingsJson.cs +++ b/Fluxer.Net/Data/Users/UserSettingsJson.cs @@ -95,7 +95,7 @@ public class UserSettingsJson : IUserSettings /// [JsonProperty("guild_folders")] - public List? GuildFolders { get; set; } + public List? GuildFolders { get; set; } /// [JsonProperty("afk_timeout")] diff --git a/Fluxer.Net/FluxerNet.xml b/Fluxer.Net/FluxerNet.xml index 1a65aec..10bfafd 100644 --- a/Fluxer.Net/FluxerNet.xml +++ b/Fluxer.Net/FluxerNet.xml @@ -2267,112 +2267,112 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2447,87 +2447,87 @@ - + Unique identifier for the favorite gif. - + ID of the user who owns this favorite gif. - + Display name of the gif. - + Tags for categorizing and searching the gif. - + ID of the attachment storing the gif. - + Original filename of the gif. - + MIME type of the gif file. - + File size in bytes. - + CDN URL to access the meme. - + Alternative text description for accessibility. - + Hash of the file content for deduplication. - + Width of the image or video in pixels. - + Height of the image or video in pixels. - + Duration of the video in seconds - + Whether the gif is a video converted from GIF - + Klipy clip slug if the meme was sourced from Klipy. - + Tenor view/- identifier if the meme was sourced from Tenor. @@ -6125,6 +6125,54 @@ User's owned bot discriminators have been sanitized (internal flag) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Fluxer.Net/Gateway/Data/ReadyGatewayData.cs b/Fluxer.Net/Gateway/Data/ReadyGatewayData.cs index 6e069c7..da4c6e8 100644 --- a/Fluxer.Net/Gateway/Data/ReadyGatewayData.cs +++ b/Fluxer.Net/Gateway/Data/ReadyGatewayData.cs @@ -1,36 +1,52 @@ +using Fluxer.Net.Gateway.Data.Guilds; using Newtonsoft.Json; namespace Fluxer.Net.Gateway.Data; public class ReadyGatewayData { - [JsonProperty("members")] - public GuildMemberJson[] Members { get; set; } + [JsonProperty("v")] + public string Version { get; set; } + + [JsonProperty("auth_session_id_hash")] + public string AuthSessionIdHash { get; set; } + + [JsonProperty("country_code")] + public string CountryCode { get; set; } + + [JsonProperty("favorite_memes")] + public FavoriteGifJson[]? FavoriteMemes { get; set; } + + [JsonProperty("pinned_dms")] + public ulong[] PinnedDMs { get; set; } [JsonProperty("notes")] public Dictionary Notes { get; set; } [JsonProperty("private_channels")] - public object[] PrivateChannels { get; set; } + public ChannelJson[]? PrivateChannels { get; set; } [JsonProperty("relationships")] - public object[] Relationships { get; set; } + public RelationshipJson[] Relationships { get; set; } [JsonProperty("session_id")] public string SessionId { get; set; } + [JsonProperty("sessions")] + public GatewaySessionJson[]? Sessions { get; set; } + [JsonProperty("guilds")] - public GuildJson[] Guilds { get; set; } + public GuildGatewayData[] Guilds { get; set; } [JsonProperty("user")] - public UserJson User { get; set; } + public CurrentUserJson User { get; set; } [JsonProperty("user_settings")] - public UserSettingsJson UserSettings { get; set; } + public UserSettingsJson? UserSettings { get; set; } - [JsonProperty("v")] - public string Version { get; set; } + [JsonProperty("user_guild_settings")] + public UserGuildSettingsJson[]? UserGuildSettings { get; set; } - // [JsonProperty("read_states")] - // public object[] ReadStates { get; set; } + [JsonProperty("rtc_regions")] + public RtcRegionJson[]? RtcRegions { get; set; } } diff --git a/Fluxer.Net/Gateway/Data/Users/FavoriteMemeGatewayData.cs b/Fluxer.Net/Gateway/Data/Users/FavoriteMemeGatewayData.cs index 62f97be..cb4dca6 100644 --- a/Fluxer.Net/Gateway/Data/Users/FavoriteMemeGatewayData.cs +++ b/Fluxer.Net/Gateway/Data/Users/FavoriteMemeGatewayData.cs @@ -5,12 +5,12 @@ namespace Fluxer.Net.Gateway.Data.Users; /// /// Gateway data for FAVORITE_MEME_CREATE, FAVORITE_MEME_UPDATE, and FAVORITE_MEME_DELETE events. /// -public class FavoriteMemeGatewayData : FavouriteGifJson +public class FavoriteMemeGatewayData : FavoriteGifJson { } -public class FavoriteMemeDeleteGatewayData : FavouriteGifJson +public class FavoriteMemeDeleteGatewayData : FavoriteGifJson { [JsonProperty("meme_id")] public string Id { get; set; } diff --git a/Fluxer.Net/Gateway/Data/Users/RelationshipGatewayData.cs b/Fluxer.Net/Gateway/Data/Users/RelationshipGatewayData.cs index 05198b3..e0356fe 100644 --- a/Fluxer.Net/Gateway/Data/Users/RelationshipGatewayData.cs +++ b/Fluxer.Net/Gateway/Data/Users/RelationshipGatewayData.cs @@ -5,8 +5,13 @@ namespace Fluxer.Net.Gateway.Data.Users; /// /// Gateway data for RELATIONSHIP_ADD, RELATIONSHIP_UPDATE, and RELATIONSHIP_REMOVE events. /// -public class RelationshipGatewayData +public class RelationshipGatewayData : RelationshipJson { - [JsonProperty("relationship")] - public RelationshipJson Relationship { get; set; } = null!; + [JsonProperty("user")] + public UserJson User { get; set; } } +public class RelationshipRemoveGatewayData +{ + [JsonProperty("id")] + public ulong Id { get; set; } +} \ No newline at end of file diff --git a/Fluxer.Net/Gateway/Data/Users/UserGuildSettingsUpdateGatewayData.cs b/Fluxer.Net/Gateway/Data/Users/UserGuildSettingsUpdateGatewayData.cs index af8646b..97a1235 100644 --- a/Fluxer.Net/Gateway/Data/Users/UserGuildSettingsUpdateGatewayData.cs +++ b/Fluxer.Net/Gateway/Data/Users/UserGuildSettingsUpdateGatewayData.cs @@ -11,5 +11,5 @@ public class UserGuildSettingsUpdateGatewayData public ulong GuildId { get; set; } [JsonProperty("settings")] - public UserGuildSettings Settings { get; set; } = null!; + public UserGuildSettingsJson Settings { get; set; } = null!; } diff --git a/Fluxer.Net/Gateway/GatewayClient.cs b/Fluxer.Net/Gateway/GatewayClient.cs index 77f8881..072bdad 100644 --- a/Fluxer.Net/Gateway/GatewayClient.cs +++ b/Fluxer.Net/Gateway/GatewayClient.cs @@ -101,6 +101,7 @@ internal GatewayClient(FluxerClient client) #region Cache + public CurrentUser? CurrentUser { get; internal set; } public ConcurrentDictionary Guilds = new ConcurrentDictionary(); public ConcurrentDictionary Channels = new ConcurrentDictionary(); public ConcurrentDictionary Roles = new ConcurrentDictionary(); @@ -460,20 +461,20 @@ private void HandleDispatch(GatewayPacket p) ReadyGatewayData? data = p.Data.ToObject(FluxerClient._serializer); if (data != null) { + CurrentUser = CurrentUser.Create(_client, data.User); GuildIds = data.Guilds.Select(x => x.Id).ToHashSet(); Channels.Clear(); Roles.Clear(); CurrentMembers.Clear(); Guilds.Clear(); - if (data.Members != null) + if (data.Guilds != null) { - foreach (GuildMemberJson m in data.Members) + foreach (var g in data.Guilds) { - if (data.User.Id == m.UserId) - CurrentMembers.TryAdd(m.GuildId, SocketGuildMember.Create(_client, m)); + CurrentMembers.TryAdd(g.Id, SocketGuildMember.Create(_client, g.Members.First(x => x.UserId == CurrentUser.Id))); + Guilds.TryAdd(g.Id, SocketGuild.Create(_client, g.Properties, CurrentMembers[g.Id])); } } - Guilds = new ConcurrentDictionary(data.Guilds.ToDictionary(x => x.Id, x => SocketGuild.Create(_client, x, CurrentMembers[x.Id]))); _sessionId = data.SessionId; _isConnecting = false; // Connection successfully established @@ -854,7 +855,7 @@ private void HandleDispatch(GatewayPacket p) GuildIds.Add(data.Id); if (!data.Unavailable.GetValueOrDefault()) { - SocketGuildMember member = SocketGuildMember.Create(_client, data.Members.First()); + SocketGuildMember member = SocketGuildMember.Create(_client, data.Members.First(x => x.UserId == CurrentUser.Id)); SocketGuild guild = SocketGuild.Create(_client, data.Properties, member); if (Guilds.TryAdd(data.Id, guild)) CurrentMembers.TryAdd(data.Id, member); @@ -1043,7 +1044,7 @@ private void HandleDispatch(GatewayPacket p) return; case "RELATIONSHIP_REMOVE": { - RelationshipGatewayData? data = p.Data.ToObject(FluxerClient._serializer); + RelationshipRemoveGatewayData? data = p.Data.ToObject(FluxerClient._serializer); if (data != null) RelationshipRemove?.Invoke(data); else @@ -2099,7 +2100,7 @@ public void SetStatus(Status status, UserCustomStatusJson? custom) /// Delegate for RELATIONSHIP_REMOVE events when a relationship is removed. /// /// The relationship data. - public delegate void RelationshipRemoveEvent(RelationshipGatewayData data); + public delegate void RelationshipRemoveEvent(RelationshipRemoveGatewayData data); /// /// Occurs when a relationship is removed. diff --git a/Fluxer.Net/Rest/ApiClient.cs b/Fluxer.Net/Rest/ApiClient.cs index 49021e7..93a3416 100644 --- a/Fluxer.Net/Rest/ApiClient.cs +++ b/Fluxer.Net/Rest/ApiClient.cs @@ -611,27 +611,27 @@ public async Task DeleteAttachmentAsync(string uploadFilename) #region Favourite Gifs API - public async Task> GetCurrentUserFavouriteGifsAsync() + public async Task> GetCurrentUserFavouriteGifsAsync() { - IEnumerable json = await MakeFluxerApiRequestAsync>(HttpMethod.Get, "/users/@me/memes", true); - return json.Select(x => FavouriteGif.Create(_client, x)); + IEnumerable json = await MakeFluxerApiRequestAsync>(HttpMethod.Get, "/users/@me/memes", true); + return json.Select(x => FavoriteGif.Create(_client, x)); } - public async Task PostCurrentUserFavouriteGifAsync(TRequest data) + public async Task PostCurrentUserFavouriteGifAsync(TRequest data) { - FavouriteGifJson json = await MakeFluxerApiRequestAsync(HttpMethod.Post, "/users/@me/memes", data, true); - return FavouriteGif.Create(_client, json); + FavoriteGifJson json = await MakeFluxerApiRequestAsync(HttpMethod.Post, "/users/@me/memes", data, true); + return FavoriteGif.Create(_client, json); } - public async Task GetCurrentUserFavouriteGifAsync(ulong memeId) + public async Task GetCurrentUserFavouriteGifAsync(ulong memeId) { - FavouriteGifJson json = await MakeFluxerApiRequestAsync(HttpMethod.Get, $"/users/@me/memes/{memeId}", true); - return FavouriteGif.Create(_client, json); + FavoriteGifJson json = await MakeFluxerApiRequestAsync(HttpMethod.Get, $"/users/@me/memes/{memeId}", true); + return FavoriteGif.Create(_client, json); } - public async Task PatchCurrentUserFavouriteGifAsync(ulong memeId, TRequest data) + public async Task PatchCurrentUserFavouriteGifAsync(ulong memeId, TRequest data) { - FavouriteGifJson json = await MakeFluxerApiRequestAsync(HttpMethod.Patch, $"/users/@me/memes/{memeId}", data, true); - return FavouriteGif.Create(_client, json); + FavoriteGifJson json = await MakeFluxerApiRequestAsync(HttpMethod.Patch, $"/users/@me/memes/{memeId}", data, true); + return FavoriteGif.Create(_client, json); } public async Task DeleteCurrentUserFavouriteGifAsync(ulong memeId)