Browse Source

Add IUser abstraction

3.0-old
FiniteReality 5 years ago
parent
commit
4018a182b3
3 changed files with 177 additions and 0 deletions
  1. +88
    -0
      src/Core/Entities/IUser.cs
  2. +21
    -0
      src/Core/NitroType.cs
  3. +68
    -0
      src/Core/UserFlags.cs

+ 88
- 0
src/Core/Entities/IUser.cs View File

@@ -0,0 +1,88 @@
namespace Discord.Core
{
/// <summary>
/// An interface representing the collection of operations that can be
/// performed on a user.
/// </summary>
public interface IUser
{
/// <summary>
/// Gets a value indicating the unique identifier for this user.
/// </summary>
ulong Id { get; }

/// <summary>
/// Gets a value representing the user's username.
/// </summary>
string Username { get; }

/// <summary>
/// Gets a value representing the user's 4-digit discriminator.
/// </summary>
short Discriminator { get; }

/// <summary>
/// Gets a value representing the user's avatar hash, or
/// <code>null</code> if one is not present.
/// </summary>
string? AvatarHash { get; }

/// <summary>
/// Gets a value representing whether the user is a bot account, or
/// <code>null</code> if it is not known.
/// </summary>
bool? IsBot { get; }

/// <summary>
/// Gets a value representing whether the user is an Official Discord
/// System account, or <code>null</code> if it is not known.
/// </summary>
bool? IsSystem { get; }

/// <summary>
/// Gets a value representing whether the user has two-factor
/// authentication enabled, or <code>null</code> if it is not known.
/// </summary>
/// <remarks>
/// If <see cref="IsBot"/> is true, this field represents the owner's
/// two factor authentication status.
/// </remarks>
bool? HasMfaEnabled { get; }

/// <summary>
/// Gets a value representing the user's locale, or <code>null</code>
/// if it is not known.
/// </summary>
string? Locale { get; }

/// <summary>
/// Gets a value representing whether the user's E-Mail address is
/// verified, or <code>null</code> if it is not known.
/// </summary>
bool? EmailVerified { get; }

/// <summary>
/// Gets a value representing the user's E-Mail address, or
/// <code>null</code> if it is not known.
/// </summary>
string? EMailAddress { get; }

/// <summary>
/// Gets a value representing the flags on the user's account, or
/// <code>null</code> if it is not known.
/// </summary>
UserFlags? Flags { get; }

/// <summary>
/// Gets a value representing the type of nitro subscription on the
/// user's account, or <code>null</code> if it is not known.
/// </summary>
NitroType? NitroType { get; }

/// <summary>
/// Gets a value representing the public flags on the user's account,
/// or <code>null</code> if it is not known.
/// </summary>
UserFlags? PublicFlags { get; }
}
}

+ 21
- 0
src/Core/NitroType.cs View File

@@ -0,0 +1,21 @@
namespace Discord.Core
{
/// <summary>
/// The type of Nitro subscription which a <see cref="IUser"/> may have.
/// </summary>
public enum NitroType
{
/// <summary>
/// The user has no nitro subscription.
/// </summary>
None = 0,
/// <summary>
/// The user has Nitro Classic.
/// </summary>
Classic = 1,
/// <summary>
/// The user has Discord Nitro.
/// </summary>
Nitro = 2,
}
}

+ 68
- 0
src/Core/UserFlags.cs View File

@@ -0,0 +1,68 @@
using System;

namespace Discord.Core
{
/// <summary>
/// Flags which may be present on an <see cref="IUser"/>
/// </summary>
[Flags]
public enum UserFlags
{
/// <summary>
/// The user has no flags on their account.
/// </summary>
None = 0,
/// <summary>
/// The user is a Discord employee.
/// </summary>
Employee = 1 << 0,
/// <summary>
/// The user is a Discord partner.
/// </summary>
Parnter = 1 << 1,
/// <summary>
/// The user part of HypeSquad events.
/// </summary>
HypeSquad = 1 << 2,
/// <summary>
/// The user has the first level bug hunter badge.
/// </summary>
BugHunterLevel1 = 1 << 3,
/// <summary>
/// The user is part of HypeSquad Bravery.
/// </summary>
HypeSquadBravery = 1 << 6,
/// <summary>
/// The user is part of HypeSquad Brilliance.
/// </summary>
HypeSquadBrilliance = 1 << 7,
/// <summary>
/// The user is part of HypeSquad Balance.
/// </summary>
HypeSquadBalance = 1 << 8,
/// <summary>
/// The user is an early discord supporter.
/// </summary>
EarlySupporter = 1 << 9,
/// <summary>
/// The user is a team user.
/// </summary>
TeamUser = 1 << 10,
/// <summary>
/// The user is the Discord System user.
/// </summary>
System = 1 << 12,
/// <summary>
/// The user has the second level bug hunter badge.
/// </summary>
BugHunterLevel2 = 1 << 14,
/// <summary>
/// The user is a verified bot.
/// </summary>
VerifiedBot = 1 << 16,
/// <summary>
/// The user is a verified bot developer.
/// </summary>
VerifiedBotDeveloper = 1 << 17,
}
}

Loading…
Cancel
Save