From b0de4dd97fed7befb7cdd674afbb7487fa163b82 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Fri, 11 Jan 2019 03:43:46 -0800 Subject: [PATCH] clean up files and add documentation where missing --- .../Entities/Activities/Game.cs | 14 +------- .../Entities/Activities/IActivity.cs | 33 ++++--------------- src/Discord.Net.Core/Entities/Users/IUser.cs | 11 +++++-- .../Entities/Users/PremiumType.cs | 7 +--- .../Entities/Users/UserFlags.cs | 4 --- .../Extensions/ActivityExtensions.cs | 10 +++++- .../Extensions/UserExtensions.cs | 8 +++++ .../Entities/Users/RestUser.cs | 4 +-- .../Entities/Users/SocketGuildUser.cs | 1 - .../Entities/Users/SocketUser.cs | 1 - 10 files changed, 35 insertions(+), 58 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Activities/Game.cs b/src/Discord.Net.Core/Entities/Activities/Game.cs index 70988c9ce..9e6efc5e7 100644 --- a/src/Discord.Net.Core/Entities/Activities/Game.cs +++ b/src/Discord.Net.Core/Entities/Activities/Game.cs @@ -12,19 +12,7 @@ namespace Discord public string Name { get; internal set; } /// public ActivityType Type { get; internal set; } - - public string Url { get; internal set; } - - public GameTimestamps Timestamps { get; internal set; } - - public ulong ApplicationId { get; internal set; } - - public string Details { get; internal set; } - public string State { get; internal set; } - public GameParty Party { get; internal set; } - public GameAsset Assets { get; internal set; } - public GameSecrets Secrets { get; internal set; } - public bool Instance { get; internal set; } + /// public int Flags { get; internal set; } internal Game() { } diff --git a/src/Discord.Net.Core/Entities/Activities/IActivity.cs b/src/Discord.Net.Core/Entities/Activities/IActivity.cs index f806d4283..44fa43d6c 100644 --- a/src/Discord.Net.Core/Entities/Activities/IActivity.cs +++ b/src/Discord.Net.Core/Entities/Activities/IActivity.cs @@ -20,36 +20,15 @@ namespace Discord /// ActivityType Type { get; } /// - /// Gets the Stream URL. Only used when is . + /// The flags that are relevant to this activity. /// + /// + /// This value is determined by bitwise OR-ing values together. + /// Each flag's value can be checked using + /// /// - /// A string containing the URL to the stream. + /// The value of flags for this activity. /// - string Url { get; } - /// - /// Gets the unix timestamps for the start and/or end of the activity. - /// - /// - /// A containing the start and end times, if specified. - /// - GameTimestamps Timestamps { get; } - /// - /// Gets the application Id for the game. - /// - ulong ApplicationId { get; } - /// - /// Gets what the user is currently doing. - /// - string Details { get; } - /// - /// Gets the user's current party status. - /// - string State { get; } - //TODO finish docs - GameParty Party { get; } - GameAsset Assets { get; } - GameSecrets Secrets { get; } - bool Instance { get; } int Flags { get; } } } diff --git a/src/Discord.Net.Core/Entities/Users/IUser.cs b/src/Discord.Net.Core/Entities/Users/IUser.cs index 745750c17..af51d9bb4 100644 --- a/src/Discord.Net.Core/Entities/Users/IUser.cs +++ b/src/Discord.Net.Core/Entities/Users/IUser.cs @@ -112,11 +112,16 @@ namespace Discord /// contains the DM channel associated with this user. /// Task GetOrCreateDMChannelAsync(RequestOptions options = null); - /// - /// The flags on a user's account - /// TODO we could probably have extension methods for determining these + /// The flags that are applied to a user's account. /// + /// + /// This value is determined by bitwise OR-ing values together. + /// Each flag's value can be checked using + /// + /// + /// The value of flags for this user. + /// int Flags { get; } /// /// The type of Nitro subscription diff --git a/src/Discord.Net.Core/Entities/Users/PremiumType.cs b/src/Discord.Net.Core/Entities/Users/PremiumType.cs index 328b68ae2..0f4fd384f 100644 --- a/src/Discord.Net.Core/Entities/Users/PremiumType.cs +++ b/src/Discord.Net.Core/Entities/Users/PremiumType.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Discord { public enum PremiumType { + None = 0, /// /// Includes app perks like animated emojis and avatars, but not games. /// diff --git a/src/Discord.Net.Core/Entities/Users/UserFlags.cs b/src/Discord.Net.Core/Entities/Users/UserFlags.cs index 54b16676e..4f4c57a60 100644 --- a/src/Discord.Net.Core/Entities/Users/UserFlags.cs +++ b/src/Discord.Net.Core/Entities/Users/UserFlags.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Discord { diff --git a/src/Discord.Net.Core/Extensions/ActivityExtensions.cs b/src/Discord.Net.Core/Extensions/ActivityExtensions.cs index 4a989015d..220b54dbc 100644 --- a/src/Discord.Net.Core/Extensions/ActivityExtensions.cs +++ b/src/Discord.Net.Core/Extensions/ActivityExtensions.cs @@ -5,7 +5,15 @@ namespace Discord /// public static class ActivityExtensions { - public static bool CheckFlag(this IActivity activity, ActivityFlag flag) + /// + /// Determines if the given flag is enabled with this activity. + /// + /// The user to check. + /// The to check for. + /// + /// True if the activity has this flag enabled, false otherwise. + /// + public static bool CheckActivityFlag(this IActivity activity, ActivityFlag flag) => (activity.Flags & (int)flag) >= (int)flag; } } diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs index cff3d1a09..92a1d3769 100644 --- a/src/Discord.Net.Core/Extensions/UserExtensions.cs +++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs @@ -161,6 +161,14 @@ namespace Discord public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) => user.Guild.AddBanAsync(user, pruneDays, reason, options); + /// + /// Determines if the user has a given flag applied to their account. + /// + /// The user to check. + /// The to check for. + /// + /// True if the user has the given flag on their account, otherwise false. + /// public static bool CheckUserFlag(this IUser user, UserFlag flag) => (user.Flags & (int)flag) >= (int)flag; } diff --git a/src/Discord.Net.Rest/Entities/Users/RestUser.cs b/src/Discord.Net.Rest/Entities/Users/RestUser.cs index 29cfcd3aa..4b3d90002 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestUser.cs @@ -32,9 +32,9 @@ namespace Discord.Rest public virtual UserStatus Status => UserStatus.Offline; /// public virtual bool IsWebhook => false; - - // TODO clean this up + /// public int Flags { get; private set; } + /// public PremiumType? PremiumType { get; private set; } internal RestUser(BaseDiscordClient discord, ulong id) diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs index 47d9f93b7..659a2eeea 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs @@ -194,6 +194,5 @@ namespace Discord.WebSocket //IVoiceState /// IVoiceChannel IVoiceState.VoiceChannel => VoiceChannel; - } } diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs index ead657da6..b48f52947 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs @@ -42,7 +42,6 @@ namespace Discord.WebSocket public int Flags { get; internal set; } /// public PremiumType? PremiumType { get; internal set; } - /// /// Gets mutual guilds shared with this user. ///