Skip to content

Commit

Permalink
[Fix] Incorrect json model for Guild Scheduled Event (#2813)
Browse files Browse the repository at this point in the history
* fix some cringe

* whoooooooops
  • Loading branch information
Misha-133 authored Dec 26, 2023
1 parent d382e5c commit de4b6b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/Discord.Net.Rest/API/Common/GuildScheduledEvent.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -16,7 +13,7 @@ internal class GuildScheduledEvent
[JsonProperty("channel_id")]
public Optional<ulong?> ChannelId { get; set; }
[JsonProperty("creator_id")]
public Optional<ulong> CreatorId { get; set; }
public Optional<ulong?> CreatorId { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("description")]
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.Rest/Entities/Guilds/RestGuildEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ internal void Update(Model model)
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();
Expand Down
4 changes: 2 additions & 2 deletions src/Discord.Net.WebSocket/Entities/Guilds/SocketGuildEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ internal void Update(Model model)

if (model.CreatorId.IsSpecified)
{
var guildUser = Guild.GetUser(model.CreatorId.Value);
var guildUser = Guild.GetUser(model.CreatorId.GetValueOrDefault(0) ?? 0);

if (guildUser != null)
{
Expand All @@ -96,7 +96,7 @@ internal void Update(Model model)

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;
Expand Down

0 comments on commit de4b6b9

Please sign in to comment.