From de4b6b9f271ecffb90fa59675c891319e14b4ced Mon Sep 17 00:00:00 2001 From: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com> Date: Tue, 26 Dec 2023 10:34:10 +0300 Subject: [PATCH] [Fix] Incorrect json model for Guild Scheduled Event (#2813) * fix some cringe * whoooooooops --- src/Discord.Net.Rest/API/Common/GuildScheduledEvent.cs | 7 ++----- src/Discord.Net.Rest/Entities/Guilds/RestGuildEvent.cs | 2 +- .../Entities/Guilds/SocketGuildEvent.cs | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Discord.Net.Rest/API/Common/GuildScheduledEvent.cs b/src/Discord.Net.Rest/API/Common/GuildScheduledEvent.cs index 94c53e77..bafff4c8 100644 --- a/src/Discord.Net.Rest/API/Common/GuildScheduledEvent.cs +++ b/src/Discord.Net.Rest/API/Common/GuildScheduledEvent.cs @@ -1,9 +1,6 @@ using Newtonsoft.Json; + using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Discord.API { @@ -16,7 +13,7 @@ namespace Discord.API [JsonProperty("channel_id")] public Optional ChannelId { get; set; } [JsonProperty("creator_id")] - public Optional CreatorId { get; set; } + public Optional CreatorId { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("description")] diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuildEvent.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuildEvent.cs index 39e63b2f..ee1b14d7 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuildEvent.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuildEvent.cs @@ -92,7 +92,7 @@ namespace Discord.Rest Creator = RestUser.Create(Discord, model.Creator.Value); } - CreatorId = model.CreatorId.ToNullable() ?? 0; // should be changed? + CreatorId = model.CreatorId.GetValueOrDefault(null) ?? 0; // should be changed? ChannelId = model.ChannelId.IsSpecified ? model.ChannelId.Value : null; Name = model.Name; Description = model.Description.GetValueOrDefault(); diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuildEvent.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuildEvent.cs index 1be5e194..cb0ef05d 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuildEvent.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuildEvent.cs @@ -87,7 +87,7 @@ namespace Discord.WebSocket if (model.CreatorId.IsSpecified) { - var guildUser = Guild.GetUser(model.CreatorId.Value); + var guildUser = Guild.GetUser(model.CreatorId.GetValueOrDefault(0) ?? 0); if (guildUser != null) { @@ -96,7 +96,7 @@ namespace Discord.WebSocket Creator = guildUser; } - else if (guildUser == null && model.Creator.IsSpecified) + else if (model.Creator.IsSpecified) { guildUser = SocketGuildUser.Create(Guild, Discord.State, model.Creator.Value); Creator = guildUser;