From 4018a182b398c263040f814419f6ab6edc9f7327 Mon Sep 17 00:00:00 2001 From: FiniteReality Date: Sat, 25 Apr 2020 13:41:06 +0100 Subject: [PATCH] Add IUser abstraction --- src/Core/Entities/IUser.cs | 88 ++++++++++++++++++++++++++++++++++++++ src/Core/NitroType.cs | 21 +++++++++ src/Core/UserFlags.cs | 68 +++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 src/Core/Entities/IUser.cs create mode 100644 src/Core/NitroType.cs create mode 100644 src/Core/UserFlags.cs diff --git a/src/Core/Entities/IUser.cs b/src/Core/Entities/IUser.cs new file mode 100644 index 000000000..2183846e1 --- /dev/null +++ b/src/Core/Entities/IUser.cs @@ -0,0 +1,88 @@ +namespace Discord.Core +{ + /// + /// An interface representing the collection of operations that can be + /// performed on a user. + /// + public interface IUser + { + /// + /// Gets a value indicating the unique identifier for this user. + /// + ulong Id { get; } + + /// + /// Gets a value representing the user's username. + /// + string Username { get; } + + /// + /// Gets a value representing the user's 4-digit discriminator. + /// + short Discriminator { get; } + + /// + /// Gets a value representing the user's avatar hash, or + /// null if one is not present. + /// + string? AvatarHash { get; } + + /// + /// Gets a value representing whether the user is a bot account, or + /// null if it is not known. + /// + bool? IsBot { get; } + + /// + /// Gets a value representing whether the user is an Official Discord + /// System account, or null if it is not known. + /// + bool? IsSystem { get; } + + /// + /// Gets a value representing whether the user has two-factor + /// authentication enabled, or null if it is not known. + /// + /// + /// If is true, this field represents the owner's + /// two factor authentication status. + /// + bool? HasMfaEnabled { get; } + + /// + /// Gets a value representing the user's locale, or null + /// if it is not known. + /// + string? Locale { get; } + + /// + /// Gets a value representing whether the user's E-Mail address is + /// verified, or null if it is not known. + /// + bool? EmailVerified { get; } + + /// + /// Gets a value representing the user's E-Mail address, or + /// null if it is not known. + /// + string? EMailAddress { get; } + + /// + /// Gets a value representing the flags on the user's account, or + /// null if it is not known. + /// + UserFlags? Flags { get; } + + /// + /// Gets a value representing the type of nitro subscription on the + /// user's account, or null if it is not known. + /// + NitroType? NitroType { get; } + + /// + /// Gets a value representing the public flags on the user's account, + /// or null if it is not known. + /// + UserFlags? PublicFlags { get; } + } +} diff --git a/src/Core/NitroType.cs b/src/Core/NitroType.cs new file mode 100644 index 000000000..e7a64ff7c --- /dev/null +++ b/src/Core/NitroType.cs @@ -0,0 +1,21 @@ +namespace Discord.Core +{ + /// + /// The type of Nitro subscription which a may have. + /// + public enum NitroType + { + /// + /// The user has no nitro subscription. + /// + None = 0, + /// + /// The user has Nitro Classic. + /// + Classic = 1, + /// + /// The user has Discord Nitro. + /// + Nitro = 2, + } +} diff --git a/src/Core/UserFlags.cs b/src/Core/UserFlags.cs new file mode 100644 index 000000000..cdaefe5af --- /dev/null +++ b/src/Core/UserFlags.cs @@ -0,0 +1,68 @@ +using System; + +namespace Discord.Core +{ + /// + /// Flags which may be present on an + /// + [Flags] + public enum UserFlags + { + /// + /// The user has no flags on their account. + /// + None = 0, + /// + /// The user is a Discord employee. + /// + Employee = 1 << 0, + /// + /// The user is a Discord partner. + /// + Parnter = 1 << 1, + /// + /// The user part of HypeSquad events. + /// + HypeSquad = 1 << 2, + /// + /// The user has the first level bug hunter badge. + /// + BugHunterLevel1 = 1 << 3, + /// + /// The user is part of HypeSquad Bravery. + /// + HypeSquadBravery = 1 << 6, + /// + /// The user is part of HypeSquad Brilliance. + /// + HypeSquadBrilliance = 1 << 7, + /// + /// The user is part of HypeSquad Balance. + /// + HypeSquadBalance = 1 << 8, + /// + /// The user is an early discord supporter. + /// + EarlySupporter = 1 << 9, + /// + /// The user is a team user. + /// + TeamUser = 1 << 10, + /// + /// The user is the Discord System user. + /// + System = 1 << 12, + /// + /// The user has the second level bug hunter badge. + /// + BugHunterLevel2 = 1 << 14, + /// + /// The user is a verified bot. + /// + VerifiedBot = 1 << 16, + /// + /// The user is a verified bot developer. + /// + VerifiedBotDeveloper = 1 << 17, + } +}