Browse Source

Remove unnecessary extension methods and use built-in functionality

pull/1237/head
Chris Johnston 6 years ago
parent
commit
693b0df4ce
9 changed files with 7 additions and 39 deletions
  1. +1
    -1
      src/Discord.Net.Core/Entities/Activities/Game.cs
  2. +1
    -2
      src/Discord.Net.Core/Entities/Activities/IActivity.cs
  3. +1
    -2
      src/Discord.Net.Core/Entities/Users/IUser.cs
  4. +0
    -19
      src/Discord.Net.Core/Extensions/ActivityExtensions.cs
  5. +0
    -11
      src/Discord.Net.Core/Extensions/UserExtensions.cs
  6. +1
    -1
      src/Discord.Net.Rest/API/Common/Game.cs
  7. +1
    -1
      src/Discord.Net.Rest/API/Common/User.cs
  8. +1
    -1
      src/Discord.Net.Rest/Entities/Users/RestUser.cs
  9. +1
    -1
      src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs

+ 1
- 1
src/Discord.Net.Core/Entities/Activities/Game.cs View File

@@ -13,7 +13,7 @@ namespace Discord
/// <inheritdoc/> /// <inheritdoc/>
public ActivityType Type { get; internal set; } public ActivityType Type { get; internal set; }
/// <inheritdoc/> /// <inheritdoc/>
public int Flags { get; internal set; }
public ActivityFlag Flags { get; internal set; }


internal Game() { } internal Game() { }
/// <summary> /// <summary>


+ 1
- 2
src/Discord.Net.Core/Entities/Activities/IActivity.cs View File

@@ -24,11 +24,10 @@ namespace Discord
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This value is determined by bitwise OR-ing <see cref="ActivityFlag"/> values together. /// This value is determined by bitwise OR-ing <see cref="ActivityFlag"/> values together.
/// Each flag's value can be checked using <see cref="ActivityExtensions.CheckActivityFlag(IActivity, ActivityFlag)"/>
/// </remarks> /// </remarks>
/// <returns> /// <returns>
/// The value of flags for this activity. /// The value of flags for this activity.
/// </returns> /// </returns>
int Flags { get; }
ActivityFlag Flags { get; }
} }
} }

+ 1
- 2
src/Discord.Net.Core/Entities/Users/IUser.cs View File

@@ -117,12 +117,11 @@ namespace Discord
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This value is determined by bitwise OR-ing <see cref="UserFlag"/> values together. /// This value is determined by bitwise OR-ing <see cref="UserFlag"/> values together.
/// Each flag's value can be checked using <see cref="UserExtensions.CheckUserFlag(IUser, UserFlag)"/>
/// </remarks> /// </remarks>
/// <returns> /// <returns>
/// The value of flags for this user. /// The value of flags for this user.
/// </returns> /// </returns>
int Flags { get; }
UserFlag Flags { get; }
/// <summary> /// <summary>
/// The type of Nitro subscription that is active on this user's account. /// The type of Nitro subscription that is active on this user's account.
/// </summary> /// </summary>


+ 0
- 19
src/Discord.Net.Core/Extensions/ActivityExtensions.cs View File

@@ -1,19 +0,0 @@
namespace Discord
{
/// <summary>
/// Extension methods for the <see cref="IActivity"/> types.
/// </summary>
public static class ActivityExtensions
{
/// <summary>
/// Determines if the given flag is enabled with this activity.
/// </summary>
/// <param name="user">The user to check.</param>
/// <param name="flag">The <see cref="ActivityFlag"/> to check for.</param>
/// <returns>
/// True if the activity has this flag enabled, false otherwise.
/// </returns>
public static bool CheckActivityFlag(this IActivity activity, ActivityFlag flag)
=> (activity.Flags & (int)flag) >= (int)flag;
}
}

+ 0
- 11
src/Discord.Net.Core/Extensions/UserExtensions.cs View File

@@ -160,16 +160,5 @@ namespace Discord
/// </returns> /// </returns>
public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null)
=> user.Guild.AddBanAsync(user, pruneDays, reason, options); => user.Guild.AddBanAsync(user, pruneDays, reason, options);

/// <summary>
/// Determines if the user has a given flag applied to their account.
/// </summary>
/// <param name="user">The user to check.</param>
/// <param name="flag">The <see cref="UserFlag"/> to check for.</param>
/// <returns>
/// True if the user has the given flag on their account, otherwise false.
/// </returns>
public static bool CheckUserFlag(this IUser user, UserFlag flag)
=> (user.Flags & (int)flag) >= (int)flag;
} }
} }

+ 1
- 1
src/Discord.Net.Rest/API/Common/Game.cs View File

@@ -34,7 +34,7 @@ namespace Discord.API
[JsonProperty("session_id")] [JsonProperty("session_id")]
public Optional<string> SessionId { get; set; } public Optional<string> SessionId { get; set; }
[JsonProperty("Flags")] [JsonProperty("Flags")]
public Optional<int> Flags { get; set; }
public Optional<ActivityFlag> Flags { get; set; }


[OnError] [OnError]
internal void OnError(StreamingContext context, ErrorContext errorContext) internal void OnError(StreamingContext context, ErrorContext errorContext)


+ 1
- 1
src/Discord.Net.Rest/API/Common/User.cs View File

@@ -24,7 +24,7 @@ namespace Discord.API
[JsonProperty("mfa_enabled")] [JsonProperty("mfa_enabled")]
public Optional<bool> MfaEnabled { get; set; } public Optional<bool> MfaEnabled { get; set; }
[JsonProperty("flags")] [JsonProperty("flags")]
public Optional<int> Flags { get; set; }
public Optional<UserFlag> Flags { get; set; }
[JsonProperty("premium_type")] [JsonProperty("premium_type")]
public Optional<PremiumType> PremiumType { get; set; } public Optional<PremiumType> PremiumType { get; set; }
[JsonProperty("locale")] [JsonProperty("locale")]


+ 1
- 1
src/Discord.Net.Rest/Entities/Users/RestUser.cs View File

@@ -33,7 +33,7 @@ namespace Discord.Rest
/// <inheritdoc /> /// <inheritdoc />
public virtual bool IsWebhook => false; public virtual bool IsWebhook => false;
/// <inheritdoc /> /// <inheritdoc />
public int Flags { get; private set; }
public UserFlag Flags { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public PremiumType? PremiumType { get; private set; } public PremiumType? PremiumType { get; private set; }
/// <inheritdoc /> /// <inheritdoc />


+ 1
- 1
src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs View File

@@ -39,7 +39,7 @@ namespace Discord.WebSocket
/// <inheritdoc /> /// <inheritdoc />
public UserStatus Status => Presence.Status; public UserStatus Status => Presence.Status;
/// <inheritdoc /> /// <inheritdoc />
public int Flags { get; internal set; }
public UserFlag Flags { get; internal set; }
/// <inheritdoc /> /// <inheritdoc />
public PremiumType? PremiumType { get; internal set; } public PremiumType? PremiumType { get; internal set; }
/// <inheritdoc /> /// <inheritdoc />


Loading…
Cancel
Save