diff --git a/DisCatSharp/Entities/User/DiscordPresence.cs b/DisCatSharp/Entities/User/DiscordPresence.cs index b169eb695..c82b6b1ad 100644 --- a/DisCatSharp/Entities/User/DiscordPresence.cs +++ b/DisCatSharp/Entities/User/DiscordPresence.cs @@ -1,160 +1,163 @@ // 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.Net.Abstractions; using Newtonsoft.Json; namespace DisCatSharp.Entities; /// /// Represents a user presence. /// public sealed class DiscordPresence : ObservableApiObject { /// /// Gets the discord client. /// [JsonIgnore] public new DiscordClient Discord { get; set; } /// /// Gets the internal user. /// [JsonProperty("user")] internal UserWithIdOnly InternalUser { get; set; } /// /// Gets the user that owns this presence. /// [JsonIgnore] public DiscordUser User => this.Discord.GetCachedOrEmptyUserInternal(this.InternalUser.Id); /// /// Gets the user's current activity. /// [JsonIgnore] public DiscordActivity Activity { get; internal set; } /// /// Gets the raw activity. /// internal TransportActivity RawActivity { get; set; } /// /// Gets the user's current activities. /// [JsonIgnore] public IReadOnlyList Activities => this.InternalActivities; [JsonIgnore] internal DiscordActivity[] InternalActivities; /// /// Gets the raw activities. /// [JsonProperty("activities", NullValueHandling = NullValueHandling.Ignore)] internal TransportActivity[] RawActivities { get; set; } /// /// Gets this user's status. /// [JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)] public UserStatus Status { get; internal set; } /// /// Gets the guild id for which this presence was set. /// [JsonProperty("guild_id", NullValueHandling = NullValueHandling.Ignore)] internal ulong GuildId { get; set; } /// /// Gets the guild for which this presence was set. /// [JsonIgnore] public DiscordGuild Guild => this.GuildId != 0 ? this.Discord.GuildsInternal[this.GuildId] : null; /// /// Gets this user's platform-dependent status. /// [JsonProperty("client_status", NullValueHandling = NullValueHandling.Ignore)] public DiscordClientStatus ClientStatus { get; internal set; } /// /// Initializes a new instance of the class. /// + // TODO: Add broadcast field internal DiscordPresence() + : base(new List() { "broadcast" }) { } /// /// Initializes a new instance of the class. /// /// The other. internal DiscordPresence(DiscordPresence other) + : base(new List() { "broadcast" }) { this.Discord = other.Discord; this.Activity = other.Activity; this.RawActivity = other.RawActivity; this.InternalActivities = (DiscordActivity[])other.InternalActivities?.Clone(); this.RawActivities = (TransportActivity[])other.RawActivities?.Clone(); this.Status = other.Status; this.InternalUser = other.InternalUser; } } /// /// Represents a user with only its id. /// -public sealed class UserWithIdOnly +public sealed class UserWithIdOnly : ObservableApiObject { [JsonProperty("id")] public ulong Id { get; internal set; } } /// /// Represents a client status. /// -public sealed class DiscordClientStatus +public sealed class DiscordClientStatus : ObservableApiObject { /// /// Gets the user's status set for an active desktop (Windows, Linux, Mac) application session. /// [JsonProperty("desktop", NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Populate)] public Optional Desktop { get; internal set; } = UserStatus.Offline; /// /// Gets the user's status set for an active mobile (iOS, Android) application session. /// [JsonProperty("mobile", NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Populate)] public Optional Mobile { get; internal set; } = UserStatus.Offline; /// /// Gets the user's status set for an active web (browser, bot account) application session. /// [JsonProperty("web", NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Populate)] public Optional Web { get; internal set; } = UserStatus.Offline; }