diff --git a/DisCatSharp/Entities/Guild/DiscordGuildMembershipScreening.cs b/DisCatSharp/Entities/Guild/DiscordGuildMembershipScreening.cs
index 87790362c..14b005aa1 100644
--- a/DisCatSharp/Entities/Guild/DiscordGuildMembershipScreening.cs
+++ b/DisCatSharp/Entities/Guild/DiscordGuildMembershipScreening.cs
@@ -1,52 +1,52 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace DisCatSharp.Entities;
///
/// Represents a guild's membership screening form.
///
-public class DiscordGuildMembershipScreening : ApiObject
+public class DiscordGuildMembershipScreening : ObservableApiObject
{
///
/// Gets when the fields were last updated.
///
[JsonProperty("version")]
public DateTimeOffset Version { get; internal set; }
///
/// Gets the steps in the screening form.
///
[JsonProperty("form_fields")]
public IReadOnlyList Fields { get; internal set; }
///
/// Gets the server description shown in the screening form.
///
[JsonProperty("description")]
public string Description { get; internal set; }
}
diff --git a/DisCatSharp/Entities/Guild/DiscordGuildTemplate.cs b/DisCatSharp/Entities/Guild/DiscordGuildTemplate.cs
index 3c6e98cb2..0c31cd60a 100644
--- a/DisCatSharp/Entities/Guild/DiscordGuildTemplate.cs
+++ b/DisCatSharp/Entities/Guild/DiscordGuildTemplate.cs
@@ -1,107 +1,107 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using Newtonsoft.Json;
namespace DisCatSharp.Entities;
///
/// Represents a guild template.
///
-public class DiscordGuildTemplate : ApiObject
+public class DiscordGuildTemplate : ObservableApiObject
{
///
/// Gets the template code.
///
[JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)]
public string Code { get; internal set; }
///
/// Gets the name of the template.
///
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; internal set; }
///
/// Gets the description of the template.
///
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public string Description { get; internal set; }
///
/// Gets the number of times the template has been used.
///
[JsonProperty("usage_count", NullValueHandling = NullValueHandling.Ignore)]
public int UsageCount { get; internal set; }
///
/// Gets the ID of the creator of the template.
///
[JsonProperty("creator_id", NullValueHandling = NullValueHandling.Ignore)]
public ulong CreatorId { get; internal set; }
///
/// Gets the creator of the template.
///
[JsonProperty("creator", NullValueHandling = NullValueHandling.Ignore)]
public DiscordUser Creator { get; internal set; }
///
/// Date the template was created.
///
[JsonProperty("created_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset CreatedAt { get; internal set; }
///
/// Date the template was updated.
///
[JsonProperty("updated_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset UpdatedAt { get; internal set; }
///
/// Gets the ID of the source guild.
///
[JsonProperty("source_guild_id", NullValueHandling = NullValueHandling.Ignore)]
public ulong SourceGuildId { get; internal set; }
///
/// Gets the source guild.
///
[JsonProperty("serialized_source_guild", NullValueHandling = NullValueHandling.Ignore)]
public DiscordGuild SourceGuild { get; internal set; }
///
/// Gets whether the template has unsynced changes.
///
[JsonProperty("is_dirty", NullValueHandling = NullValueHandling.Ignore)]
public bool? IsDirty { get; internal set; }
///
/// Gets whether the template has unsynced changes.
///
///
[JsonIgnore]
public bool? IsUnsynced
=> this.IsDirty;
}
diff --git a/DisCatSharp/Entities/Guild/DiscordGuildWelcomeScreen.cs b/DisCatSharp/Entities/Guild/DiscordGuildWelcomeScreen.cs
index fa4dc69a4..1cfd0c20c 100644
--- a/DisCatSharp/Entities/Guild/DiscordGuildWelcomeScreen.cs
+++ b/DisCatSharp/Entities/Guild/DiscordGuildWelcomeScreen.cs
@@ -1,45 +1,45 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System.Collections.Generic;
using Newtonsoft.Json;
namespace DisCatSharp.Entities;
///
/// Represents a discord welcome screen object.
///
-public class DiscordGuildWelcomeScreen : ApiObject
+public class DiscordGuildWelcomeScreen : ObservableApiObject
{
///
/// Gets the server description shown in the welcome screen.
///
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public string Description { get; internal set; }
///
/// Gets the channels shown in the welcome screen.
///
[JsonProperty("welcome_channels", NullValueHandling = NullValueHandling.Ignore)]
public IReadOnlyList WelcomeChannels { get; internal set; }
}
diff --git a/DisCatSharp/Entities/Guild/ThreadAndForum/DiscordThreadResult.cs b/DisCatSharp/Entities/Guild/ThreadAndForum/DiscordThreadResult.cs
index 8d77f3e04..f34f2bc03 100644
--- a/DisCatSharp/Entities/Guild/ThreadAndForum/DiscordThreadResult.cs
+++ b/DisCatSharp/Entities/Guild/ThreadAndForum/DiscordThreadResult.cs
@@ -1,61 +1,61 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace DisCatSharp.Entities;
///
/// Represents a discord thread result.
///
-public class DiscordThreadResult : ApiObject
+public class DiscordThreadResult : ObservableApiObject
{
///
/// Gets the returned threads.
///
[JsonIgnore]
public Dictionary ReturnedThreads
=> this.Threads == null || !this.Threads.Any() ? new Dictionary() : this.Threads.Select(t => new { t.Id, t }).ToDictionary(t => t.Id, t => t.t);
[JsonProperty("threads", NullValueHandling = NullValueHandling.Ignore)]
internal List Threads { get; set; }
///
/// Gets the active members.
///
[JsonProperty("members", NullValueHandling = NullValueHandling.Ignore)]
public List ActiveMembers { get; internal set; }
///
/// Whether there are more results.
///
public bool HasMore { get; internal set; }
///
/// Initializes a new instance of the class.
///
internal DiscordThreadResult()
: base()
{ }
}
diff --git a/DisCatSharp/Entities/Guild/Widget/DiscordWidgetSettings.cs b/DisCatSharp/Entities/Guild/Widget/DiscordWidgetSettings.cs
index a67ee1bab..b59165674 100644
--- a/DisCatSharp/Entities/Guild/Widget/DiscordWidgetSettings.cs
+++ b/DisCatSharp/Entities/Guild/Widget/DiscordWidgetSettings.cs
@@ -1,56 +1,56 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using Newtonsoft.Json;
namespace DisCatSharp.Entities;
///
/// Represents a Discord guild's widget settings.
///
-public class DiscordWidgetSettings : ApiObject
+public class DiscordWidgetSettings : ObservableApiObject
{
///
/// Gets the guild.
///
[JsonIgnore]
internal DiscordGuild Guild { get; set; }
///
/// Gets the guild's widget channel id.
///
[JsonProperty("channel_id", NullValueHandling = NullValueHandling.Ignore)]
public ulong ChannelId { get; internal set; }
///
/// Gets the guild's widget channel.
///
[JsonIgnore]
public DiscordChannel Channel
=> this.Guild?.GetChannel(this.ChannelId);
///
/// Whether if the guild's widget is enabled.
///
[JsonProperty("enabled", NullValueHandling = NullValueHandling.Ignore)]
public bool IsEnabled { get; internal set; }
}
diff --git a/DisCatSharp/Entities/Invite/DiscordInvite.cs b/DisCatSharp/Entities/Invite/DiscordInvite.cs
index 0e46b09a5..3ad62556a 100644
--- a/DisCatSharp/Entities/Invite/DiscordInvite.cs
+++ b/DisCatSharp/Entities/Invite/DiscordInvite.cs
@@ -1,200 +1,200 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Threading.Tasks;
using DisCatSharp.Enums;
using DisCatSharp.Exceptions;
using Newtonsoft.Json;
namespace DisCatSharp.Entities;
///
/// Represents a Discord invite.
///
-public class DiscordInvite : ApiObject
+public class DiscordInvite : ObservableApiObject
{
///
/// Gets the invite's code.
///
[JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)]
public string Code { get; internal set; }
///
/// Gets the invite's url.
///
[JsonIgnore]
public string Url => DiscordDomain.GetDomain(CoreDomain.DiscordShortlink).Url + "/" + this.Code;
///
/// Gets the invite's url as Uri.
///
[JsonIgnore]
public Uri Uri => new(this.Url);
///
/// Gets the guild this invite is for.
///
[JsonProperty("guild", NullValueHandling = NullValueHandling.Ignore)]
public DiscordInviteGuild Guild { get; internal set; }
///
/// Gets the channel this invite is for.
///
[JsonProperty("channel", NullValueHandling = NullValueHandling.Ignore)]
public DiscordInviteChannel Channel { get; internal set; }
///
/// Gets the target type for the voice channel this invite is for.
///
[JsonProperty("target_type", NullValueHandling = NullValueHandling.Ignore)]
public TargetType? TargetType { get; internal set; }
///
/// Gets the type of this invite.
///
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
public InviteType Type { get; internal set; }
///
/// Gets the user that is currently livestreaming.
///
[JsonProperty("target_user", NullValueHandling = NullValueHandling.Ignore)]
public DiscordUser TargetUser { get; internal set; }
///
/// Gets the embedded partial application to open for this voice channel.
///
[JsonProperty("target_application", NullValueHandling = NullValueHandling.Ignore)]
public DiscordApplication TargetApplication { get; internal set; }
///
/// Gets the approximate guild online member count for the invite.
///
[JsonProperty("approximate_presence_count", NullValueHandling = NullValueHandling.Ignore)]
public int? ApproximatePresenceCount { get; internal set; }
///
/// Gets the approximate guild total member count for the invite.
///
[JsonProperty("approximate_member_count", NullValueHandling = NullValueHandling.Ignore)]
public int? ApproximateMemberCount { get; internal set; }
///
/// Gets the user who created the invite.
///
[JsonProperty("inviter", NullValueHandling = NullValueHandling.Ignore)]
public DiscordUser Inviter { get; internal set; }
///
/// Gets the number of times this invite has been used.
///
[JsonProperty("uses", NullValueHandling = NullValueHandling.Ignore)]
public int Uses { get; internal set; }
///
/// Gets the max number of times this invite can be used.
///
[JsonProperty("max_uses", NullValueHandling = NullValueHandling.Ignore)]
public int MaxUses { get; internal set; }
///
/// Gets duration in seconds after which the invite expires.
///
[JsonProperty("max_age", NullValueHandling = NullValueHandling.Ignore)]
public int MaxAge { get; internal set; }
///
/// Gets whether this invite only grants temporary membership.
///
[JsonProperty("temporary", NullValueHandling = NullValueHandling.Ignore)]
public bool IsTemporary { get; internal set; }
///
/// Gets the date and time this invite was created.
///
[JsonProperty("created_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset CreatedAt { get; internal set; }
///
/// Gets the date and time when this invite expires.
///
[JsonProperty("expires_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset ExpiresAt { get; internal set; }
///
/// Gets the date and time when this invite got expired.
///
[JsonProperty("expired_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset ExpiredAt { get; internal set; }
///
/// Gets whether this invite is revoked.
///
[JsonProperty("revoked", NullValueHandling = NullValueHandling.Ignore)]
public bool IsRevoked { get; internal set; }
///
/// Gets the stage instance this invite is for.
///
[JsonProperty("stage_instance", NullValueHandling = NullValueHandling.Ignore)]
public DiscordInviteStage Stage { get; internal set; }
///
/// Gets the guild scheduled event data for the invite.
///
[JsonProperty("guild_scheduled_event", NullValueHandling = NullValueHandling.Ignore)]
public DiscordScheduledEvent GuildScheduledEvent { get; internal set; }
///
/// Gets the invites flags.
///
[JsonProperty("flags", NullValueHandling = NullValueHandling.Ignore)]
public InviteFlags Flags { get; internal set; }
///
/// Initializes a new instance of the class.
///
internal DiscordInvite()
{ }
///
/// Deletes the invite.
///
/// Reason for audit logs.
///
/// Thrown when the client does not have the permission or the permission.
/// Thrown when the emoji does not exist.
/// Thrown when an invalid parameter was provided.
/// Thrown when Discord is unable to process the request.
public Task DeleteAsync(string reason = null)
=> this.Discord.ApiClient.DeleteInviteAsync(this.Code, reason);
///
/// Converts this invite into an invite link.
///
/// A discord.gg invite link.
public override string ToString()
=> $"{DiscordDomain.GetDomain(CoreDomain.DiscordShortlink).Url}/{this.Code}";
}
diff --git a/DisCatSharp/Entities/NullableSnowflakeObject.cs b/DisCatSharp/Entities/NullableSnowflakeObject.cs
index 3562fc1b0..4c1b4de2d 100644
--- a/DisCatSharp/Entities/NullableSnowflakeObject.cs
+++ b/DisCatSharp/Entities/NullableSnowflakeObject.cs
@@ -1,57 +1,51 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using Newtonsoft.Json;
namespace DisCatSharp.Entities;
///
/// Represents an object in Discord API.
///
-public abstract class NullableSnowflakeObject
+public abstract class NullableSnowflakeObject : ObservableApiObject
{
///
/// Gets the ID of this object.
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public ulong? Id { get; internal set; }
///
/// Gets the date and time this object was created.
///
[JsonIgnore]
public DateTimeOffset? CreationTimestamp
=> this.Id.GetSnowflakeTime();
- ///
- /// Gets the client instance this object is tied to.
- ///
- [JsonIgnore]
- internal BaseDiscordClient Discord { get; set; }
-
///
/// Initializes a new instance of the class.
///
internal NullableSnowflakeObject() { }
}
diff --git a/DisCatSharp/Entities/ApiObject.cs b/DisCatSharp/Entities/ObservableApiObject.cs
similarity index 97%
rename from DisCatSharp/Entities/ApiObject.cs
rename to DisCatSharp/Entities/ObservableApiObject.cs
index 2aa91d22d..43469d641 100644
--- a/DisCatSharp/Entities/ApiObject.cs
+++ b/DisCatSharp/Entities/ObservableApiObject.cs
@@ -1,46 +1,46 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System.Collections.Generic;
using Newtonsoft.Json;
namespace DisCatSharp.Entities
{
- public abstract class ApiObject
+ public abstract class ObservableApiObject
{
///
/// Gets the client instance this object is tied to.
///
[JsonIgnore]
internal BaseDiscordClient Discord { get; set; }
internal IDictionary _unknownProperties = new Dictionary();
[JsonExtensionData(ReadData = true, WriteData = false)]
internal IDictionary AdditionalProperties
{
get => this._unknownProperties;
set => this._unknownProperties = value;
}
}
}
diff --git a/DisCatSharp/Entities/SnowflakeObject.cs b/DisCatSharp/Entities/SnowflakeObject.cs
index fae608f63..22039b3e8 100644
--- a/DisCatSharp/Entities/SnowflakeObject.cs
+++ b/DisCatSharp/Entities/SnowflakeObject.cs
@@ -1,52 +1,52 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace DisCatSharp.Entities;
///
/// Represents an object in Discord API.
///
-public abstract class SnowflakeObject : ApiObject
+public abstract class SnowflakeObject : ObservableApiObject
{
///
/// Gets the ID of this object.
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public ulong Id { get; internal set; }
///
/// Gets the date and time this object was created.
///
[JsonIgnore]
public DateTimeOffset CreationTimestamp
=> this.Id.GetSnowflakeTime();
///
/// Initializes a new instance of the class.
///
internal SnowflakeObject() { }
}
diff --git a/DisCatSharp/Net/Abstractions/AuditLogAbstractions.cs b/DisCatSharp/Net/Abstractions/AuditLogAbstractions.cs
index b5401c17d..a775f6ea7 100644
--- a/DisCatSharp/Net/Abstractions/AuditLogAbstractions.cs
+++ b/DisCatSharp/Net/Abstractions/AuditLogAbstractions.cs
@@ -1,577 +1,577 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System.Collections.Generic;
using DisCatSharp.Entities;
using DisCatSharp.Enums;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace DisCatSharp.Net.Abstractions;
///
/// Represents a audit log user.
///
internal sealed class AuditLogUser
{
///
/// Gets or sets the username.
///
[JsonProperty("username")]
public string Username { get; set; }
///
/// Gets or sets the discriminator.
///
[JsonProperty("discriminator")]
public string Discriminator { get; set; }
///
/// Gets or sets the id.
///
[JsonProperty("id")]
public ulong Id { get; set; }
///
/// Gets or sets the avatar hash.
///
[JsonProperty("avatar")]
public string AvatarHash { get; set; }
}
///
/// Represents a audit log webhook.
///
internal sealed class AuditLogWebhook
{
///
/// Gets or sets the name.
///
[JsonProperty("name")]
public string Name { get; set; }
///
/// Gets or sets the channel id.
///
[JsonProperty("channel_id")]
public ulong ChannelId { get; set; }
///
/// Gets or sets the token.
///
[JsonProperty("token")]
public string Token { get; set; }
///
/// Gets or sets the avatar hash.
///
[JsonProperty("avatar")]
public string AvatarHash { get; set; }
///
/// Gets or sets the guild id.
///
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
///
/// Gets or sets the id.
///
[JsonProperty("id")]
public ulong Id { get; set; }
}
///
/// Represents a audit log thread metadata.
///
internal sealed class AuditLogThreadMetadata
{
///
/// Gets whether the thread is archived.
///
[JsonProperty("archived")]
public bool Archived { get; set; }
///
/// Gets the threads archive timestamp.
///
[JsonProperty("archive_timestamp", NullValueHandling = NullValueHandling.Ignore)]
public string ArchiveTimestamp { get; set; }
///
/// Gets the threads auto archive duration.
///
[JsonProperty("auto_archive_duration")]
public int AutoArchiveDuration { get; set; }
///
/// Gets whether the thread is locked.
///
[JsonProperty("locked")]
public bool Locked { get; set; }
}
///
/// Represents a audit log thread.
///
internal sealed class AuditLogThread
{
///
/// Gets the thread id.
///
[JsonProperty("id")]
public ulong Id { get; set; }
///
/// Gets the thread guild id.
///
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
///
/// Gets the thread parent channel id.
///
[JsonProperty("parent_id")]
public ulong ParentId { get; set; }
///
/// Gets the thread owner id.
///
[JsonProperty("owner_id", NullValueHandling = NullValueHandling.Ignore)]
public ulong? OwnerId { get; set; }
///
/// Gets the thread type.
///
[JsonProperty("type")]
public ChannelType Type { get; set; }
///
/// Gets the thread name.
///
[JsonProperty("name")]
public string Name { get; set; }
///
/// Gets the thread last message id.
///
[JsonProperty("last_message_id", NullValueHandling = NullValueHandling.Ignore)]
public ulong? LastMessageId { get; set; }
///
/// Gets the thread metadata.
///
[JsonProperty("thread_metadata")]
public AuditLogThreadMetadata Metadata { get; set; }
///
/// Gets the thread approximate message count.
///
[JsonProperty("message_count", NullValueHandling = NullValueHandling.Ignore)]
public int? MessageCount { get; set; }
///
/// Gets the thread member count.
///
[JsonProperty("member_count", NullValueHandling = NullValueHandling.Ignore)]
public int? MemberCount { get; set; }
///
/// Gets the thread rate limit per user.
///
[JsonProperty("rate_limit_per_user", NullValueHandling = NullValueHandling.Ignore)]
public int? RateLimitPerUser { get; set; }
}
///
/// Represents a audit log scheduled event.
///
internal sealed class AuditLogGuildScheduledEvent
{
///
/// Gets the scheduled event id.
///
[JsonProperty("id")]
public ulong Id { get; set; }
///
/// Gets the scheduled event guild id.
///
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
///
/// Gets the scheduled event channel id.
///
[JsonProperty("channel_id", NullValueHandling = NullValueHandling.Ignore)]
public ulong ChannelId { get; set; }
///
/// Gets the scheduled event creator id.
///
[JsonProperty("creator_id")]
public ulong CreatorId { get; set; }
///
/// Gets the scheduled event name.
///
[JsonProperty("name")]
public string Name { get; set; }
///
/// Gets the scheduled event description.
///
[JsonProperty("description")]
public string Description { get; set; }
///
/// Gets the scheduled event image.
///
[JsonProperty("image", NullValueHandling = NullValueHandling.Ignore)]
public string Image { get; set; }
///
/// Gets the scheduled event scheduled start time.
///
[JsonProperty("scheduled_start_time")]
public string ScheduledStartTime;
///
/// Gets the scheduled event scheduled end time.
///
[JsonProperty("scheduled_end_time")]
public string ScheduledEndTime { get; set; }
///
/// Gets the scheduled event privacy level.
///
[JsonProperty("privacy_level")]
public ScheduledEventPrivacyLevel PrivacyLevel { get; set; }
///
/// Gets the scheduled event status.
///
[JsonProperty("status")]
public ScheduledEventStatus Status { get; set; }
///
/// Gets the scheduled event entity type.
///
[JsonProperty("entity_type")]
public ScheduledEventEntityType EntityType { get; set; }
///
/// Gets the scheduled event entity id.
///
[JsonProperty("entity_id", NullValueHandling = NullValueHandling.Ignore)]
public ulong EntityId { get; set; }
///
/// Gets the scheduled event entity metadata.
///
[JsonProperty("entity_metadata")]
public AuditLogGuildScheduledEventEntityMetadata EntityMetadata { get; set; }
///
/// Gets the scheduled event sku ids.
///
[JsonProperty("sku_ids")]
public List SkuIds { get; set; }
}
///
/// Represents a audit log scheduled event entity metadata.
///
internal sealed class AuditLogGuildScheduledEventEntityMetadata
{
///
/// Gets the scheduled events external location.
///
[JsonProperty("location")]
public string Location { get; set; }
}
///
/// Represents a audit log integration account.
///
internal sealed class AuditLogIntegrationAccount
{
///
/// Gets the account id.
///
[JsonProperty("id")]
public string Id { get; set; }
///
/// Gets the account name.
///
[JsonProperty("name")]
public string Name { get; set; }
}
///
/// Represents a audit log integration.
///
internal sealed class AuditLogIntegration
{
///
/// Gets the integration id.
///
[JsonProperty("id")]
public ulong Id { get; set; }
///
/// Gets the integration type.
///
[JsonProperty("type")]
public string Type { get; set; }
///
/// Gets the integration name.
///
[JsonProperty("name")]
public string Name { get; set; }
///
/// Gets the integration account.
///
[JsonProperty("account")]
public AuditLogIntegrationAccount Account { get; set; }
}
///
/// Represents a audit log action change.
///
internal sealed class AuditLogActionChange
{
// this can be a string or an array
///
/// Gets or sets the old value.
///
[JsonProperty("old_value")]
public object OldValue { get; set; }
///
/// Gets the old values.
///
[JsonIgnore]
public IReadOnlyList OldValues
=> (this.OldValue as JArray)?.ToObject>();
///
/// Gets the old value ulong.
///
[JsonIgnore]
public ulong OldValueUlong
=> (ulong)this.OldValue;
///
/// Gets the old value string.
///
[JsonIgnore]
public string OldValueString
=> (string)this.OldValue;
// this can be a string or an array
///
/// Gets or sets the new value.
///
[JsonProperty("new_value")]
public object NewValue { get; set; }
///
/// Gets the new values.
///
[JsonIgnore]
public IReadOnlyList NewValues
=> (this.NewValue as JArray)?.ToObject>();
///
/// Gets the new value ulong.
///
[JsonIgnore]
public ulong NewValueUlong
=> (ulong)this.NewValue;
///
/// Gets the new value string.
///
[JsonIgnore]
public string NewValueString
=> (string)this.NewValue;
///
/// Gets or sets the key.
///
[JsonProperty("key")]
public string Key { get; set; }
}
///
/// Represents a audit log action options.
///
internal sealed class AuditLogActionOptions
{
///
/// Gets or sets the type.
///
[JsonProperty("type")]
public object Type { get; set; }
///
/// Gets or sets the id.
///
[JsonProperty("id")]
public ulong Id { get; set; }
///
/// Gets or sets the channel id.
///
[JsonProperty("channel_id")]
public ulong ChannelId { get; set; }
///
/// Gets or sets the message id.
///
[JsonProperty("message_id")]
public ulong MessageId { get; set; }
///
/// Gets or sets the count.
///
[JsonProperty("count")]
public int Count { get; set; }
///
/// Gets or sets the delete member days.
///
[JsonProperty("delete_member_days")]
public int DeleteMemberDays { get; set; }
///
/// Gets or sets the members removed.
///
[JsonProperty("members_removed")]
public int MembersRemoved { get; set; }
}
///
/// Represents a audit log action.
///
internal sealed class AuditLogAction
{
///
/// Gets or sets the target id.
///
[JsonProperty("target_id")]
public ulong? TargetId { get; set; }
///
/// Gets or sets the user id.
///
[JsonProperty("user_id", NullValueHandling = NullValueHandling.Ignore)]
public ulong UserId { get; set; }
///
/// Gets or sets the id.
///
[JsonProperty("id")]
public ulong Id { get; set; }
///
/// Gets or sets the action type.
///
[JsonProperty("action_type", NullValueHandling = NullValueHandling.Ignore)]
public AuditLogActionType ActionType { get; set; }
///
/// Gets or sets the changes.
///
[JsonProperty("changes")]
public IReadOnlyList Changes { get; set; }
///
/// Gets or sets the options.
///
[JsonProperty("options")]
public AuditLogActionOptions Options { get; set; }
///
/// Gets or sets the reason.
///
[JsonProperty("reason")]
public string Reason { get; set; }
}
///
/// Represents a audit log.
///
-internal sealed class AuditLog : ApiObject
+internal sealed class AuditLog : ObservableApiObject
{
///
/// Gets or sets the webhooks.
///
[JsonProperty("webhooks")]
public IReadOnlyList Webhooks { get; set; }
///
/// Gets or sets the users.
///
[JsonProperty("users")]
public IReadOnlyList Users { get; set; }
///
/// Gets or sets the entries.
///
[JsonProperty("audit_log_entries")]
public IReadOnlyList Entries { get; set; }
///
/// Gets or sets the scheduled events.
///
[JsonProperty("guild_scheduled_events")]
public IReadOnlyList ScheduledEvents { get; set; }
///
/// Gets or sets the threads.
///
[JsonProperty("threads")]
public IReadOnlyList Threads { get; set; }
///
/// Gets or sets the integrations.
/// Twitch related.
///
[JsonProperty("integrations")]
public IReadOnlyList Integrations { get; set; }
/*
///
/// Gets or sets the application commands.
/// Related to Permissions V2.
///
[JsonProperty("application_commands")]
public IReadOnlyList ApplicationCommands { get; set; }
*/
}
diff --git a/DisCatSharp/Net/Abstractions/Rest/RestGuildPayloads.cs b/DisCatSharp/Net/Abstractions/Rest/RestGuildPayloads.cs
index c8f3f7ece..7e70ec36c 100644
--- a/DisCatSharp/Net/Abstractions/Rest/RestGuildPayloads.cs
+++ b/DisCatSharp/Net/Abstractions/Rest/RestGuildPayloads.cs
@@ -1,775 +1,775 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Collections.Generic;
using DisCatSharp.Entities;
using DisCatSharp.Enums;
using Newtonsoft.Json;
namespace DisCatSharp.Net.Abstractions;
///
/// The reason action.
///
internal interface IReasonAction
{
///
/// Gets or sets the reason.
///
string Reason { get; set; }
}
///
/// Represents a guild create payload.
///
-internal class RestGuildCreatePayload : ApiObject
+internal class RestGuildCreatePayload : ObservableApiObject
{
///
/// Gets or sets the name.
///
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; }
///
/// Gets or sets the region id.
///
[JsonProperty("region", NullValueHandling = NullValueHandling.Ignore)]
public string RegionId { get; set; }
///
/// Gets or sets the icon base64.
///
[JsonProperty("icon", NullValueHandling = NullValueHandling.Include)]
public Optional IconBase64 { get; set; }
///
/// Gets or sets the verification level.
///
[JsonProperty("verification_level", NullValueHandling = NullValueHandling.Ignore)]
public VerificationLevel? VerificationLevel { get; set; }
///
/// Gets or sets the default message notifications.
///
[JsonProperty("default_message_notifications", NullValueHandling = NullValueHandling.Ignore)]
public DefaultMessageNotifications? DefaultMessageNotifications { get; set; }
///
/// Gets or sets the system channel flags.
///
[JsonProperty("system_channel_flags", NullValueHandling = NullValueHandling.Ignore)]
public SystemChannelFlags? SystemChannelFlags { get; set; }
///
/// Gets or sets the roles.
///
[JsonProperty("roles", NullValueHandling = NullValueHandling.Ignore)]
public IEnumerable Roles { get; set; }
///
/// Gets or sets the channels.
///
[JsonProperty("channels", NullValueHandling = NullValueHandling.Ignore)]
public IEnumerable Channels { get; set; }
}
///
/// Represents a guild create from template payload.
///
-internal sealed class RestGuildCreateFromTemplatePayload : ApiObject
+internal sealed class RestGuildCreateFromTemplatePayload : ObservableApiObject
{
///
/// Gets or sets the name.
///
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; }
///
/// Gets or sets the icon base64.
///
[JsonProperty("icon", NullValueHandling = NullValueHandling.Include)]
public Optional IconBase64 { get; set; }
}
///
/// Represents a guild modify payload.
///
-internal sealed class RestGuildModifyPayload : ApiObject
+internal sealed class RestGuildModifyPayload : ObservableApiObject
{
///
/// Gets or sets the name.
///
[JsonProperty("name")]
public Optional Name { get; set; }
///
/// Gets or sets the icon base64.
///
[JsonProperty("icon")]
public Optional IconBase64 { get; set; }
///
/// Gets or sets the verification level.
///
[JsonProperty("verification_level")]
public Optional VerificationLevel { get; set; }
///
/// Gets or sets the default message notifications.
///
[JsonProperty("default_message_notifications")]
public Optional DefaultMessageNotifications { get; set; }
///
/// Gets or sets the owner id.
///
[JsonProperty("owner_id")]
public Optional OwnerId { get; set; }
///
/// Gets or sets the splash base64.
///
[JsonProperty("splash")]
public Optional SplashBase64 { get; set; }
///
/// Gets or sets the banner base64.
///
[JsonProperty("banner")]
public Optional BannerBase64 { get; set; }
///
/// Gets or sets the home header base64.
///
[JsonProperty("home_header")]
public Optional HomeHeaderBase64 { get; set; }
///
/// Gets or sets the discovery splash base64.
///
[JsonProperty("discovery_splash")]
public Optional DiscoverySplashBase64 { get; set; }
///
/// Gets or sets the afk channel id.
///
[JsonProperty("afk_channel_id")]
public Optional AfkChannelId { get; set; }
///
/// Gets or sets the afk timeout.
///
[JsonProperty("afk_timeout")]
public Optional AfkTimeout { get; set; }
///
/// Gets or sets the mfa level.
///
[JsonProperty("mfa_level")]
public Optional MfaLevel { get; set; }
///
/// Gets or sets the explicit content filter.
///
[JsonProperty("explicit_content_filter")]
public Optional ExplicitContentFilter { get; set; }
///
/// Gets or sets the system channel id.
///
[JsonProperty("system_channel_id", NullValueHandling = NullValueHandling.Include)]
public Optional SystemChannelId { get; set; }
///
/// Gets or sets the safety alerts channel id.
///
[JsonProperty("safety_alerts_channel_id", NullValueHandling = NullValueHandling.Include)]
internal Optional SafetyAlertsChannelId { get; set; }
///
/// Gets or sets the system channel flags.
///
[JsonProperty("system_channel_flags", NullValueHandling = NullValueHandling.Ignore)]
public Optional SystemChannelFlags { get; set; }
///
/// Gets or sets the rules channel id.
///
[JsonProperty("rules_channel_id")]
public Optional RulesChannelId { get; set; }
///
/// Gets or sets the public updates channel id.
///
[JsonProperty("public_updates_channel_id")]
public Optional PublicUpdatesChannelId { get; set; }
///
/// Gets or sets the preferred locale.
///
[JsonProperty("preferred_locale")]
public Optional PreferredLocale { get; set; }
///
/// Gets or sets the description.
///
[JsonProperty("description", NullValueHandling = NullValueHandling.Include)]
public Optional Description { get; set; }
///
/// Gets or sets whether the premium progress bar should be enabled.
///
[JsonProperty("premium_progress_bar_enabled", NullValueHandling = NullValueHandling.Ignore)]
public Optional PremiumProgressBarEnabled { get; set; }
}
///
/// Represents a guild mfa level modify payload.
///
-internal sealed class RestGuildMfaLevelModifyPayload : ApiObject
+internal sealed class RestGuildMfaLevelModifyPayload : ObservableApiObject
{
///
/// Gets or sets the mfa level.
///
[JsonProperty("level")]
public MfaLevel Level { get; set; }
}
///
/// Represents a guild community modify payload.
///
-internal sealed class RestGuildFeatureModifyPayload : ApiObject
+internal sealed class RestGuildFeatureModifyPayload : ObservableApiObject
{
///
/// Gets or sets the features.
///
[JsonProperty("features", NullValueHandling = NullValueHandling.Ignore)]
public List Features { get; set; }
}
-internal sealed class RestGuildSafetyModifyPayload : ApiObject
+internal sealed class RestGuildSafetyModifyPayload : ObservableApiObject
{
///
/// Gets or sets the safety alerts channel id.
///
[JsonProperty("safety_alerts_channel_id", NullValueHandling = NullValueHandling.Include)]
internal Optional SafetyAlertsChannelId { get; set; }
///
/// Gets or sets the features.
///
[JsonProperty("features", NullValueHandling = NullValueHandling.Ignore)]
public List Features { get; set; }
}
///
/// Represents a guild community modify payload.
///
-internal sealed class RestGuildCommunityModifyPayload : ApiObject
+internal sealed class RestGuildCommunityModifyPayload : ObservableApiObject
{
///
/// Gets or sets the verification level.
///
[JsonProperty("verification_level", NullValueHandling = NullValueHandling.Ignore)]
public Optional VerificationLevel { get; set; }
///
/// Gets or sets the default message notifications.
///
[JsonProperty("default_message_notifications", NullValueHandling = NullValueHandling.Ignore)]
public Optional DefaultMessageNotifications { get; set; }
///
/// Gets or sets the explicit content filter.
///
[JsonProperty("explicit_content_filter", NullValueHandling = NullValueHandling.Ignore)]
public Optional ExplicitContentFilter { get; set; }
///
/// Gets or sets the rules channel id.
///
[JsonProperty("rules_channel_id", NullValueHandling = NullValueHandling.Ignore)]
public Optional RulesChannelId { get; set; }
///
/// Gets or sets the public updates channel id.
///
[JsonProperty("public_updates_channel_id", NullValueHandling = NullValueHandling.Ignore)]
public Optional PublicUpdatesChannelId { get; set; }
///
/// Gets or sets the preferred locale.
///
[JsonProperty("preferred_locale")]
public Optional PreferredLocale { get; set; }
///
/// Gets or sets the description.
///
[JsonProperty("description", NullValueHandling = NullValueHandling.Include)]
public Optional Description { get; set; }
///
/// Gets or sets the features.
///
[JsonProperty("features", NullValueHandling = NullValueHandling.Ignore)]
public List Features { get; set; }
}
///
/// Represents a guild member add payload.
///
internal sealed class RestGuildMemberAddPayload : IOAuth2Payload
{
///
/// Gets or sets the access token.
///
[JsonProperty("access_token")]
public string AccessToken { get; set; }
///
/// Gets or sets the nickname.
///
[JsonProperty("nick", NullValueHandling = NullValueHandling.Ignore)]
public string Nickname { get; set; }
///
/// Gets or sets the roles.
///
[JsonProperty("roles", NullValueHandling = NullValueHandling.Ignore)]
public IEnumerable Roles { get; set; }
///
/// Gets or sets a value indicating whether mute.
///
[JsonProperty("mute", NullValueHandling = NullValueHandling.Ignore)]
public bool? Mute { get; set; }
///
/// Gets or sets a value indicating whether deaf.
///
[JsonProperty("deaf", NullValueHandling = NullValueHandling.Ignore)]
public bool? Deaf { get; set; }
}
///
/// Represents a guild channel reorder payload.
///
-internal sealed class RestGuildChannelReorderPayload : ApiObject
+internal sealed class RestGuildChannelReorderPayload : ObservableApiObject
{
///
/// Gets or sets the channel id.
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public ulong ChannelId { get; set; }
///
/// Gets or sets the position.
///
[JsonProperty("position", NullValueHandling = NullValueHandling.Ignore)]
public int Position { get; set; }
}
///
/// Represents a guild channel new parent payload.
///
-internal sealed class RestGuildChannelNewParentPayload : ApiObject
+internal sealed class RestGuildChannelNewParentPayload : ObservableApiObject
{
///
/// Gets or sets the channel id.
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public ulong ChannelId { get; set; }
///
/// Gets or sets the position.
///
[JsonProperty("position", NullValueHandling = NullValueHandling.Ignore)]
public int Position { get; set; }
///
/// Gets or sets the parent id.
///
[JsonProperty("parent_id", NullValueHandling = NullValueHandling.Ignore)]
public Optional ParentId { get; set; }
///
/// Gets or sets a value indicating whether lock permissions.
///
[JsonProperty("lock_permissions", NullValueHandling = NullValueHandling.Ignore)]
public bool? LockPermissions { get; set; }
}
///
/// Represents a guild channel no parent payload.
///
-internal sealed class RestGuildChannelNoParentPayload : ApiObject
+internal sealed class RestGuildChannelNoParentPayload : ObservableApiObject
{
///
/// Gets or sets the channel id.
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public ulong ChannelId { get; set; }
///
/// Gets or sets the position.
///
[JsonProperty("position", NullValueHandling = NullValueHandling.Ignore)]
public int Position { get; set; }
///
/// Gets or sets the parent id.
///
[JsonProperty("parent_id", NullValueHandling = NullValueHandling.Include)]
public Optional ParentId { get; set; }
}
///
/// Represents a guild role reorder payload.
///
internal sealed class RestGuildRoleReorderPayload
{
///
/// Gets or sets the role id.
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public ulong RoleId { get; set; }
///
/// Gets or sets the position.
///
[JsonProperty("position", NullValueHandling = NullValueHandling.Ignore)]
public int Position { get; set; }
}
///
/// Represents a guild member modify payload.
///
-internal sealed class RestGuildMemberModifyPayload : ApiObject
+internal sealed class RestGuildMemberModifyPayload : ObservableApiObject
{
///
/// Gets or sets the nickname.
///
[JsonProperty("nick")]
public Optional Nickname { get; set; }
///
/// Gets or sets the role ids.
///
[JsonProperty("roles")]
public Optional> RoleIds { get; set; }
///
/// Gets or sets the mute.
///
[JsonProperty("mute")]
public Optional Mute { get; set; }
///
/// Gets or sets the deafen.
///
[JsonProperty("deaf")]
public Optional Deafen { get; set; }
///
/// Gets or sets the voice channel id.
///
[JsonProperty("channel_id")]
public Optional VoiceChannelId { get; set; }
[JsonProperty("flags")]
public Optional Flags { get; set; }
}
///
/// Represents a guild member timeout modify payload.
///
-internal sealed class RestGuildMemberTimeoutModifyPayload : ApiObject
+internal sealed class RestGuildMemberTimeoutModifyPayload : ObservableApiObject
{
///
/// Gets or sets the date until the member can communicate again.
///
[JsonProperty("communication_disabled_until")]
public DateTimeOffset? CommunicationDisabledUntil { get; internal set; }
}
///
/// Represents a guild role payload.
///
-internal sealed class RestGuildRolePayload : ApiObject
+internal sealed class RestGuildRolePayload : ObservableApiObject
{
///
/// Gets or sets the name.
///
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; }
///
/// Gets or sets the permissions.
///
[JsonProperty("permissions", NullValueHandling = NullValueHandling.Ignore)]
public Permissions? Permissions { get; set; }
///
/// Gets or sets the color.
///
[JsonProperty("color", NullValueHandling = NullValueHandling.Ignore)]
public int? Color { get; set; }
///
/// Gets or sets a value indicating whether hoist.
///
[JsonProperty("hoist", NullValueHandling = NullValueHandling.Ignore)]
public bool? Hoist { get; set; }
///
/// Gets or sets a value indicating whether mentionable.
///
[JsonProperty("mentionable", NullValueHandling = NullValueHandling.Ignore)]
public bool? Mentionable { get; set; }
///
/// Gets or sets the icon base64.
///
[JsonProperty("icon")]
public Optional IconBase64 { get; set; }
///
/// Gets or sets the icon base64.
///
[JsonProperty("unicode_emoji")]
public Optional UnicodeEmoji { get; set; }
}
///
/// Represents a guild prune result payload.
///
-internal sealed class RestGuildPruneResultPayload : ApiObject
+internal sealed class RestGuildPruneResultPayload : ObservableApiObject
{
///
/// Gets or sets the pruned.
///
[JsonProperty("pruned", NullValueHandling = NullValueHandling.Ignore)]
public int? Pruned { get; set; }
}
///
/// Represents a guild integration attach payload.
///
-internal sealed class RestGuildIntegrationAttachPayload : ApiObject
+internal sealed class RestGuildIntegrationAttachPayload : ObservableApiObject
{
///
/// Gets or sets the type.
///
[JsonProperty("type")]
public string Type { get; set; }
///
/// Gets or sets the id.
///
[JsonProperty("id")]
public ulong Id { get; set; }
}
///
/// Represents a guild integration modify payload.
///
-internal sealed class RestGuildIntegrationModifyPayload : ApiObject
+internal sealed class RestGuildIntegrationModifyPayload : ObservableApiObject
{
///
/// Gets or sets the expire behavior.
///
[JsonProperty("expire_behavior", NullValueHandling = NullValueHandling.Ignore)]
public int? ExpireBehavior { get; set; }
///
/// Gets or sets the expire grace period.
///
[JsonProperty("expire_grace_period", NullValueHandling = NullValueHandling.Ignore)]
public int? ExpireGracePeriod { get; set; }
///
/// Gets or sets a value indicating whether enable emoticons.
///
[JsonProperty("enable_emoticons", NullValueHandling = NullValueHandling.Ignore)]
public bool? EnableEmoticons { get; set; }
}
///
/// Represents a guild emoji modify payload.
///
-internal class RestGuildEmojiModifyPayload : ApiObject
+internal class RestGuildEmojiModifyPayload : ObservableApiObject
{
///
/// Gets or sets the name.
///
[JsonProperty("name")]
public string Name { get; set; }
///
/// Gets or sets the roles.
///
[JsonProperty("roles", NullValueHandling = NullValueHandling.Ignore)]
public ulong[] Roles { get; set; }
}
///
/// Represents a guild emoji create payload.
///
internal class RestGuildEmojiCreatePayload : RestGuildEmojiModifyPayload
{
///
/// Gets or sets the image b64.
///
[JsonProperty("image")]
public string ImageB64 { get; set; }
}
///
/// Represents a guild widget settings payload.
///
-internal class RestGuildWidgetSettingsPayload : ApiObject
+internal class RestGuildWidgetSettingsPayload : ObservableApiObject
{
///
/// Gets or sets a value indicating whether enabled.
///
[JsonProperty("enabled", NullValueHandling = NullValueHandling.Ignore)]
public bool? Enabled { get; set; }
///
/// Gets or sets the channel id.
///
[JsonProperty("channel_id", NullValueHandling = NullValueHandling.Ignore)]
public ulong? ChannelId { get; set; }
}
///
/// Represents a guild template create or modify payload.
///
-internal class RestGuildTemplateCreateOrModifyPayload : ApiObject
+internal class RestGuildTemplateCreateOrModifyPayload : ObservableApiObject
{
///
/// Gets or sets the name.
///
[JsonProperty("name", NullValueHandling = NullValueHandling.Include)]
public string Name { get; set; }
///
/// Gets or sets the description.
///
[JsonProperty("description", NullValueHandling = NullValueHandling.Include)]
public string Description { get; set; }
}
///
/// Represents a guild membership screening form modify payload.
///
-internal class RestGuildMembershipScreeningFormModifyPayload : ApiObject
+internal class RestGuildMembershipScreeningFormModifyPayload : ObservableApiObject
{
///
/// Gets or sets the enabled.
///
[JsonProperty("enabled", NullValueHandling = NullValueHandling.Ignore)]
public Optional Enabled { get; set; }
///
/// Gets or sets the fields.
///
[JsonProperty("form_fields", NullValueHandling = NullValueHandling.Ignore)]
public Optional Fields { get; set; }
///
/// Gets or sets the description.
///
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public Optional Description { get; set; }
}
///
/// Represents a guild welcome screen modify payload.
///
-internal class RestGuildWelcomeScreenModifyPayload : ApiObject
+internal class RestGuildWelcomeScreenModifyPayload : ObservableApiObject
{
///
/// Gets or sets the enabled.
///
[JsonProperty("enabled", NullValueHandling = NullValueHandling.Ignore)]
public Optional Enabled { get; set; }
///
/// Gets or sets the welcome channels.
///
[JsonProperty("welcome_channels", NullValueHandling = NullValueHandling.Ignore)]
public Optional> WelcomeChannels { get; set; }
///
/// Gets or sets the description.
///
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public Optional Description { get; set; }
}
///
/// Represents a guild update current user voice state payload.
///
-internal class RestGuildUpdateCurrentUserVoiceStatePayload : ApiObject
+internal class RestGuildUpdateCurrentUserVoiceStatePayload : ObservableApiObject
{
///
/// Gets or sets the channel id.
///
[JsonProperty("channel_id")]
public ulong ChannelId { get; set; }
///
/// Gets or sets a value indicating whether suppress.
///
[JsonProperty("suppress", NullValueHandling = NullValueHandling.Ignore)]
public bool? Suppress { get; set; }
///
/// Gets or sets the request to speak timestamp.
///
[JsonProperty("request_to_speak_timestamp", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? RequestToSpeakTimestamp { get; set; }
}
///
/// Represents a guild update user voice state payload.
///
-internal class RestGuildUpdateUserVoiceStatePayload : ApiObject
+internal class RestGuildUpdateUserVoiceStatePayload : ObservableApiObject
{
///
/// Gets or sets the channel id.
///
[JsonProperty("channel_id")]
public ulong ChannelId { get; set; }
///
/// Gets or sets a value indicating whether suppress.
///
[JsonProperty("suppress", NullValueHandling = NullValueHandling.Ignore)]
public bool? Suppress { get; set; }
}
diff --git a/DisCatSharp/Net/Abstractions/Transport/TransportActivity.cs b/DisCatSharp/Net/Abstractions/Transport/TransportActivity.cs
index f411a2a57..0c676cb1e 100644
--- a/DisCatSharp/Net/Abstractions/Transport/TransportActivity.cs
+++ b/DisCatSharp/Net/Abstractions/Transport/TransportActivity.cs
@@ -1,373 +1,373 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Collections.Generic;
using System.Globalization;
using DisCatSharp.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace DisCatSharp.Net.Abstractions;
///
/// Represents a game a user is playing.
///
-internal sealed class TransportActivity : ApiObject
+internal sealed class TransportActivity : ObservableApiObject
{
///
/// Gets or sets the id of user's activity.
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public string Id { get; internal set; }
///
/// Gets or sets the name of the game the user is playing.
///
[JsonProperty("name", NullValueHandling = NullValueHandling.Include)]
public string Name { get; internal set; }
///
/// Gets or sets the stream URI, if applicable.
///
[JsonProperty("url", NullValueHandling = NullValueHandling.Ignore)]
public string StreamUrl { get; internal set; }
///
/// Gets or sets the livestream type.
///
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
public ActivityType ActivityType { get; internal set; }
///
/// Gets or sets the details.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("details", NullValueHandling = NullValueHandling.Ignore)]
public string Details { get; internal set; }
///
/// Gets or sets game state.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("state", NullValueHandling = NullValueHandling.Ignore)]
public string State { get; internal set; }
///
/// Gets the emoji details for a custom status, if any.
///
[JsonProperty("emoji", NullValueHandling = NullValueHandling.Ignore)]
public DiscordEmoji Emoji { get; internal set; }
///
/// Gets ID of the application for which this rich presence is for.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonIgnore]
public ulong? ApplicationId
{
get => this.ApplicationIdStr != null ? ulong.Parse(this.ApplicationIdStr, CultureInfo.InvariantCulture) : null;
internal set => this.ApplicationIdStr = value?.ToString(CultureInfo.InvariantCulture);
}
///
/// Gets or sets the application id string.
///
[JsonProperty("application_id", NullValueHandling = NullValueHandling.Ignore)]
internal string ApplicationIdStr { get; set; }
///
/// Gets or sets instance status.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("instance", NullValueHandling = NullValueHandling.Ignore)]
public bool? Instance { get; internal set; }
///
/// Gets or sets information about the current game's party.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("party", NullValueHandling = NullValueHandling.Ignore)]
public GameParty Party { get; internal set; }
///
/// Gets or sets information about assets related to this rich presence.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("assets", NullValueHandling = NullValueHandling.Ignore)]
public PresenceAssets Assets { get; internal set; }
///
/// Gets or sets information about buttons in this rich presence.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("buttons", NullValueHandling = NullValueHandling.Ignore)]
public IReadOnlyList Buttons { get; internal set; }
///
/// Gets or sets platform in this rich presence.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("platform", NullValueHandling = NullValueHandling.Ignore)]
public string Platform { get; internal set; }
///
/// Gets or sets sync_id in this rich presence.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("sync_id", NullValueHandling = NullValueHandling.Ignore)]
public string SyncId { get; internal set; }
///
/// Gets or sets session_id in this rich presence.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("session_id", NullValueHandling = NullValueHandling.Ignore)]
public string SessionId { get; internal set; }
///
/// Gets or sets information about current game's timestamps.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("timestamps", NullValueHandling = NullValueHandling.Ignore)]
public GameTimestamps Timestamps { get; internal set; }
///
/// Gets or sets information about current game's secret values.
///
/// This is a component of the rich presence, and, as such, can only be used by regular users.
///
[JsonProperty("secrets", NullValueHandling = NullValueHandling.Ignore)]
public GameSecrets Secrets { get; internal set; }
///
/// Initializes a new instance of the class.
///
internal TransportActivity() { }
///
/// Initializes a new instance of the class.
///
/// The game.
internal TransportActivity(DiscordActivity game)
{
if (game == null)
return;
this.Name = game.Name;
this.ActivityType = game.ActivityType;
this.StreamUrl = game.StreamUrl;
}
///
/// Whether this activity is a rich presence.
///
public bool IsRichPresence()
=> this.Details != null || this.State != null || this.ApplicationId != null || this.Instance != null || this.Party != null || this.Assets != null || this.Secrets != null || this.Timestamps != null || this.Buttons != null;
///
/// Whether this activity is a custom status.
///
public bool IsCustomStatus()
=> this.Name == "Custom Status";
///
/// Represents information about assets attached to a rich presence.
///
public class PresenceAssets
{
///
/// Gets the large image asset ID.
///
[JsonProperty("large_image")]
public string LargeImage { get; set; }
///
/// Gets the large image text.
///
[JsonProperty("large_text", NullValueHandling = NullValueHandling.Ignore)]
public string LargeImageText { get; internal set; }
///
/// Gets the small image asset ID.
///
[JsonProperty("small_image")]
internal string SmallImage { get; set; }
///
/// Gets the small image text.
///
[JsonProperty("small_text", NullValueHandling = NullValueHandling.Ignore)]
public string SmallImageText { get; internal set; }
}
///
/// Represents information about rich presence game party.
///
public class GameParty
{
///
/// Gets the game party ID.
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public string Id { get; internal set; }
///
/// Gets the size of the party.
///
[JsonProperty("size", NullValueHandling = NullValueHandling.Ignore)]
public GamePartySize Size { get; internal set; }
///
/// Represents information about party size.
///
[JsonConverter(typeof(GamePartySizeConverter))]
public class GamePartySize
{
///
/// Gets the current number of players in the party.
///
public long Current { get; internal set; }
///
/// Gets the maximum party size.
///
public long Maximum { get; internal set; }
}
}
///
/// Represents information about the game state's timestamps.
///
public class GameTimestamps
{
///
/// Gets the time the game has started.
///
[JsonIgnore]
public DateTimeOffset? Start
=> this.StartInternal != null ? Utilities.GetDateTimeOffsetFromMilliseconds(this.StartInternal.Value, false) : null;
[JsonProperty("start", NullValueHandling = NullValueHandling.Ignore)]
internal long? StartInternal;
///
/// Gets the time the game is going to end.
///
[JsonIgnore]
public DateTimeOffset? End
=> this.EndInternal != null ? Utilities.GetDateTimeOffsetFromMilliseconds(this.EndInternal.Value, false) : null;
[JsonProperty("end", NullValueHandling = NullValueHandling.Ignore)]
internal long? EndInternal;
}
///
/// Represents information about secret values for the Join, Spectate, and Match actions.
///
public class GameSecrets
{
///
/// Gets the secret value for join action.
///
[JsonProperty("join", NullValueHandling = NullValueHandling.Ignore)]
public string Join { get; internal set; }
///
/// Gets the secret value for match action.
///
[JsonProperty("match", NullValueHandling = NullValueHandling.Ignore)]
public string Match { get; internal set; }
///
/// Gets the secret value for spectate action.
///
[JsonProperty("spectate", NullValueHandling = NullValueHandling.Ignore)]
public string Spectate { get; internal set; }
}
}
///
/// Represents a game party size converter.
///
internal sealed class GamePartySizeConverter : JsonConverter
{
///
/// Writes the json.
///
/// The writer.
/// The value.
/// The serializer.
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var obj = value is TransportActivity.GameParty.GamePartySize sinfo
? new object[] { sinfo.Current, sinfo.Maximum }
: null;
serializer.Serialize(writer, obj);
}
///
/// Reads the json.
///
/// The reader.
/// The object type.
/// The existing value.
/// The serializer.
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var arr = this.ReadArrayObject(reader, serializer);
return new TransportActivity.GameParty.GamePartySize
{
Current = (long)arr[0],
Maximum = (long)arr[1],
};
}
///
/// Reads the array object.
///
/// The reader.
/// The serializer.
private JArray ReadArrayObject(JsonReader reader, JsonSerializer serializer) =>
serializer.Deserialize(reader) is not JArray arr || arr.Count != 2
? throw new JsonSerializationException("Expected array of length 2")
: arr;
///
/// Whether it can convert.
///
/// The object type.
public override bool CanConvert(Type objectType) => objectType == typeof(TransportActivity.GameParty.GamePartySize);
}
diff --git a/DisCatSharp/Net/Abstractions/Transport/TransportApplication.cs b/DisCatSharp/Net/Abstractions/Transport/TransportApplication.cs
index d6bc2a479..60944313d 100644
--- a/DisCatSharp/Net/Abstractions/Transport/TransportApplication.cs
+++ b/DisCatSharp/Net/Abstractions/Transport/TransportApplication.cs
@@ -1,207 +1,207 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System.Collections.Generic;
using DisCatSharp.Entities;
using DisCatSharp.Enums;
using Newtonsoft.Json;
namespace DisCatSharp.Net.Abstractions;
///
/// The transport application.
///
-internal sealed class TransportApplication : ApiObject
+internal sealed class TransportApplication : ObservableApiObject
{
///
/// Gets or sets the id.
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Include)]
public ulong Id { get; set; }
///
/// Gets or sets the name.
///
[JsonProperty("name", NullValueHandling = NullValueHandling.Include)]
public string Name { get; set; }
///
/// Gets or sets the icon hash.
///
[JsonProperty("icon", NullValueHandling = NullValueHandling.Include)]
public string IconHash { get; set; }
///
/// Gets or sets the description.
///
[JsonProperty("description", NullValueHandling = NullValueHandling.Include)]
public string Description { get; set; }
///
/// Gets or sets the summary.
///
[JsonProperty("summary", NullValueHandling = NullValueHandling.Include)]
public string Summary { get; set; }
///
/// Whether the bot is public.
///
[JsonProperty("bot_public", NullValueHandling = NullValueHandling.Include)]
public Optional IsPublicBot { get; set; }
///
/// Gets or sets the flags.
///
[JsonProperty("flags", NullValueHandling = NullValueHandling.Include)]
public ApplicationFlags Flags { get; set; }
///
/// Gets or sets the terms of service url.
///
[JsonProperty("terms_of_service_url", NullValueHandling = NullValueHandling.Include)]
public string TermsOfServiceUrl { get; set; }
///
/// Gets or sets the privacy policy url.
///
[JsonProperty("privacy_policy_url", NullValueHandling = NullValueHandling.Include)]
public string PrivacyPolicyUrl { get; set; }
///
/// Gets or sets a value indicating whether the bot requires code grant.
///
[JsonProperty("bot_require_code_grant", NullValueHandling = NullValueHandling.Include)]
public Optional BotRequiresCodeGrant { get; set; }
///
/// Gets or sets a value indicating whether the bot is a hook.
///
[JsonProperty("hook", NullValueHandling = NullValueHandling.Ignore)]
public bool IsHook { get; set; }
///
/// Gets or sets a value indicating whether the bot requires code grant.
///
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
///
/// Gets or sets the rpc origins.
///
[JsonProperty("rpc_origins", NullValueHandling = NullValueHandling.Ignore)]
public List RpcOrigins { get; set; }
///
/// Gets or sets the owner.
///
[JsonProperty("owner", NullValueHandling = NullValueHandling.Include)]
public TransportUser Owner { get; set; }
///
/// Gets or sets the team.
///
[JsonProperty("team", NullValueHandling = NullValueHandling.Include)]
public TransportTeam Team { get; set; }
///
/// Gets or sets the verify key.
///
[JsonProperty("verify_key", NullValueHandling = NullValueHandling.Include)]
public Optional VerifyKey { get; set; }
///
/// Gets or sets the guild id.
///
[JsonProperty("guild_id")]
public Optional GuildId { get; set; }
///
/// Gets or sets the partial guild.
///
[JsonProperty("guild", NullValueHandling = NullValueHandling.Ignore)]
public Optional Guild { get; set; }
///
/// Gets or sets the primary sku id.
///
[JsonProperty("primary_sku_id")]
public Optional PrimarySkuId { get; set; }
///
/// Gets or sets the slug.
///
[JsonProperty("slug")]
public Optional Slug { get; set; }
///
/// Gets or sets the cover image hash.
///
[JsonProperty("cover_image")]
public Optional CoverImageHash { get; set; }
///
/// Gets or sets the custom install url.
///
[JsonProperty("custom_install_url")]
public string CustomInstallUrl { get; set; }
///
/// Gets or sets the install params.
///
[JsonProperty("install_params", NullValueHandling = NullValueHandling.Include)]
public DiscordApplicationInstallParams InstallParams { get; set; }
///
/// Gets or sets the role connection verification entry point.
///
[JsonProperty("role_connections_verification_url")]
public string RoleConnectionsVerificationUrl { get; set; }
///
/// Gets or sets the tags.
///
[JsonProperty("tags", NullValueHandling = NullValueHandling.Include)]
public List Tags { get; set; }
[JsonProperty("approximate_guild_count", NullValueHandling = NullValueHandling.Ignore)]
public Optional ApproximateGuildCount { get; set; }
///
/// Gets or sets the interactions endpoint url.
///
[JsonProperty("interactions_endpoint_url", NullValueHandling = NullValueHandling.Include)]
public Optional InteractionsEndpointUrl { get; set; }
///
/// Gets or sets the rpc origins.
///
[JsonProperty("redirect_uris", NullValueHandling = NullValueHandling.Ignore)]
public Optional> RedirectUris { get; set; }
///
/// Initializes a new instance of the class.
///
internal TransportApplication()
{ }
}
diff --git a/DisCatSharp/Net/Abstractions/Transport/TransportMember.cs b/DisCatSharp/Net/Abstractions/Transport/TransportMember.cs
index fb07c406b..2ed080ad7 100644
--- a/DisCatSharp/Net/Abstractions/Transport/TransportMember.cs
+++ b/DisCatSharp/Net/Abstractions/Transport/TransportMember.cs
@@ -1,128 +1,128 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Collections.Generic;
using DisCatSharp.Entities;
using DisCatSharp.Enums;
using Newtonsoft.Json;
namespace DisCatSharp.Net.Abstractions;
///
/// Represents a transport member.
///
-internal class TransportMember : ApiObject
+internal class TransportMember : ObservableApiObject
{
///
/// Gets the avatar hash.
///
[JsonIgnore]
public string AvatarHash { get; internal set; }
///
/// Gets the guild avatar hash.
///
[JsonProperty("avatar", NullValueHandling = NullValueHandling.Ignore)]
public string GuildAvatarHash { get; internal set; }
///
/// Gets the guild banner hash.
///
[JsonProperty("banner", NullValueHandling = NullValueHandling.Ignore)]
public string GuildBannerHash { get; internal set; }
///
/// Gets the guild bio.
/// This is not available to bots tho.
///
[JsonProperty("bio", NullValueHandling = NullValueHandling.Ignore)]
public string GuildBio { get; internal set; }
///
/// Gets the members's pronouns.
///
[JsonProperty("pronouns", NullValueHandling = NullValueHandling.Ignore)]
public string GuildPronouns { get; internal set; }
///
/// Gets the user.
///
[JsonProperty("user", NullValueHandling = NullValueHandling.Ignore)]
public TransportUser User { get; internal set; }
///
/// Gets the nickname.
///
[JsonProperty("nick", NullValueHandling = NullValueHandling.Ignore)]
public string Nickname { get; internal set; }
///
/// Gets the roles.
///
[JsonProperty("roles", NullValueHandling = NullValueHandling.Ignore)]
public List Roles { get; internal set; }
///
/// Gets the joined at.
///
[JsonProperty("joined_at", NullValueHandling = NullValueHandling.Ignore)]
public DateTime JoinedAt { get; internal set; }
///
/// Whether this member is deafened.
///
[JsonProperty("deaf", NullValueHandling = NullValueHandling.Ignore)]
public bool IsDeafened { get; internal set; }
///
/// Whether this member is muted.
///
[JsonProperty("mute", NullValueHandling = NullValueHandling.Ignore)]
public bool IsMuted { get; internal set; }
///
/// Gets the premium since.
///
[JsonProperty("premium_since", NullValueHandling = NullValueHandling.Ignore)]
public DateTime? PremiumSince { get; internal set; }
///
/// Whether this member is marked as pending.
///
[JsonProperty("pending", NullValueHandling = NullValueHandling.Ignore)]
public bool? IsPending { get; internal set; }
///
/// Gets the timeout time.
///
[JsonProperty("communication_disabled_until", NullValueHandling = NullValueHandling.Include)]
public DateTime? CommunicationDisabledUntil { get; internal set; }
///
/// Gets the members flags.
///
[JsonProperty("flags", NullValueHandling = NullValueHandling.Ignore)]
public MemberFlags MemberFlags { get; internal set; }
}
diff --git a/DisCatSharp/Net/Abstractions/Transport/TransportTeam.cs b/DisCatSharp/Net/Abstractions/Transport/TransportTeam.cs
index be1da97ca..f7f30270c 100644
--- a/DisCatSharp/Net/Abstractions/Transport/TransportTeam.cs
+++ b/DisCatSharp/Net/Abstractions/Transport/TransportTeam.cs
@@ -1,105 +1,105 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System.Collections.Generic;
using DisCatSharp.Entities;
using Newtonsoft.Json;
namespace DisCatSharp.Net.Abstractions;
///
/// The transport team.
///
-internal sealed class TransportTeam : ApiObject
+internal sealed class TransportTeam : ObservableApiObject
{
///
/// Gets or sets the id.
///
[JsonProperty("id")]
public ulong Id { get; set; }
///
/// Gets or sets the name.
///
[JsonProperty("name", NullValueHandling = NullValueHandling.Include)]
public string Name { get; set; }
///
/// Gets or sets the icon hash.
///
[JsonProperty("icon", NullValueHandling = NullValueHandling.Include)]
public string IconHash { get; set; }
///
/// Gets or sets the owner id.
///
[JsonProperty("owner_user_id")]
public ulong OwnerId { get; set; }
///
/// Gets or sets the members.
///
[JsonProperty("members", NullValueHandling = NullValueHandling.Include)]
public List Members { get; set; }
///
/// Initializes a new instance of the class.
///
internal TransportTeam() { }
}
///
/// The transport team member.
///
internal sealed class TransportTeamMember
{
///
/// Gets or sets the membership state.
///
[JsonProperty("membership_state")]
public int MembershipState { get; set; }
///
/// Gets or sets the permissions.
///
[JsonProperty("permissions", NullValueHandling = NullValueHandling.Include)]
public List Permissions { get; set; }
///
/// Gets or sets the team id.
///
[JsonProperty("team_id")]
public ulong TeamId { get; set; }
///
/// Gets or sets the user.
///
[JsonProperty("user", NullValueHandling = NullValueHandling.Include)]
public TransportUser User { get; set; }
///
/// Initializes a new instance of the class.
///
internal TransportTeamMember() { }
}
diff --git a/DisCatSharp/Net/Abstractions/Transport/TransportUser.cs b/DisCatSharp/Net/Abstractions/Transport/TransportUser.cs
index 0a5c3ff7c..02b231ced 100644
--- a/DisCatSharp/Net/Abstractions/Transport/TransportUser.cs
+++ b/DisCatSharp/Net/Abstractions/Transport/TransportUser.cs
@@ -1,195 +1,195 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using DisCatSharp.Attributes;
using DisCatSharp.Entities;
using DisCatSharp.Enums;
using Newtonsoft.Json;
namespace DisCatSharp.Net.Abstractions;
///
/// Represents a transport user.
///
-internal class TransportUser : ApiObject
+internal class TransportUser : ObservableApiObject
{
///
/// Gets the id.
///
[JsonProperty("id")]
public ulong Id { get; internal set; }
///
/// Gets the username.
///
[JsonProperty("username", NullValueHandling = NullValueHandling.Ignore)]
public string Username { get; internal set; }
///
/// Gets this user's global name.
///
[JsonProperty("global_name", NullValueHandling = NullValueHandling.Ignore), DiscordInExperiment]
public string GlobalName { get; internal set; }
///
/// Gets or sets the discriminator.
///
[JsonProperty("discriminator", NullValueHandling = NullValueHandling.Ignore)]
internal string Discriminator { get; set; } = "0";
///
/// Gets the username with discriminator.
///
[JsonIgnore, DiscordDeprecated]
internal string UsernameWithDiscriminator
=> $"{this.Username}#{this.Discriminator}";
///
/// Gets the username with the global name.
///
[JsonIgnore, DiscordInExperiment]
internal string UsernameWithGlobalName
=> $"{this.Username} ({this.GlobalName})";
///
/// Gets the avatar hash.
///
[JsonProperty("avatar", NullValueHandling = NullValueHandling.Ignore)]
public string AvatarHash { get; internal set; }
///
/// Gets the avatar decoration hash.
///
[JsonProperty("avatar_decoration", NullValueHandling = NullValueHandling.Ignore)]
public string AvatarDecorationHash { get; internal set; }
///
/// Gets the banner hash.
///
[JsonProperty("banner", NullValueHandling = NullValueHandling.Ignore)]
public string BannerHash { get; internal set; }
///
/// Gets the banner color.
///
[JsonProperty("accent_color", NullValueHandling = NullValueHandling.Ignore)]
public int? BannerColor { get; internal set; }
///
/// Gets the users theme colors.
///
[JsonProperty("theme_colors", NullValueHandling = NullValueHandling.Ignore)]
#pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public int[]? ThemeColors { get; internal set; }
#pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
///
/// Gets a value indicating whether is bot.
///
[JsonProperty("bot", NullValueHandling = NullValueHandling.Ignore)]
public bool IsBot { get; internal set; }
///
/// Gets a value indicating whether mfa enabled.
///
[JsonProperty("mfa_enabled", NullValueHandling = NullValueHandling.Ignore)]
public bool? MfaEnabled { get; internal set; }
///
/// Gets a value indicating whether verified.
///
[JsonProperty("verified", NullValueHandling = NullValueHandling.Ignore)]
public bool? Verified { get; internal set; }
///
/// Gets the email.
///
[JsonProperty("email", NullValueHandling = NullValueHandling.Ignore)]
public string Email { get; internal set; }
///
/// Gets the premium type.
///
[JsonProperty("premium_type", NullValueHandling = NullValueHandling.Ignore)]
public PremiumType? PremiumType { get; internal set; }
///
/// Gets the locale.
///
[JsonProperty("locale", NullValueHandling = NullValueHandling.Ignore)]
public string Locale { get; internal set; }
///
/// Gets the OAuth flags.
///
[JsonProperty("flags", NullValueHandling = NullValueHandling.Ignore)]
public UserFlags? OAuthFlags { get; internal set; }
///
/// Gets the flags.
///
[JsonProperty("public_flags", NullValueHandling = NullValueHandling.Ignore)]
public UserFlags? Flags { get; internal set; }
///
/// Gets the users bio.
/// This is not available to bots tho.
///
[JsonProperty("bio", NullValueHandling = NullValueHandling.Ignore)]
public string Bio { get; internal set; }
///
/// Gets the users pronouns.
///
[JsonProperty("pronouns", NullValueHandling = NullValueHandling.Ignore)]
public string Pronouns { get; internal set; }
///
/// Initializes a new instance of the class.
///
internal TransportUser() { }
///
/// Initializes a new instance of the class from an existing .
///
/// The other transport user.
internal TransportUser(TransportUser other)
{
this.Id = other.Id;
this.Username = other.Username;
this.Discriminator = other.Discriminator;
this.AvatarHash = other.AvatarHash;
this.BannerHash = other.BannerHash;
this.BannerColor = other.BannerColor;
this.IsBot = other.IsBot;
this.MfaEnabled = other.MfaEnabled;
this.Verified = other.Verified;
this.Email = other.Email;
this.PremiumType = other.PremiumType;
this.Locale = other.Locale;
this.Flags = other.Flags;
this.OAuthFlags = other.OAuthFlags;
this.Bio = other.Bio;
this.Pronouns = other.Pronouns;
}
}
diff --git a/DisCatSharp/Net/Serialization/DiscordJson.cs b/DisCatSharp/Net/Serialization/DiscordJson.cs
index 79be8c5d1..d8c3f2d81 100644
--- a/DisCatSharp/Net/Serialization/DiscordJson.cs
+++ b/DisCatSharp/Net/Serialization/DiscordJson.cs
@@ -1,106 +1,106 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2023 AITSYS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using DisCatSharp.Entities;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace DisCatSharp.Net.Serialization;
///
/// Represents discord json.
///
public static class DiscordJson
{
private static readonly JsonSerializer s_serializer = JsonSerializer.CreateDefault(new JsonSerializerSettings
{
ContractResolver = new OptionalJsonContractResolver()
});
/// Serializes the specified object to a JSON string.
/// The object to serialize.
/// A JSON string representation of the object.
public static string SerializeObject(object value)
=> SerializeObjectInternal(value, null, s_serializer);
- public static T DeserializeObject(string json, BaseDiscordClient discord) where T : ApiObject
+ public static T DeserializeObject(string json, BaseDiscordClient discord) where T : ObservableApiObject
=> DeserializeObjectInternal(json, discord);
/// Populates an object with the values from a JSON node.
/// The token to populate the object with.
/// The object to populate.
public static void PopulateObject(JToken value, object target)
{
using var reader = value.CreateReader();
s_serializer.Populate(reader, target);
}
///
/// Converts this token into an object, passing any properties through extra s if needed.
///
/// The token to convert
/// Type to convert to
/// The converted token
public static T ToDiscordObject(this JToken token)
=> token.ToObject(s_serializer);
///
/// Serializes the object.
///
/// The value.
/// The type.
/// The json serializer.
private static string SerializeObjectInternal(object value, Type type, JsonSerializer jsonSerializer)
{
var stringWriter = new StringWriter(new StringBuilder(256), CultureInfo.InvariantCulture);
using (var jsonTextWriter = new JsonTextWriter(stringWriter))
{
jsonTextWriter.Formatting = jsonSerializer.Formatting;
jsonSerializer.Serialize(jsonTextWriter, value, type);
}
return stringWriter.ToString();
}
- private static T DeserializeObjectInternal(string json, BaseDiscordClient discord) where T : ApiObject
+ private static T DeserializeObjectInternal(string json, BaseDiscordClient discord) where T : ObservableApiObject
{
var obj = JsonConvert.DeserializeObject(json);
obj.Discord = discord;
if (discord.Configuration.ReportMissingFields && obj.AdditionalProperties.Any())
{
discord.Logger.LogInformation("Found missing properties in api response");
foreach (var ap in obj.AdditionalProperties)
discord.Logger.LogInformation("Found field {field} on {object}", ap.Key, obj.GetType().Name);
}
return obj;
}
}