diff --git a/Discord.Net.sln b/Discord.Net.sln index 8635159e4..b62a7c5ee 100644 --- a/Discord.Net.sln +++ b/Discord.Net.sln @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Gateway.UnitTes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Models", "src\Models\Discord.Net.Models.csproj", "{564A2E82-CE92-42F6-9D4E-8CC09C5CDF17}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Rest", "src\Rest\Discord.Net.Rest.csproj", "{1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -75,6 +77,18 @@ Global {564A2E82-CE92-42F6-9D4E-8CC09C5CDF17}.Release|x64.Build.0 = Release|Any CPU {564A2E82-CE92-42F6-9D4E-8CC09C5CDF17}.Release|x86.ActiveCfg = Release|Any CPU {564A2E82-CE92-42F6-9D4E-8CC09C5CDF17}.Release|x86.Build.0 = Release|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Debug|x64.ActiveCfg = Debug|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Debug|x64.Build.0 = Debug|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Debug|x86.ActiveCfg = Debug|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Debug|x86.Build.0 = Debug|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Release|Any CPU.Build.0 = Release|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Release|x64.ActiveCfg = Release|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Release|x64.Build.0 = Release|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Release|x86.ActiveCfg = Release|Any CPU + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,6 +98,7 @@ Global {54A6E396-5186-4D79-893B-6EFD1CF658CB} = {6D7B7A29-83FE-44F2-85E1-7D44B061EA27} {7EC53EB6-6C15-4FD7-9B83-95F96025C14D} = {A47FC28E-1835-46C3-AFD5-7C048A43C157} {564A2E82-CE92-42F6-9D4E-8CC09C5CDF17} = {CD5CFA4B-143E-4495-8BFD-AF419226CBE5} + {1BD9BEE5-8DAA-429A-8692-A0009D2CB90E} = {CD5CFA4B-143E-4495-8BFD-AF419226CBE5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {36B0BFC9-AF79-4D25-89D4-2EE3C961612B} diff --git a/src/Models/Application/Application.cs b/src/Models/Application/Application.cs deleted file mode 100644 index 4adddeedf..000000000 --- a/src/Models/Application/Application.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an application object. - /// - public record Application - { - /// - /// Creates a with the provided parameters. - /// - /// The id of the app. - /// The name of the app. - /// The icon hash of the app. - /// The description of the app. - /// An array of rpc origin urls, if rpc is enabled. - /// When false only app owner can join the app's bot to guilds. - /// When true the app's bot will only join upon completion of the full oauth2 code grant flow. - /// The url of the app's terms of service. - /// The url of the app's privacy policy. - /// Partial user object containing info on the owner of the application. - /// If this application is a game sold on Discord, this field will be the summary field for the store page of its primary sku. - /// The hex encoded key for verification in interactions and the GameSDK's GetTicket. - /// If the application belongs to a team, this will be a list of the members of that team. - /// If this application is a game sold on Discord, this field will be the guild to which it has been linked. - /// If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists. - /// If this application is a game sold on Discord, this field will be the URL slug that links to the store page. - /// The application's default rich presence invite cover image hash. - /// The application's public flags. - [JsonConstructor] - public Application(Snowflake id, string name, string? icon, string description, Optional rpcOrigins, bool botPublic, bool botRequireCodeGrant, Optional termsOfServiceUrl, Optional privacyPolicyUrl, User owner, string summary, string verifyKey, Team? team, Optional guildId, Optional primarySkuId, Optional slug, Optional coverImage, ApplicationFlags flags) - { - Id = id; - Name = name; - Icon = icon; - Description = description; - RpcOrigins = rpcOrigins; - BotPublic = botPublic; - BotRequireCodeGrant = botRequireCodeGrant; - TermsOfServiceUrl = termsOfServiceUrl; - PrivacyPolicyUrl = privacyPolicyUrl; - Owner = owner; - Summary = summary; - VerifyKey = verifyKey; - Team = team; - GuildId = guildId; - PrimarySkuId = primarySkuId; - Slug = slug; - CoverImage = coverImage; - Flags = flags; - - } - - /// - /// The id of the app. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// The name of the app. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// The icon hash of the app. - /// - [JsonPropertyName("icon")] - public string? Icon { get; } - - /// - /// The description of the app. - /// - [JsonPropertyName("description")] - public string Description { get; } - - /// - /// An array of rpc origin urls, if rpc is enabled. - /// - [JsonPropertyName("rpc_origins")] - public Optional RpcOrigins { get; } - - /// - /// When false only app owner can join the app's bot to guilds. - /// - [JsonPropertyName("bot_public")] - public bool BotPublic { get; } - - /// - /// When true the app's bot will only join upon completion of the full oauth2 code grant flow. - /// - [JsonPropertyName("bot_require_code_grant")] - public bool BotRequireCodeGrant { get; } - - /// - /// The url of the app's terms of service. - /// - [JsonPropertyName("terms_of_service_url")] - public Optional TermsOfServiceUrl { get; } - - /// - /// The url of the app's privacy policy. - /// - [JsonPropertyName("privacy_policy_url")] - public Optional PrivacyPolicyUrl { get; } - - /// - /// Partial user object containing info on the owner of the application. - /// - [JsonPropertyName("owner")] - public User Owner { get; } - - /// - /// If this application is a game sold on Discord, this field will be the summary field for the store page of its primary sku. - /// - [JsonPropertyName("summary")] - public string Summary { get; } - - /// - /// The hex encoded key for verification in interactions and the GameSDK's GetTicket. - /// - [JsonPropertyName("verify_key")] - public string VerifyKey { get; } - - /// - /// If the application belongs to a team, this will be a list of the members of that team. - /// - [JsonPropertyName("team")] - public Team? Team { get; } - - /// - /// If this application is a game sold on Discord, this field will be the guild to which it has been linked. - /// - [JsonPropertyName("guild_id")] - public Optional GuildId { get; } - - /// - /// If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists. - /// - [JsonPropertyName("primary_sku_id")] - public Optional PrimarySkuId { get; } - - /// - /// If this application is a game sold on Discord, this field will be the URL slug that links to the store page. - /// - [JsonPropertyName("slug")] - public Optional Slug { get; } - - /// - /// The application's default rich presence invite cover image hash. - /// - [JsonPropertyName("cover_image")] - public Optional CoverImage { get; } - - /// - /// The application's public flags. - /// - [JsonPropertyName("flags")] - public ApplicationFlags Flags { get; } - } -} diff --git a/src/Models/Application/ApplicationFlags.cs b/src/Models/Application/ApplicationFlags.cs deleted file mode 100644 index 7370e137b..000000000 --- a/src/Models/Application/ApplicationFlags.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the application flags. - /// - [Flags] - public enum ApplicationFlags - { - /// - /// This application has the gateway presence privileged intent. - /// - GatewayPresence = 1 << 12, - - /// - /// This application has the gateway presence limited. - /// - GatewayPresenceLimited = 1 << 13, - - /// - /// This application has the gateway guild members privileged intent. - /// - GatewayGuildMembers = 1 << 14, - - /// - /// This application has the gateway guid members limited. - /// - GatewayGuildMembersLimited = 1 << 15, - - /// - /// This application has the verification for the increase of the guild limit pending. - /// - VerificationPendingGuildLimit = 1 << 16, - - /// - /// This application is embedded. - /// - Embedded = 1 << 17, - } -} diff --git a/src/Models/Applications/Application.cs b/src/Models/Applications/Application.cs new file mode 100644 index 000000000..7962e3901 --- /dev/null +++ b/src/Models/Applications/Application.cs @@ -0,0 +1,126 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord application object. + /// + /// + /// + /// + public record Application + { + /// + /// The id of the . + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// The name of the . + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// The icon hash of the . + /// + [JsonPropertyName("icon")] + public string? Icon { get; init; } + + /// + /// The description of the . + /// + [JsonPropertyName("description")] + public string? Description { get; init; } // Required property candidate + + /// + /// An array of rpc origin urls, if rpc is enabled. + /// + [JsonPropertyName("rpc_origins")] + public Optional RpcOrigins { get; init; } + + /// + /// When false only app owner can join the 's bot to s. + /// + [JsonPropertyName("bot_public")] + public bool BotPublic { get; init; } + + /// + /// When true the app's bot will only join upon completion of the full oauth2 code grant flow. + /// + [JsonPropertyName("bot_require_code_grant")] + public bool BotRequireCodeGrant { get; init; } + + /// + /// The url of the 's terms of service. + /// + [JsonPropertyName("terms_of_service_url")] + public Optional TermsOfServiceUrl { get; init; } + + /// + /// The url of the 's privacy policy. + /// + [JsonPropertyName("privacy_policy_url")] + public Optional PrivacyPolicyUrl { get; init; } + + /// + /// Partial containing info on the owner of the . + /// + [JsonPropertyName("owner")] + public User? Owner { get; init; } // Required property candidate + + /// + /// If this is a game sold on Discord, this field will be + /// the summary field for the store page of its primary sku. + /// + [JsonPropertyName("summary")] + public string? Summary { get; init; } // Required property candidate + + /// + /// The hex encoded key for verification in interactions and the GameSDK's GetTicket. + /// + [JsonPropertyName("verify_key")] + public string? VerifyKey { get; init; } // Required property candidate + + /// + /// If the belongs to a , + /// this will be a list of the s of that . + /// + [JsonPropertyName("team")] + public Team? Team { get; init; } + + /// + /// If this is a game sold on Discord, this field will + /// be the to which it has been linked. + /// + [JsonPropertyName("guild_id")] + public Optional GuildId { get; init; } + + /// + /// If this is a game sold on Discord, this field will + /// be the id of the "Game SKU" that is created, if exists. + /// + [JsonPropertyName("primary_sku_id")] + public Optional PrimarySkuId { get; init; } + + /// + /// If this is a game sold on Discord, this field will + /// be the URL slug that links to the store page. + /// + [JsonPropertyName("slug")] + public Optional Slug { get; init; } + + /// + /// The 's default rich presence invite cover image hash. + /// + [JsonPropertyName("cover_image")] + public Optional CoverImage { get; init; } + + /// + /// The 's public flags. + /// + [JsonPropertyName("flags")] + public ApplicationFlags Flags { get; init; } + } +} diff --git a/src/Models/Applications/ApplicationFlags.cs b/src/Models/Applications/ApplicationFlags.cs new file mode 100644 index 000000000..7f84a892a --- /dev/null +++ b/src/Models/Applications/ApplicationFlags.cs @@ -0,0 +1,44 @@ +using System; + +namespace Discord.Net.Models +{ + /// + /// Declares a flag enum which represents the application flags for an . + /// + /// + /// + /// + [Flags] + public enum ApplicationFlags + { + /// + /// This application has the gateway presence privileged intent. + /// + GatewayPresence = 1 << 12, + + /// + /// This application has the gateway presence limited. + /// + GatewayPresenceLimited = 1 << 13, + + /// + /// This application has the gateway guild members privileged intent. + /// + GatewayGuildMembers = 1 << 14, + + /// + /// This application has the gateway guid members limited. + /// + GatewayGuildMembersLimited = 1 << 15, + + /// + /// This application has the verification for the increase of the guild limit pending. + /// + VerificationPendingGuildLimit = 1 << 16, + + /// + /// This application is embedded. + /// + Embedded = 1 << 17, + } +} diff --git a/src/Models/AuditLog/AuditEntryInfo.cs b/src/Models/AuditLog/AuditEntryInfo.cs deleted file mode 100644 index c8a5f2c9a..000000000 --- a/src/Models/AuditLog/AuditEntryInfo.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an audit entry info object. - /// - public record AuditEntryInfo - { - /// - /// Creates a with the provided parameters. - /// - /// Number of days after which inactive members were kicked. - /// Number of members removed by the prune. - /// Channel in which the entities were targeted. - /// Id of the message that was targeted. - /// Number of entities that were targeted. - /// Id of the overwritten entity. - /// Type of overwritten entity. - /// Name of the role if type is (not present if type is ). - [JsonConstructor] - public AuditEntryInfo(int? deleteMemberDays, int? membersRemoved, Snowflake? channelId, Snowflake? messageId, int? count, Snowflake? id, AuditEntryInfoType? type, string? roleName) - { - DeleteMemberDays = deleteMemberDays; - MembersRemoved = membersRemoved; - ChannelId = channelId; - MessageId = messageId; - Count = count; - Id = id; - Type = type; - RoleName = roleName; - } - - /// - /// Number of days after which inactive members were kicked. - /// - [JsonPropertyName("delete_member_days")] - public int? DeleteMemberDays { get; } - - /// - /// Number of members removed by the prune. - /// - [JsonPropertyName("members_removed")] - public int? MembersRemoved { get; } - - /// - /// Channel in which the entities were targeted. - /// - [JsonPropertyName("channel_id")] - public Snowflake? ChannelId { get; } - - /// - /// Id of the message that was targeted. - /// - [JsonPropertyName("message_id")] - public Snowflake? MessageId { get; } - - /// - /// Number of entities that were targeted. - /// - [JsonPropertyName("count")] - public int? Count { get; } - - /// - /// Id of the overwritten entity. - /// - [JsonPropertyName("id")] - public Snowflake? Id { get; } - - /// - /// Type of overwritten entity. - /// - [JsonPropertyName("type")] - public AuditEntryInfoType? Type { get; } - - /// - /// Name of the role if type is (not present if type is ). - /// - [JsonPropertyName("role_name")] - public string? RoleName { get; } - } -} diff --git a/src/Models/AuditLog/AuditEntryInfoType.cs b/src/Models/AuditLog/AuditEntryInfoType.cs deleted file mode 100644 index b487c2aa4..000000000 --- a/src/Models/AuditLog/AuditEntryInfoType.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Discord.Net.Models -{ - /// - /// Represents the type of the overwritten entity for an audit entry info. - /// - public enum AuditEntryInfoType - { - /// - /// The type of the overwritten entity is a role. - /// - Role = 0, - /// - /// The type of the overwritten entity is a member. - /// - Member = 1, - } -} diff --git a/src/Models/AuditLog/AuditLog.cs b/src/Models/AuditLog/AuditLog.cs deleted file mode 100644 index 960e2607a..000000000 --- a/src/Models/AuditLog/AuditLog.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an audit log object. - /// - public record AuditLog - { - /// - /// Creates a with the provided parameters. - /// - /// List of webhooks found in the audit log. - /// List of users found in the audit log. - /// List of audit log entries. - /// List of partial integration objects. - [JsonConstructor] - public AuditLog(Webhook[] webhooks, User[] users, AuditLogEntry[] auditLogEntries, Integration[] integrations) - { - Webhooks = webhooks; - Users = users; - AuditLogEntries = auditLogEntries; - Integrations = integrations; - } - - /// - /// List of webhooks found in the audit log. - /// - [JsonPropertyName("webhooks")] - public Webhook[] Webhooks { get; } - - /// - /// List of users found in the audit log. - /// - [JsonPropertyName("users")] - public User[] Users { get; } - - /// - /// List of audit log entries. - /// - [JsonPropertyName("audit_log_entries")] - public AuditLogEntry[] AuditLogEntries { get; } - - /// - /// List of partial integration objects. - /// - [JsonPropertyName("integrations")] - public Integration[] Integrations { get; } - } -} diff --git a/src/Models/AuditLog/AuditLogChange.cs b/src/Models/AuditLog/AuditLogChange.cs deleted file mode 100644 index e5cdca8e4..000000000 --- a/src/Models/AuditLog/AuditLogChange.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an audit log change object. - /// - public record AuditLogChange - { - /// - /// Creates a with the provided parameters. - /// - /// New value of the key. - /// Old value of the key. - /// Name of audit log change key. - [JsonConstructor] - public AuditLogChange(Optional newValue, Optional oldValue, string key) - { - NewValue = newValue; - OldValue = oldValue; - Key = key; - } - - /// - /// New value of the key. - /// - [JsonPropertyName("new_value")] - public Optional NewValue { get; } - - /// - /// Old value of the key. - /// - [JsonPropertyName("old_value")] - public Optional OldValue { get; } - - /// - /// Name of audit log change key. - /// - [JsonPropertyName("key")] - public string Key { get; } - } -} diff --git a/src/Models/AuditLog/AuditLogEntry.cs b/src/Models/AuditLog/AuditLogEntry.cs deleted file mode 100644 index 499413166..000000000 --- a/src/Models/AuditLog/AuditLogEntry.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an audit log entry object. - /// - public record AuditLogEntry - { - /// - /// Creates a with the provided parameters. - /// - /// Id of the affected entity (webhook, user, role, etc.). - /// Changes made to the target_id. - /// The user who made the changes. - /// Id of the entry. - /// Type of action that occurred. - /// Additional info for certain action types. - /// The reason for the change (0-512 characters). - [JsonConstructor] - public AuditLogEntry(string? targetId, Optional changes, Snowflake? userId, Snowflake id, AuditLogEvent actionType, Optional options, Optional reason) - { - TargetId = targetId; - Changes = changes; - UserId = userId; - Id = id; - ActionType = actionType; - Options = options; - Reason = reason; - } - - /// - /// Id of the affected entity (webhook, user, role, etc.). - /// - [JsonPropertyName("target_id")] - public string? TargetId { get; } - - /// - /// Changes made to the target_id. - /// - [JsonPropertyName("changes")] - public Optional Changes { get; } - - /// - /// The user who made the changes. - /// - [JsonPropertyName("user_id")] - public Snowflake? UserId { get; } - - /// - /// Id of the entry. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// Type of action that occurred. - /// - [JsonPropertyName("action_type")] - public AuditLogEvent ActionType { get; } - - /// - /// Additional info for certain action types. - /// - [JsonPropertyName("options")] - public Optional Options { get; } - - /// - /// The reason for the change (0-512 characters). - /// - [JsonPropertyName("reason")] - public Optional Reason { get; } - } -} diff --git a/src/Models/AuditLogs/AuditEntryInfoType.cs b/src/Models/AuditLogs/AuditEntryInfoType.cs new file mode 100644 index 000000000..b3e273313 --- /dev/null +++ b/src/Models/AuditLogs/AuditEntryInfoType.cs @@ -0,0 +1,18 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the type of the overwritten entity for an . + /// + public enum AuditEntryInfoType + { + /// + /// The type of the overwritten entity is a . + /// + Role = 0, + + /// + /// The type of the overwritten entity is a . + /// + GuildMember = 1, + } +} diff --git a/src/Models/AuditLogs/AuditLog.cs b/src/Models/AuditLogs/AuditLog.cs new file mode 100644 index 000000000..a57c3ec3b --- /dev/null +++ b/src/Models/AuditLogs/AuditLog.cs @@ -0,0 +1,52 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord audit log object. + /// + /// + /// + /// + public record AuditLog + { + /// + /// Minimum amount of in . + /// + public const int MinimumGetEntryAmount = 1; + + /// + /// Default amount of in . + /// + public const int DefaultGetEntryAmount = 50; + + /// + /// Maximum amount of in . + /// + public const int MaximumGetEntryAmount = 100; + + /// + /// List of s found in the . + /// + [JsonPropertyName("webhooks")] + public Webhook[]? Webhooks { get; init; } // Required property candidate + + /// + /// List of s found in the . + /// + [JsonPropertyName("users")] + public User[]? Users { get; init; } // Required property candidate + + /// + /// List of . + /// + [JsonPropertyName("audit_log_entries")] + public AuditLogEntry[]? AuditLogEntries { get; init; } // Required property candidate + + /// + /// List of partial s. + /// + [JsonPropertyName("integrations")] + public Integration[]? Integrations { get; init; } // Required property candidate + } +} diff --git a/src/Models/AuditLogs/AuditLogChange.cs b/src/Models/AuditLogs/AuditLogChange.cs new file mode 100644 index 000000000..d55731f80 --- /dev/null +++ b/src/Models/AuditLogs/AuditLogChange.cs @@ -0,0 +1,31 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord audit log change object. + /// + /// + /// + /// + public record AuditLogChange + { + /// + /// New value of the key. + /// + [JsonPropertyName("new_value")] + public Optional NewValue { get; } + + /// + /// Old value of the key. + /// + [JsonPropertyName("old_value")] + public Optional OldValue { get; } + + /// + /// Audit log change key that will define the type of value. + /// + [JsonPropertyName("key")] + public AuditLogChangeKey Key { get; } + } +} diff --git a/src/Models/AuditLogs/AuditLogChangeKey.cs b/src/Models/AuditLogs/AuditLogChangeKey.cs new file mode 100644 index 000000000..2ea22b8fb --- /dev/null +++ b/src/Models/AuditLogs/AuditLogChangeKey.cs @@ -0,0 +1,304 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the audit log change key for an . + /// + /// + /// + /// + public enum AuditLogChangeKey + { + // + // Any + // + + /// + /// The id of the changed entity - sometimes used in conjunction with other keys. + /// + Id, + + /// + /// Type of entity created. + /// + Type, + + // + // Guild + // + + /// + /// Name changed. + /// + Name, + + /// + /// Icon changed. + /// + IconHash, + + /// + /// Invite splash page artwork changed. + /// + SplashHash, + + /// + /// Discovery splash changed. + /// + DiscoverySplashHash, + + /// + /// Guild banner changed. + /// + BannerHash, + + /// + /// Owner changed. + /// + OwnerId, + + /// + /// changed. + /// + Region, + + /// + /// Preferred locale changed. + /// + PreferredLocale, + + /// + /// Id of the afk changed. + /// + AfkChannelId, + + /// + /// Afk timeout duration changed. + /// + AfkTimeout, + + /// + /// Id of the rules changed. + /// + RulesChannelId, + + /// + /// Id of the public updates changed. + /// + PublicUpdatesChannelId, + + /// + /// Two-factor auth requirement () changed. + /// + MfaLevel, + + /// + /// Required changed. + /// + VerificationLevel, + + /// + /// Change in the , that changes whose + /// s are scanned and delete for explicit content in the . + /// + ExplicitContentFilter, + + /// + /// Default changed. + /// + DefaultMessageNotifications, + + /// + /// vanity url changed. + /// + VanityUrlCode, + + /// + /// New added. + /// + Add, //TODO: This is actually called $add + + /// + /// removed. + /// + Remove, //TODO: This is actually called $remove + + /// + /// Change in number of days after which inactive and -unassigned s are kicked. + /// + PruneDeleteDays, + + /// + /// enabled/disabled. + /// + WidgetEnabled, + + /// + /// Id of changed. + /// + WidgetChannelId, + + /// + /// Id of the system changed. + /// + SystemChannelId, + + // + // Channel + // + + /// + /// Text or voice position changed. + /// + Position, + + /// + /// Text topic changed. + /// + Topic, + + /// + /// Voice bitrate changed. + /// + Bitrate, + + /// + /// s on a channel changed. + /// + PermissionOverwrites, + + /// + /// nsfw restriction changed. + /// + Nsfw, + + /// + /// Id of the added or removed or bot. + /// + ApplicationId, + + // + // Role + // + + /// + /// for a changed. + /// + Permissions, + + /// + /// color changed. + /// + Color, + + /// + /// is now displayed/no longer displayed separate from other online s. + /// + Hoist, + + /// + /// is now mentionable/unmentionable. + /// + Mentionable, + + /// + /// A on a was allowed for a . + /// + Allow, + + /// + /// A on a was denied for a . + /// + Deny, + + // + // Invite + // + + /// + /// code changed. + /// + Code, + + /// + /// for code changed. + /// + ChannelId, + + /// + /// who created code changed. + /// + InviterId, + + /// + /// Change to the max number of times code can be used. + /// + MaxUses, + + /// + /// Number of times code used changed. + /// + Uses, + + /// + /// How long code lasts changed. + /// + MaxAge, + + /// + /// code is temporary/never expires. + /// + Temporary, + + // + // User + // + + /// + /// server deafened/undeafened. + /// + Deaf, + + /// + /// server muted/unmuted. + /// + Mute, + + /// + /// nickname changed. + /// + Nick, + + /// + /// avatar changed. + /// + AvatarHash, + + // + // Integration + // + + /// + /// enabled/disabled. + /// + EnableEmoticons, + + /// + /// changed. + /// + ExpireBehavior, + + /// + /// changed. + /// + ExpireGracePeriod, + + // + // Voice channel + // + + /// + /// New user limit in a voice . + /// + UserLimit, + } +} diff --git a/src/Models/AuditLogs/AuditLogEntry.cs b/src/Models/AuditLogs/AuditLogEntry.cs new file mode 100644 index 000000000..86f24db04 --- /dev/null +++ b/src/Models/AuditLogs/AuditLogEntry.cs @@ -0,0 +1,55 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord audit log entry object. + /// + /// + /// + /// + public record AuditLogEntry + { + /// + /// Id of the affected entity (webhook, user, role, etc.). + /// + [JsonPropertyName("target_id")] + public string? TargetId { get; init; } + + /// + /// Changes made to the . + /// + [JsonPropertyName("changes")] + public Optional Changes { get; init; } + + /// + /// Id of the user who made the changes. + /// + [JsonPropertyName("user_id")] + public Snowflake? UserId { get; init; } + + /// + /// Id of the entry. + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// Type of action that occurred. + /// + [JsonPropertyName("action_type")] + public AuditLogEvent ActionType { get; init; } + + /// + /// Additional info for certain action types. + /// + [JsonPropertyName("options")] + public Optional Options { get; init; } + + /// + /// The reason for the change. + /// + [JsonPropertyName("reason")] + public Optional Reason { get; init; } + } +} diff --git a/src/Models/AuditLog/AuditLogEvent.cs b/src/Models/AuditLogs/AuditLogEvent.cs similarity index 62% rename from src/Models/AuditLog/AuditLogEvent.cs rename to src/Models/AuditLogs/AuditLogEvent.cs index f3dc94c59..fcc1a6c53 100644 --- a/src/Models/AuditLog/AuditLogEvent.cs +++ b/src/Models/AuditLogs/AuditLogEvent.cs @@ -1,152 +1,190 @@ namespace Discord.Net.Models { /// - /// Specifies the type of audit log event. + /// Declares an enum which represents the audit log event for an . /// - public enum AuditLogEvent : int + /// + /// + /// + public enum AuditLogEvent { /// - /// Default value of this type. + /// Default value of this type. /// None = 0, + /// - /// The guild was updated. + /// The guild was updated. /// GuildUpdate = 1, + /// - /// A channel was created. + /// A channel was created. /// ChannelCreate = 10, + /// - /// A channel was updated. + /// A channel was updated. /// ChannelUpdate = 11, + /// - /// A channel was deleted. + /// A channel was deleted. /// ChannelDelete = 12, + /// - /// A channel overwrite was created. + /// A channel overwrite was created. /// ChannelOverwriteCreate = 13, + /// - /// A channel overwrite was updated. + /// A channel overwrite was updated. /// ChannelOverwriteUpdate = 14, + /// - /// A channel overwrite was deleted. + /// A channel overwrite was deleted. /// ChannelOverwriteDelete = 15, + /// - /// A guild member was kicked. + /// A guild member was kicked. /// MemberKick = 20, + /// - /// A guild member was pruned. + /// A guild member was pruned. /// MemberPrune = 21, + /// - /// A guild member was banned. + /// A guild member was banned. /// MemberBanAdd = 22, + /// - /// A guild member was unbanned. + /// A guild member was unbanned. /// MemberBanRemove = 23, + /// - /// A guild member was updated. + /// A guild member was updated. /// MemberUpdate = 24, + /// - /// A guild role was updated. + /// A guild role was updated. /// MemberRoleUpdate = 25, + /// - /// A guild member was moved. + /// A guild member was moved. /// MemberMove = 26, + /// - /// A guild member was disconnected. + /// A guild member was disconnected. /// MemberDisconnect = 27, + /// - /// A bot was added. + /// A bot was added. /// BotAdd = 28, + /// - /// A role was created. + /// A role was created. /// RoleCreate = 30, + /// - /// A role was updated. + /// A role was updated. /// RoleUpdate = 31, + /// - /// A role was deleted. + /// A role was deleted. /// RoleDelete = 32, + /// - /// An invite was created. + /// An invite was created. /// InviteCreate = 40, + /// - /// An invite was updated. + /// An invite was updated. /// InviteUpdate = 41, + /// - /// An invite was deleted. + /// An invite was deleted. /// InviteDelete = 42, + /// - /// A webhook was created. + /// A webhook was created. /// WebhookCreate = 50, + /// - /// A webhook was updated. + /// A webhook was updated. /// WebhookUpdate = 51, + /// - /// A webhook was deleted. + /// A webhook was deleted. /// WebhookDelete = 52, + /// - /// An emoji was created. + /// An emoji was created. /// EmojiCreate = 60, + /// - /// An emoji was updated. + /// An emoji was updated. /// EmojiUpdate = 61, + /// - /// An emoji was deleted. + /// An emoji was deleted. /// EmojiDelete = 62, + /// - /// A message was deleted. + /// A message was deleted. /// MessageDelete = 72, + /// - /// Message were deleted in bulk. + /// Message were deleted in bulk. /// MessageBulkDelete = 73, + /// - /// A message was pinned. + /// A message was pinned. /// MessagePin = 74, + /// - /// A message was unpinned. + /// A message was unpinned. /// MessageUnpin = 75, + /// - /// An integration was created. + /// An integration was created. /// IntegrationCreate = 80, + /// - /// An integration was updated. + /// An integration was updated. /// IntegrationUpdate = 81, + /// - /// An integration was deleted. + /// An integration was deleted. /// IntegrationDelete = 82, } diff --git a/src/Models/AuditLogs/OptionalAuditEntryInfo.cs b/src/Models/AuditLogs/OptionalAuditEntryInfo.cs new file mode 100644 index 000000000..405a8b146 --- /dev/null +++ b/src/Models/AuditLogs/OptionalAuditEntryInfo.cs @@ -0,0 +1,90 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord optional audit entry info object. + /// + /// + /// + /// + public record OptionalAuditEntryInfo + { + /// + /// Number of days after which inactive members were kicked. + /// + /// + /// Action type: + /// + [JsonPropertyName("delete_member_days")] + public Optional DeleteMemberDays { get; init; } + + /// + /// Number of members removed by the prune. + /// + /// + /// Action type: + /// + [JsonPropertyName("members_removed")] + public Optional MembersRemoved { get; init; } + + /// + /// Channel in which the entities were targeted. + /// + /// + /// Action type: , , + /// , + /// + [JsonPropertyName("channel_id")] + public Optional ChannelId { get; init; } + + /// + /// Id of the message that was targeted. + /// + /// + /// Action type: , + /// + [JsonPropertyName("message_id")] + public Optional MessageId { get; init; } + + /// + /// Number of entities that were targeted. + /// + /// + /// Action type: , , + /// , + /// + [JsonPropertyName("count")] + public Optional Count { get; init; } + + /// + /// Id of the overwritten entity. + /// + /// + /// Action type: , , + /// + /// + [JsonPropertyName("id")] + public Optional Id { get; init; } + + /// + /// Type of overwritten entity. + /// + /// + /// Action type: , , + /// + /// + [JsonPropertyName("type")] + public Optional Type { get; init; } + + /// + /// Name of the role if type is (not present if type is ). + /// + /// + /// Action type: , , + /// + /// + [JsonPropertyName("role_name")] + public Optional RoleName { get; init; } + } +} diff --git a/src/Models/Channel/Channel.cs b/src/Models/Channel/Channel.cs deleted file mode 100644 index 2d8e3d370..000000000 --- a/src/Models/Channel/Channel.cs +++ /dev/null @@ -1,211 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a channel object. - /// - public record Channel - { - /// - /// Creates a with the provided parameters. - /// - /// The id of this channel. - /// The type of channel. - /// The id of the guild (may be missing for some channel objects received over gateway guild dispatches). - /// Sorting position of the channel. - /// Explicit permission overwrites for members and roles. - /// The name of the channel (2-100 characters). - /// The channel topic (0-1024 characters). - /// Whether the channel is nsfw. - /// The id of the last message sent in this channel (may not point to an existing or valid message). - /// The bitrate (in bits) of the voice channel. - /// The user limit of the voice channel. - /// Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected. - /// The recipients of the DM. - /// Icon hash. - /// Id of the creator of the group DM or thread. - /// Application id of the group DM creator if it is bot-created. - /// For guild channels: id of the parent category for a channel (each parent category can contain up to 50 channels), for threads: id of the text channel this thread was created. - /// When the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a message is not pinned. - /// Voice region id for the voice channel, automatic when set to null. - /// The camera video quality mode of the voice channel, 1 when not present. - /// An approximate count of messages in a thread, stops counting at 50. - /// An approximate count of users in a thread, stops counting at 50. - /// Thread-specific fields not needed by other channels. - /// Thread member object for the current user, if they have joined the thread, only included on certain API endpoints. - [JsonConstructor] - public Channel(Snowflake id, ChannelType type, Optional guildId, Optional position, Optional permissionOverwrites, Optional name, Optional topic, Optional nsfw, Optional lastMessageId, Optional bitrate, Optional userLimit, Optional rateLimitPerUser, Optional recipients, Optional icon, Optional ownerId, Optional applicationId, Optional parentId, Optional lastPinTimestamp, Optional rtcRegion, Optional videoQualityMode, Optional messageCount, Optional memberCount, Optional threadMetadata, Optional member) - { - Id = id; - Type = type; - GuildId = guildId; - Position = position; - PermissionOverwrites = permissionOverwrites; - Name = name; - Topic = topic; - Nsfw = nsfw; - LastMessageId = lastMessageId; - Bitrate = bitrate; - UserLimit = userLimit; - RateLimitPerUser = rateLimitPerUser; - Recipients = recipients; - Icon = icon; - OwnerId = ownerId; - ApplicationId = applicationId; - ParentId = parentId; - LastPinTimestamp = lastPinTimestamp; - RtcRegion = rtcRegion; - VideoQualityMode = videoQualityMode; - MessageCount = messageCount; - MemberCount = memberCount; - ThreadMetadata = threadMetadata; - Member = member; - } - - /// - /// The id of this channel. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// The type of channel. - /// - [JsonPropertyName("type")] - public ChannelType Type { get; } - - /// - /// The id of the guild (may be missing for some channel objects received over gateway guild dispatches). - /// - [JsonPropertyName("guild_id")] - public Optional GuildId { get; } - - /// - /// Sorting position of the channel. - /// - [JsonPropertyName("position")] - public Optional Position { get; } - - /// - /// Explicit permission overwrites for members and roles. - /// - [JsonPropertyName("permission_overwrites")] - public Optional PermissionOverwrites { get; } - - /// - /// The name of the channel (2-100 characters). - /// - [JsonPropertyName("name")] - public Optional Name { get; } - - /// - /// The channel topic (0-1024 characters). - /// - [JsonPropertyName("topic")] - public Optional Topic { get; } - - /// - /// Whether the channel is nsfw. - /// - [JsonPropertyName("nsfw")] - public Optional Nsfw { get; } - - /// - /// The id of the last message sent in this channel (may not point to an existing or valid message). - /// - [JsonPropertyName("last_message_id")] - public Optional LastMessageId { get; } - - /// - /// The bitrate (in bits) of the voice channel. - /// - [JsonPropertyName("bitrate")] - public Optional Bitrate { get; } - - /// - /// The user limit of the voice channel. - /// - [JsonPropertyName("user_limit")] - public Optional UserLimit { get; } - - /// - /// Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected. - /// - [JsonPropertyName("rate_limit_per_user")] - public Optional RateLimitPerUser { get; } - - /// - /// The recipients of the DM. - /// - [JsonPropertyName("recipients")] - public Optional Recipients { get; } - - /// - /// Icon hash. - /// - [JsonPropertyName("icon")] - public Optional Icon { get; } - - /// - /// Id of the creator of the group DM or thread. - /// - [JsonPropertyName("owner_id")] - public Optional OwnerId { get; } - - /// - /// Application id of the group DM creator if it is bot-created. - /// - [JsonPropertyName("application_id")] - public Optional ApplicationId { get; } - - /// - /// For guild channels: id of the parent category for a channel (each parent category can contain up to 50 channels), for threads: id of the text channel this thread was created. - /// - [JsonPropertyName("parent_id")] - public Optional ParentId { get; } - - /// - /// When the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a message is not pinned. - /// - [JsonPropertyName("last_pin_timestamp")] - public Optional LastPinTimestamp { get; } - - /// - /// Voice region id for the voice channel, automatic when set to null. - /// - [JsonPropertyName("rtc_region")] - public Optional RtcRegion { get; } - - /// - /// The camera video quality mode of the voice channel, 1 when not present. - /// - [JsonPropertyName("video_quality_mode")] - public Optional VideoQualityMode { get; } - - /// - /// An approximate count of messages in a thread, stops counting at 50. - /// - [JsonPropertyName("message_count")] - public Optional MessageCount { get; } - - /// - /// An approximate count of users in a thread, stops counting at 50. - /// - [JsonPropertyName("member_count")] - public Optional MemberCount { get; } - - /// - /// Thread-specific fields not needed by other channels. - /// - [JsonPropertyName("thread_metadata")] - public Optional ThreadMetadata { get; } - - /// - /// Thread member object for the current user, if they have joined the thread, only included on certain API endpoints. - /// - [JsonPropertyName("member")] - public Optional Member { get; } - } -} diff --git a/src/Models/Channel/ChannelType.cs b/src/Models/Channel/ChannelType.cs deleted file mode 100644 index e2d874171..000000000 --- a/src/Models/Channel/ChannelType.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the channel type. - /// - [Flags] - public enum ChannelType - { - /// - /// A text channel within a server. - /// - GuildText = 0, - - /// - /// A direct message between users. - /// - Dm = 1, - - /// - /// A voice channel within a server. - /// - GuildVoice = 2, - - /// - /// A direct message between multiple users. - /// - GroupDm = 3, - - /// - /// An organizational category that contains up to 50 channels. - /// - GuildCategory = 4, - - /// - /// A channel that users can follow and crosspost into their own server. - /// - GuildNews = 5, - - /// - /// A channel in which game developers can sell their game on Discord. - /// - GuildStore = 6, - - /// - /// A temporary sub-channel within a GUILD_NEWS channel. - /// - GuildNewsThread = 10, - - /// - /// A temporary sub-channel within a GUILD_TEXT channel. - /// - GuildPublicThread = 11, - - /// - /// A temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission. - /// - GuildPrivateThread = 12, - - /// - /// A voice channel for hosting events with an audience. - /// - GuildStageVoice = 13, - } -} diff --git a/src/Models/Channel/FollowedChannel.cs b/src/Models/Channel/FollowedChannel.cs deleted file mode 100644 index f641f032f..000000000 --- a/src/Models/Channel/FollowedChannel.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a followed channel object. - /// - public record FollowedChannel - { - /// - /// Creates a with the provided parameters. - /// - /// Source channel id. - /// Created target webhook id. - [JsonConstructor] - public FollowedChannel(Snowflake channelId, Snowflake webhookId) - { - ChannelId = channelId; - WebhookId = webhookId; - } - - /// - /// Source channel id. - /// - [JsonPropertyName("channel_id")] - public Snowflake ChannelId { get; } - - /// - /// Created target webhook id. - /// - [JsonPropertyName("webhook_id")] - public Snowflake WebhookId { get; } - } -} diff --git a/src/Models/Channel/Message/AllowedMentions.cs b/src/Models/Channel/Message/AllowedMentions.cs deleted file mode 100644 index a818053d0..000000000 --- a/src/Models/Channel/Message/AllowedMentions.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an allowed mentions object. - /// - public record AllowedMentions - { - /// - /// Creates a with the provided parameters. - /// - /// An array of allowed mention types to parse from the content. - /// Array of role_ids to mention (Max size of 100). - /// Array of user_ids to mention (Max size of 100). - /// For replies, whether to mention the author of the message being replied to (default false). - [JsonConstructor] - public AllowedMentions(string[] parse, Snowflake[] roles, Snowflake[] users, bool repliedUser) - { - Parse = parse; - Roles = roles; - Users = users; - RepliedUser = repliedUser; - } - - /// - /// An array of allowed mention types to parse from the content. - /// - [JsonPropertyName("parse")] - public string[] Parse { get; } - - /// - /// Array of role_ids to mention (Max size of 100). - /// - [JsonPropertyName("roles")] - public Snowflake[] Roles { get; } - - /// - /// Array of user_ids to mention (Max size of 100). - /// - [JsonPropertyName("users")] - public Snowflake[] Users { get; } - - /// - /// For replies, whether to mention the author of the message being replied to (default false). - /// - [JsonPropertyName("replied_user")] - public bool RepliedUser { get; } - } -} diff --git a/src/Models/Channel/Message/Attachment.cs b/src/Models/Channel/Message/Attachment.cs deleted file mode 100644 index 1b72bfd85..000000000 --- a/src/Models/Channel/Message/Attachment.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an attachment object. - /// - public record Attachment - { - /// - /// Creates a with the provided parameters. - /// - /// Attachment id. - /// Name of file attached. - /// The attachment's media type. - /// Size of file in bytes. - /// Source url of file. - /// A proxied url of file. - /// Height of file (if image). - /// Width of file (if image). - [JsonConstructor] - public Attachment(Snowflake id, string filename, Optional contentType, int size, string url, string proxyUrl, Optional height, Optional width) - { - Id = id; - Filename = filename; - ContentType = contentType; - Size = size; - Url = url; - ProxyUrl = proxyUrl; - Height = height; - Width = width; - } - - /// - /// Attachment id. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// Name of file attached. - /// - [JsonPropertyName("filename")] - public string Filename { get; } - - /// - /// The attachment's media type. - /// - [JsonPropertyName("content_type")] - public Optional ContentType { get; } - - /// - /// Size of file in bytes. - /// - [JsonPropertyName("size")] - public int Size { get; } - - /// - /// Source url of file. - /// - [JsonPropertyName("url")] - public string Url { get; } - - /// - /// A proxied url of file. - /// - [JsonPropertyName("proxy_url")] - public string ProxyUrl { get; } - - /// - /// Height of file (if image). - /// - [JsonPropertyName("height")] - public Optional Height { get; } - - /// - /// Width of file (if image). - /// - [JsonPropertyName("width")] - public Optional Width { get; } - } -} diff --git a/src/Models/Channel/Message/ChannelMention.cs b/src/Models/Channel/Message/ChannelMention.cs deleted file mode 100644 index 886683323..000000000 --- a/src/Models/Channel/Message/ChannelMention.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a channel mention object. - /// - public record ChannelMention - { - /// - /// Creates a with the provided parameters. - /// - /// Id of the channel. - /// Id of the guild containing the channel. - /// The type of channel. - /// The name of the channel. - [JsonConstructor] - public ChannelMention(Snowflake id, Snowflake guildId, ChannelType type, string name) - { - Id = id; - GuildId = guildId; - Type = type; - Name = name; - } - - /// - /// Id of the channel. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// Id of the guild containing the channel. - /// - [JsonPropertyName("guild_id")] - public Snowflake GuildId { get; } - - /// - /// The type of channel. - /// - [JsonPropertyName("type")] - public ChannelType Type { get; } - - /// - /// The name of the channel. - /// - [JsonPropertyName("name")] - public string Name { get; } - } -} diff --git a/src/Models/Channel/Message/Embed/Embed.cs b/src/Models/Channel/Message/Embed/Embed.cs deleted file mode 100644 index 9ee90565d..000000000 --- a/src/Models/Channel/Message/Embed/Embed.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a embed object. - /// - public record Embed - { - /// - /// Creates a with the provided parameters. - /// - /// Title of embed. - /// Type of embed (always "rich" for webhook embeds). - /// Description of embed. - /// Url of embed. - /// Timestamp of embed content. - /// Color code of the embed. - /// Footer information. - /// Image information. - /// Thumbnail information. - /// Video information. - /// Provider information. - /// Author information. - /// Fields information. - [JsonConstructor] - public Embed(Optional title, Optional type, Optional description, Optional url, Optional timestamp, Optional color, Optional footer, Optional image, Optional thumbnail, Optional video, Optional provider, Optional author, Optional fields) - { - Title = title; - Type = type; - Description = description; - Url = url; - Timestamp = timestamp; - Color = color; - Footer = footer; - Image = image; - Thumbnail = thumbnail; - Video = video; - Provider = provider; - Author = author; - Fields = fields; - } - - /// - /// Title of embed. - /// - [JsonPropertyName("title")] - public Optional Title { get; } - - /// - /// Type of embed (always "rich" for webhook embeds). - /// - [JsonPropertyName("type")] - public Optional Type { get; } - - /// - /// Description of embed. - /// - [JsonPropertyName("description")] - public Optional Description { get; } - - /// - /// Url of embed. - /// - [JsonPropertyName("url")] - public Optional Url { get; } - - /// - /// Timestamp of embed content. - /// - [JsonPropertyName("timestamp")] - public Optional Timestamp { get; } - - /// - /// Color code of the embed. - /// - [JsonPropertyName("color")] - public Optional Color { get; } - - /// - /// Footer information. - /// - [JsonPropertyName("footer")] - public Optional Footer { get; } - - /// - /// Image information. - /// - [JsonPropertyName("image")] - public Optional Image { get; } - - /// - /// Thumbnail information. - /// - [JsonPropertyName("thumbnail")] - public Optional Thumbnail { get; } - - /// - /// Video information. - /// - [JsonPropertyName("video")] - public Optional Video { get; } - - /// - /// Provider information. - /// - [JsonPropertyName("provider")] - public Optional Provider { get; } - - /// - /// Author information. - /// - [JsonPropertyName("author")] - public Optional Author { get; } - - /// - /// Fields information. - /// - [JsonPropertyName("fields")] - public Optional Fields { get; } - } -} diff --git a/src/Models/Channel/Message/Embed/EmbedAuthor.cs b/src/Models/Channel/Message/Embed/EmbedAuthor.cs deleted file mode 100644 index 344c40414..000000000 --- a/src/Models/Channel/Message/Embed/EmbedAuthor.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a embed author object. - /// - public record EmbedAuthor - { - /// - /// Creates a with the provided parameters. - /// - /// Name of author. - /// Url of author. - /// Url of author icon (only supports http(s) and attachments). - /// A proxied url of author icon. - [JsonConstructor] - public EmbedAuthor(Optional name, Optional url, Optional iconUrl, Optional proxyIconUrl) - { - Name = name; - Url = url; - IconUrl = iconUrl; - ProxyIconUrl = proxyIconUrl; - } - - /// - /// Name of author. - /// - [JsonPropertyName("name")] - public Optional Name { get; } - - /// - /// Url of author. - /// - [JsonPropertyName("url")] - public Optional Url { get; } - - /// - /// Url of author icon (only supports http(s) and attachments). - /// - [JsonPropertyName("icon_url")] - public Optional IconUrl { get; } - - /// - /// A proxied url of author icon. - /// - [JsonPropertyName("proxy_icon_url")] - public Optional ProxyIconUrl { get; } - } -} diff --git a/src/Models/Channel/Message/Embed/EmbedField.cs b/src/Models/Channel/Message/Embed/EmbedField.cs deleted file mode 100644 index b4a39de5a..000000000 --- a/src/Models/Channel/Message/Embed/EmbedField.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a embed field object. - /// - public record EmbedField - { - /// - /// Creates a with the provided parameters. - /// - /// Name of the field. - /// Value of the field. - /// Whether or not this field should display inline. - [JsonConstructor] - public EmbedField(string name, string value, Optional inline) - { - Name = name; - Value = value; - Inline = inline; - } - - /// - /// Name of the field. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// Value of the field. - /// - [JsonPropertyName("value")] - public string Value { get; } - - /// - /// Whether or not this field should display inline. - /// - [JsonPropertyName("inline")] - public Optional Inline { get; } - } -} diff --git a/src/Models/Channel/Message/Embed/EmbedFooter.cs b/src/Models/Channel/Message/Embed/EmbedFooter.cs deleted file mode 100644 index ba172dd1b..000000000 --- a/src/Models/Channel/Message/Embed/EmbedFooter.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a embed footer object. - /// - public record EmbedFooter - { - /// - /// Creates a with the provided parameters. - /// - /// Footer text. - /// Url of footer icon (only supports http(s) and attachments). - /// A proxied url of footer icon. - [JsonConstructor] - public EmbedFooter(string text, Optional iconUrl, Optional proxyIconUrl) - { - Text = text; - IconUrl = iconUrl; - ProxyIconUrl = proxyIconUrl; - } - - /// - /// Footer text. - /// - [JsonPropertyName("text")] - public string Text { get; } - - /// - /// Url of footer icon (only supports http(s) and attachments). - /// - [JsonPropertyName("icon_url")] - public Optional IconUrl { get; } - - /// - /// A proxied url of footer icon. - /// - [JsonPropertyName("proxy_icon_url")] - public Optional ProxyIconUrl { get; } - } -} diff --git a/src/Models/Channel/Message/Embed/EmbedImage.cs b/src/Models/Channel/Message/Embed/EmbedImage.cs deleted file mode 100644 index 75984072a..000000000 --- a/src/Models/Channel/Message/Embed/EmbedImage.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a embed image object. - /// - public record EmbedImage - { - /// - /// Creates a with the provided parameters. - /// - /// Source url of image (only supports http(s) and attachments). - /// A proxied url of the image. - /// Height of image. - /// Width of image. - [JsonConstructor] - public EmbedImage(Optional url, Optional proxyUrl, Optional height, Optional width) - { - Url = url; - ProxyUrl = proxyUrl; - Height = height; - Width = width; - } - - /// - /// Source url of image (only supports http(s) and attachments). - /// - [JsonPropertyName("url")] - public Optional Url { get; } - - /// - /// A proxied url of the image. - /// - [JsonPropertyName("proxy_url")] - public Optional ProxyUrl { get; } - - /// - /// Height of image. - /// - [JsonPropertyName("height")] - public Optional Height { get; } - - /// - /// Width of image. - /// - [JsonPropertyName("width")] - public Optional Width { get; } - } -} diff --git a/src/Models/Channel/Message/Embed/EmbedProvider.cs b/src/Models/Channel/Message/Embed/EmbedProvider.cs deleted file mode 100644 index 67349b0c7..000000000 --- a/src/Models/Channel/Message/Embed/EmbedProvider.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a embed provider object. - /// - public record EmbedProvider - { - /// - /// Creates a with the provided parameters. - /// - /// Name of provider. - /// Url of provider. - [JsonConstructor] - public EmbedProvider(Optional name, Optional url) - { - Name = name; - Url = url; - } - - /// - /// Name of provider. - /// - [JsonPropertyName("name")] - public Optional Name { get; } - - /// - /// Url of provider. - /// - [JsonPropertyName("url")] - public Optional Url { get; } - } -} diff --git a/src/Models/Channel/Message/Embed/EmbedThumbnail.cs b/src/Models/Channel/Message/Embed/EmbedThumbnail.cs deleted file mode 100644 index dd20c3911..000000000 --- a/src/Models/Channel/Message/Embed/EmbedThumbnail.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a embed thumbnail object. - /// - public record EmbedThumbnail - { - /// - /// Creates a with the provided parameters. - /// - /// Source url of thumbnail (only supports http(s) and attachments). - /// A proxied url of the thumbnail. - /// Height of thumbnail. - /// Width of thumbnail. - [JsonConstructor] - public EmbedThumbnail(Optional url, Optional proxyUrl, Optional height, Optional width) - { - Url = url; - ProxyUrl = proxyUrl; - Height = height; - Width = width; - } - - /// - /// Source url of thumbnail (only supports http(s) and attachments). - /// - [JsonPropertyName("url")] - public Optional Url { get; } - - /// - /// A proxied url of the thumbnail. - /// - [JsonPropertyName("proxy_url")] - public Optional ProxyUrl { get; } - - /// - /// Height of thumbnail. - /// - [JsonPropertyName("height")] - public Optional Height { get; } - - /// - /// Width of thumbnail. - /// - [JsonPropertyName("width")] - public Optional Width { get; } - } -} diff --git a/src/Models/Channel/Message/Embed/EmbedVideo.cs b/src/Models/Channel/Message/Embed/EmbedVideo.cs deleted file mode 100644 index f0e2cdf1c..000000000 --- a/src/Models/Channel/Message/Embed/EmbedVideo.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a embed video object. - /// - public record EmbedVideo - { - /// - /// Creates a with the provided parameters. - /// - /// Source url of video. - /// A proxied url of the video. - /// Height of video. - /// Width of video. - [JsonConstructor] - public EmbedVideo(Optional url, Optional proxyUrl, Optional height, Optional width) - { - Url = url; - ProxyUrl = proxyUrl; - Height = height; - Width = width; - } - - /// - /// Source url of video. - /// - [JsonPropertyName("url")] - public Optional Url { get; } - - /// - /// A proxied url of the video. - /// - [JsonPropertyName("proxy_url")] - public Optional ProxyUrl { get; } - - /// - /// Height of video. - /// - [JsonPropertyName("height")] - public Optional Height { get; } - - /// - /// Width of video. - /// - [JsonPropertyName("width")] - public Optional Width { get; } - } -} diff --git a/src/Models/Channel/Message/Message.cs b/src/Models/Channel/Message/Message.cs deleted file mode 100644 index 84a45e9b6..000000000 --- a/src/Models/Channel/Message/Message.cs +++ /dev/null @@ -1,259 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a message object. - /// - public record Message - { - /// - /// Creates a with the provided parameters. - /// - /// Id of the message. - /// Id of the channel the message was sent in. - /// Id of the guild the message was sent in. - /// The author of this message (not guaranteed to be a valid user, see below). - /// Member properties for this message's author. - /// Contents of the message. - /// When this message was sent. - /// When this message was edited (or null if never). - /// Whether this was a TTS message. - /// Whether this message mentions everyone. - /// Users specifically mentioned in the message. - /// Roles specifically mentioned in this message. - /// Channels specifically mentioned in this message. - /// Any attached files. - /// Any embedded content. - /// Reactions to the message. - /// Used for validating a message was sent. - /// Whether this message is pinned. - /// If the message is generated by a webhook, this is the webhook's id. - /// Type of message. - /// Sent with Rich Presence-related chat embeds. - /// Sent with Rich Presence-related chat embeds. - /// If the message is a response to an Interaction, this is the id of the interaction's application. - /// Data showing the source of a crosspost, channel follow add, pin, or reply message. - /// Message flags combined as a bitfield. - /// The stickers sent with the message (bots currently can only receive messages with stickers, not send). - /// The message associated with the message_reference. - /// Sent if the message is a response to an Interaction. - /// The thread that was started from this message, includes thread member object. - /// Sent if the message contains components like buttons, action rows, or other interactive components. - [JsonConstructor] - public Message(Snowflake id, Snowflake channelId, Optional guildId, User author, Optional member, string content, DateTimeOffset timestamp, DateTimeOffset? editedTimestamp, bool tts, bool mentionEveryone, UserMention[] mentions, Snowflake[] mentionRoles, Optional mentionChannels, Attachment[] attachments, Embed[] embeds, Optional reactions, Optional nonce, bool pinned, Optional webhookId, int type, Optional activity, Optional application, Optional applicationId, Optional messageReference, Optional flags, Optional stickers, Optional referencedMessage, Optional interaction, Optional thread, Optional components) - { - Id = id; - ChannelId = channelId; - GuildId = guildId; - Author = author; - Member = member; - Content = content; - Timestamp = timestamp; - EditedTimestamp = editedTimestamp; - Tts = tts; - MentionEveryone = mentionEveryone; - Mentions = mentions; - MentionRoles = mentionRoles; - MentionChannels = mentionChannels; - Attachments = attachments; - Embeds = embeds; - Reactions = reactions; - Nonce = nonce; - Pinned = pinned; - WebhookId = webhookId; - Type = type; - Activity = activity; - Application = application; - ApplicationId = applicationId; - MessageReference = messageReference; - Flags = flags; - Stickers = stickers; - ReferencedMessage = referencedMessage; - Interaction = interaction; - Thread = thread; - Components = components; - } - - /// - /// Id of the message. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// Id of the channel the message was sent in. - /// - [JsonPropertyName("channel_id")] - public Snowflake ChannelId { get; } - - /// - /// Id of the guild the message was sent in. - /// - [JsonPropertyName("guild_id")] - public Optional GuildId { get; } - - /// - /// The author of this message (not guaranteed to be a valid user, see below). - /// - [JsonPropertyName("author")] - public User Author { get; } - - /// - /// Member properties for this message's author. - /// - [JsonPropertyName("member")] - public Optional Member { get; } - - /// - /// Contents of the message. - /// - [JsonPropertyName("content")] - public string Content { get; } - - /// - /// When this message was sent. - /// - [JsonPropertyName("timestamp")] - public DateTimeOffset Timestamp { get; } - - /// - /// When this message was edited (or null if never). - /// - [JsonPropertyName("edited_timestamp")] - public DateTimeOffset? EditedTimestamp { get; } - - /// - /// Whether this was a TTS message. - /// - [JsonPropertyName("tts")] - public bool Tts { get; } - - /// - /// Whether this message mentions everyone. - /// - [JsonPropertyName("mention_everyone")] - public bool MentionEveryone { get; } - - /// - /// Users specifically mentioned in the message. - /// - [JsonPropertyName("mentions")] - public UserMention[] Mentions { get; } - - /// - /// Roles specifically mentioned in this message. - /// - [JsonPropertyName("mention_roles")] - public Snowflake[] MentionRoles { get; } - - /// - /// Channels specifically mentioned in this message. - /// - [JsonPropertyName("mention_channels")] - public Optional MentionChannels { get; } - - /// - /// Any attached files. - /// - [JsonPropertyName("attachments")] - public Attachment[] Attachments { get; } - - /// - /// Any embedded content. - /// - [JsonPropertyName("embeds")] - public Embed[] Embeds { get; } - - /// - /// Reactions to the message. - /// - [JsonPropertyName("reactions")] - public Optional Reactions { get; } - - /// - /// Used for validating a message was sent. - /// - [JsonPropertyName("nonce")] - public Optional Nonce { get; } - - /// - /// Whether this message is pinned. - /// - [JsonPropertyName("pinned")] - public bool Pinned { get; } - - /// - /// If the message is generated by a webhook, this is the webhook's id. - /// - [JsonPropertyName("webhook_id")] - public Optional WebhookId { get; } - - /// - /// Type of message. - /// - [JsonPropertyName("type")] - public int Type { get; } - - /// - /// Sent with Rich Presence-related chat embeds. - /// - [JsonPropertyName("activity")] - public Optional Activity { get; } - - /// - /// Sent with Rich Presence-related chat embeds. - /// - [JsonPropertyName("application")] - public Optional Application { get; } - - /// - /// If the message is a response to an Interaction, this is the id of the interaction's application. - /// - [JsonPropertyName("application_id")] - public Optional ApplicationId { get; } - - /// - /// Data showing the source of a crosspost, channel follow add, pin, or reply message. - /// - [JsonPropertyName("message_reference")] - public Optional MessageReference { get; } - - /// - /// Message flags combined as a bitfield. - /// - [JsonPropertyName("flags")] - public Optional Flags { get; } - - /// - /// The stickers sent with the message (bots currently can only receive messages with stickers, not send). - /// - [JsonPropertyName("stickers")] - public Optional Stickers { get; } - - /// - /// The message associated with the message_reference. - /// - [JsonPropertyName("referenced_message")] - public Optional ReferencedMessage { get; } - - /// - /// Sent if the message is a response to an Interaction. - /// - [JsonPropertyName("interaction")] - public Optional Interaction { get; } - - /// - /// The thread that was started from this message, includes thread member object. - /// - [JsonPropertyName("thread")] - public Optional Thread { get; } - - /// - /// Sent if the message contains components like buttons, action rows, or other interactive components. - /// - [JsonPropertyName("components")] - public Optional Components { get; } - } -} diff --git a/src/Models/Channel/Message/MessageActivity.cs b/src/Models/Channel/Message/MessageActivity.cs deleted file mode 100644 index 657b8b9cf..000000000 --- a/src/Models/Channel/Message/MessageActivity.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a message activity object. - /// - public record MessageActivity - { - /// - /// Creates a with the provided parameters. - /// - /// Type of message activity. - /// Party_id from a Rich Presence event. - [JsonConstructor] - public MessageActivity(int type, Optional partyId) - { - Type = type; - PartyId = partyId; - } - - /// - /// Type of message activity. - /// - [JsonPropertyName("type")] - public int Type { get; } - - /// - /// Party_id from a Rich Presence event. - /// - [JsonPropertyName("party_id")] - public Optional PartyId { get; } - } -} diff --git a/src/Models/Channel/Message/MessageActivityType.cs b/src/Models/Channel/Message/MessageActivityType.cs deleted file mode 100644 index 04de9bd33..000000000 --- a/src/Models/Channel/Message/MessageActivityType.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the message activity type. - /// - [Flags] - public enum MessageActivityType - { - /// - /// The message activity is to join. - /// - Join = 1, - - /// - /// The message activity is to spectate a stream. - /// - Spectate = 2, - - /// - /// The message activity is to listen to music. - /// - Listen = 3, - - /// - /// The message activity is to request to join. - /// - JoinRequest = 5, - } -} diff --git a/src/Models/Channel/Message/MessageFlags.cs b/src/Models/Channel/Message/MessageFlags.cs deleted file mode 100644 index 4e16ed323..000000000 --- a/src/Models/Channel/Message/MessageFlags.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the message flags. - /// - [Flags] - public enum MessageFlags - { - /// - /// This message has been published to subscribed channels (via Channel Following). - /// - Crossposted = 1 << 0, - - /// - /// This message originated from a message in another channel (via Channel Following). - /// - IsCrosspost = 1 << 1, - - /// - /// Do not include any embeds when serializing this message. - /// - SuppressEmbeds = 1 << 2, - - /// - /// The source message for this crosspost has been deleted (via Channel Following). - /// - SourceMessageDeleted = 1 << 3, - - /// - /// This message came from the urgent message system. - /// - Urgent = 1 << 4, - - /// - /// This message has an associated thread, with the same id as the message. - /// - HasThread = 1 << 5, - - /// - /// This message is only visible to the user who invoked the Interaction. - /// - Ephemeral = 1 << 6, - - /// - /// This message is an Interaction Response and the bot is "thinking". - /// - Loading = 1 << 7, - } -} diff --git a/src/Models/Channel/Message/MessageReference.cs b/src/Models/Channel/Message/MessageReference.cs deleted file mode 100644 index d7e0e60cf..000000000 --- a/src/Models/Channel/Message/MessageReference.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a message reference object. - /// - public record MessageReference - { - /// - /// Creates a with the provided parameters. - /// - /// Id of the originating message. - /// Id of the originating message's channel. - /// Id of the originating message's guild. - /// When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true. - [JsonConstructor] - public MessageReference(Optional messageId, Optional channelId, Optional guildId, Optional failIfNotExists) - { - MessageId = messageId; - ChannelId = channelId; - GuildId = guildId; - FailIfNotExists = failIfNotExists; - } - - /// - /// Id of the originating message. - /// - [JsonPropertyName("message_id")] - public Optional MessageId { get; } - - /// - /// Id of the originating message's channel. - /// - [JsonPropertyName("channel_id")] - public Optional ChannelId { get; } - - /// - /// Id of the originating message's guild. - /// - [JsonPropertyName("guild_id")] - public Optional GuildId { get; } - - /// - /// When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true. - /// - [JsonPropertyName("fail_if_not_exists")] - public Optional FailIfNotExists { get; } - } -} diff --git a/src/Models/Channel/Message/Reaction.cs b/src/Models/Channel/Message/Reaction.cs deleted file mode 100644 index ec3201514..000000000 --- a/src/Models/Channel/Message/Reaction.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a reaction object. - /// - public record Reaction - { - /// - /// Creates a with the provided parameters. - /// - /// Times this emoji has been used to react. - /// Whether the current user reacted using this emoji. - /// Emoji information. - [JsonConstructor] - public Reaction(int count, bool me, Emoji emoji) - { - Count = count; - Me = me; - Emoji = emoji; - } - - /// - /// Times this emoji has been used to react. - /// - [JsonPropertyName("count")] - public int Count { get; } - - /// - /// Whether the current user reacted using this emoji. - /// - [JsonPropertyName("me")] - public bool Me { get; } - - /// - /// Emoji information. - /// - [JsonPropertyName("emoji")] - public Emoji Emoji { get; } - } -} diff --git a/src/Models/Channel/Message/Sticker.cs b/src/Models/Channel/Message/Sticker.cs deleted file mode 100644 index c4eefb8de..000000000 --- a/src/Models/Channel/Message/Sticker.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a sticker object. - /// - public record Sticker - { - /// - /// Creates a with the provided parameters. - /// - /// Id of the sticker. - /// Id of the pack the sticker is from. - /// Name of the sticker. - /// Description of the sticker. - /// A comma-separated list of tags for the sticker. - /// Sticker asset hash. - /// Type of sticker format. - [JsonConstructor] - public Sticker(Snowflake id, Snowflake packId, string name, string description, Optional tags, string asset, StickerFormatType formatType) - { - Id = id; - PackId = packId; - Name = name; - Description = description; - Tags = tags; - Asset = asset; - FormatType = formatType; - } - - /// - /// Id of the sticker. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// Id of the pack the sticker is from. - /// - [JsonPropertyName("pack_id")] - public Snowflake PackId { get; } - - /// - /// Name of the sticker. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// Description of the sticker. - /// - [JsonPropertyName("description")] - public string Description { get; } - - /// - /// A comma-separated list of tags for the sticker. - /// - [JsonPropertyName("tags")] - public Optional Tags { get; } - - /// - /// Sticker asset hash. - /// - [JsonPropertyName("asset")] - public string Asset { get; } - - /// - /// Type of sticker format. - /// - [JsonPropertyName("format_type")] - public StickerFormatType FormatType { get; } - } -} diff --git a/src/Models/Channel/Message/StickerFormatType.cs b/src/Models/Channel/Message/StickerFormatType.cs deleted file mode 100644 index c735057a6..000000000 --- a/src/Models/Channel/Message/StickerFormatType.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the sticker format type. - /// - [Flags] - public enum StickerFormatType - { - /// - /// The sticker format is a png. - /// - Png = 1, - - /// - /// The sticker format is a apng. - /// - Apng = 2, - - /// - /// The sticker format is a lottie. - /// - Lottie = 3, - } -} diff --git a/src/Models/Channel/Message/UserMention.cs b/src/Models/Channel/Message/UserMention.cs deleted file mode 100644 index 59908b586..000000000 --- a/src/Models/Channel/Message/UserMention.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a user mention object. - /// - public record UserMention : User - { - /// - /// Creates a with the provided parameters. - /// - /// The user's id. - /// The user's username, not unique across the platform. - /// The user's 4-digit discord-tag. - /// The user's avatar hash. - /// Whether the user belongs to an OAuth2 application. - /// Whether the user is an Official Discord System user (part of the urgent message system). - /// Whether the user has two factor enabled on their account. - /// The user's chosen language option. - /// Whether the email on this account has been verified. - /// The user's email. - /// The flags on a user's account. - /// The type of Nitro subscription on a user's account. - /// The public flags on a user's account. - /// Additional partial member field. - [JsonConstructor] - public UserMention(Snowflake id, string username, string discriminator, string? avatar, Optional bot, Optional system, Optional mfaEnabled, Optional locale, Optional verified, Optional email, Optional flags, Optional premiumType, Optional publicFlags, Optional member) - : base(id, username, discriminator, avatar, bot, system, mfaEnabled, locale, verified, email, flags, premiumType, publicFlags) - { - Member = member; - } - - /// - /// Additional partial member field. - /// - [JsonPropertyName("member")] - public Optional Member { get; } - } -} diff --git a/src/Models/Channel/Overwrite.cs b/src/Models/Channel/Overwrite.cs deleted file mode 100644 index 692c9c38e..000000000 --- a/src/Models/Channel/Overwrite.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a overwrite object. - /// - public record Overwrite - { - /// - /// Creates a with the provided parameters. - /// - /// Role or user id. - /// Type of entity this overwrite belongs to. - /// Permission bit set. - /// Permission bit set. - [JsonConstructor] - public Overwrite(Snowflake id, OverwriteType type, string allow, string deny) - { - Id = id; - Type = type; - Allow = allow; - Deny = deny; - } - - /// - /// Role or user id. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// Type of entity this overwrite belongs to. - /// - [JsonPropertyName("type")] - public OverwriteType Type { get; } - - /// - /// Permission bit set. - /// - [JsonPropertyName("allow")] - public string Allow { get; } - - /// - /// Permission bit set. - /// - [JsonPropertyName("deny")] - public string Deny { get; } - } -} diff --git a/src/Models/Channel/OverwriteType.cs b/src/Models/Channel/OverwriteType.cs deleted file mode 100644 index 405697f23..000000000 --- a/src/Models/Channel/OverwriteType.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Discord.Net.Models -{ - /// - /// Represents the type of the overwrite. - /// - public enum OverwriteType - { - /// - /// The type of the overwrite is a role. - /// - Role = 0, - /// - /// The type of the overwrite is a member. - /// - Member = 1, - } -} diff --git a/src/Models/Channel/Thread/ThreadMember.cs b/src/Models/Channel/Thread/ThreadMember.cs deleted file mode 100644 index e28fe1c34..000000000 --- a/src/Models/Channel/Thread/ThreadMember.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a thread member object. - /// - public record ThreadMember - { - /// - /// Creates a with the provided parameters. - /// - /// The id of the thread. - /// The id of the user. - /// The time the current user last joined the thread. - /// Any user-thread settings, currently only used for notifications. - [JsonConstructor] - public ThreadMember(Snowflake id, Snowflake userId, DateTimeOffset joinTimestamp, int flags) - { - Id = id; - UserId = userId; - JoinTimestamp = joinTimestamp; - Flags = flags; - } - - /// - /// The id of the thread. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// The id of the user. - /// - [JsonPropertyName("user_id")] - public Snowflake UserId { get; } - - /// - /// The time the current user last joined the thread. - /// - [JsonPropertyName("join_timestamp")] - public DateTimeOffset JoinTimestamp { get; } - - /// - /// Any user-thread settings, currently only used for notifications. - /// - [JsonPropertyName("flags")] - public int Flags { get; } - } -} diff --git a/src/Models/Channel/Thread/ThreadMetadata.cs b/src/Models/Channel/Thread/ThreadMetadata.cs deleted file mode 100644 index dd653de38..000000000 --- a/src/Models/Channel/Thread/ThreadMetadata.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a thread metadata object. - /// - public record ThreadMetadata - { - /// - /// Creates a with the provided parameters. - /// - /// Whether the thread is archived. - /// Id of the user that last archived or unarchived the thread. - /// Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080. - /// Timestamp when the thread's archive status was last changed, used for calculating recent activity. - /// When a thread is locked, only users with MANAGE_THREADS can unarchive it. - [JsonConstructor] - public ThreadMetadata(bool archived, Optional archiverId, int autoArchiveDuration, DateTimeOffset archiveTimestamp, Optional locked) - { - Archived = archived; - ArchiverId = archiverId; - AutoArchiveDuration = autoArchiveDuration; - ArchiveTimestamp = archiveTimestamp; - Locked = locked; - } - - /// - /// Whether the thread is archived. - /// - [JsonPropertyName("archived")] - public bool Archived { get; } - - /// - /// Id of the user that last archived or unarchived the thread. - /// - [JsonPropertyName("archiver_id")] - public Optional ArchiverId { get; } - - /// - /// Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080. - /// - [JsonPropertyName("auto_archive_duration")] - public int AutoArchiveDuration { get; } - - /// - /// Timestamp when the thread's archive status was last changed, used for calculating recent activity. - /// - [JsonPropertyName("archive_timestamp")] - public DateTimeOffset ArchiveTimestamp { get; } - - /// - /// When a thread is locked, only users with MANAGE_THREADS can unarchive it. - /// - [JsonPropertyName("locked")] - public Optional Locked { get; } - } -} diff --git a/src/Models/Channel/VideoQualityMode.cs b/src/Models/Channel/VideoQualityMode.cs deleted file mode 100644 index eecee2002..000000000 --- a/src/Models/Channel/VideoQualityMode.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the video quality mode type. - /// - [Flags] - public enum VideoQualityMode - { - /// - /// Discord chooses the quality for optimal performance. - /// - Auto = 1, - - /// - /// 720p. - /// - Full = 2, - } -} diff --git a/src/Models/Channels/Channel.cs b/src/Models/Channels/Channel.cs new file mode 100644 index 000000000..9526e815f --- /dev/null +++ b/src/Models/Channels/Channel.cs @@ -0,0 +1,174 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord channel object. + /// + /// + /// + /// + public record Channel + { + /// + /// The id of this . + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// The type of . + /// + [JsonPropertyName("type")] + public ChannelType Type { get; init; } + + /// + /// The id of the . + /// + /// + /// May be missing for some channel objects received over gateway guild dispatches. + /// + [JsonPropertyName("guild_id")] + public Optional GuildId { get; init; } + + /// + /// Sorting position of the . + /// + [JsonPropertyName("position")] + public Optional Position { get; init; } + + /// + /// Explicit permission s for s + /// and s. + /// + [JsonPropertyName("permission_overwrites")] + public Optional PermissionOverwrites { get; init; } + + /// + /// The name of the . + /// + [JsonPropertyName("name")] + public Optional Name { get; init; } + + /// + /// The topic. + /// + [JsonPropertyName("topic")] + public Optional Topic { get; init; } + + /// + /// Whether the is nsfw. + /// + [JsonPropertyName("nsfw")] + public Optional Nsfw { get; init; } + + /// + /// The id of the last sent in this . + /// + /// + /// May not point to an existing or valid message. + /// + [JsonPropertyName("last_message_id")] + public Optional LastMessageId { get; init; } + + /// + /// The bitrate (in bits) of the voice . + /// + [JsonPropertyName("bitrate")] + public Optional Bitrate { get; init; } + + /// + /// The limit of the voice . + /// + [JsonPropertyName("user_limit")] + public Optional UserLimit { get; init; } + + /// + /// Amount of seconds a has to wait before sending another ; + /// bots, as well as s with the permission + /// or , are unaffected. + /// + [JsonPropertyName("rate_limit_per_user")] + public Optional RateLimitPerUser { get; init; } + + /// + /// The recipients of the DM. + /// + [JsonPropertyName("recipients")] + public Optional Recipients { get; init; } + + /// + /// Icon hash. + /// + [JsonPropertyName("icon")] + public Optional Icon { get; init; } + + /// + /// Id of the creator of the group DM or thread. + /// + [JsonPropertyName("owner_id")] + public Optional OwnerId { get; init; } + + /// + /// id of the group DM creator if it is bot-created. + /// + [JsonPropertyName("application_id")] + public Optional ApplicationId { get; init; } + + /// + /// For guild channels: id of the parent category for a channel (each parent + /// category can contain up to 50 channels), for threads: id of the text channel + /// this thread was created. + /// + [JsonPropertyName("parent_id")] + public Optional ParentId { get; init; } + + /// + /// When the last pinned was pinned. + /// + /// + /// This may be null in events such + /// as GUILD_CREATE when a message is not pinned. + /// + [JsonPropertyName("last_pin_timestamp")] + public Optional LastPinTimestamp { get; init; } + + /// + /// Voice region id for the voice , automatic when set to null. + /// + [JsonPropertyName("rtc_region")] + public Optional RtcRegion { get; init; } + + /// + /// The camera video quality mode of the voice channel, 1 when not present. + /// + [JsonPropertyName("video_quality_mode")] + public Optional VideoQualityMode { get; init; } + + /// + /// An approximate count of s in a thread, stops counting at 50. + /// + [JsonPropertyName("message_count")] + public Optional MessageCount { get; init; } + + /// + /// An approximate count of s in a thread, stops counting at 50. + /// + [JsonPropertyName("member_count")] + public Optional MemberCount { get; init; } + + /// + /// Thread-specific fields not needed by other channels. + /// + [JsonPropertyName("thread_metadata")] + public Optional ThreadMetadata { get; init; } + + /// + /// Thread member object for the current user, if they have joined the + /// thread, only included on certain API endpoints. + /// + [JsonPropertyName("member")] + public Optional Member { get; init; } + } +} diff --git a/src/Models/Channels/ChannelType.cs b/src/Models/Channels/ChannelType.cs new file mode 100644 index 000000000..8838457d4 --- /dev/null +++ b/src/Models/Channels/ChannelType.cs @@ -0,0 +1,67 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the channel type for a . + /// + /// + /// + /// + public enum ChannelType + { + /// + /// A text channel within a . + /// + GuildText = 0, + + /// + /// A direct message between s. + /// + Dm = 1, + + /// + /// A voice channel within a server. + /// + GuildVoice = 2, + + /// + /// A direct message between multiple users. + /// + GroupDm = 3, + + /// + /// An organizational category that contains up to 50 channels. + /// + GuildCategory = 4, + + /// + /// A channel that users can follow and crosspost into their own server. + /// + GuildNews = 5, + + /// + /// A channel in which game developers can sell their game on Discord. + /// + GuildStore = 6, + + /// + /// A temporary sub-channel within a GUILD_NEWS channel. + /// + GuildNewsThread = 10, + + /// + /// A temporary sub-channel within a GUILD_TEXT channel. + /// + GuildPublicThread = 11, + + /// + /// A temporary sub-channel within a GUILD_TEXT channel that is only viewable + /// by those invited and those with the permission. + /// + GuildPrivateThread = 12, + + /// + /// A voice channel for hosting events with an audience. + /// + GuildStageVoice = 13, + } +} diff --git a/src/Models/Channels/Emoji.cs b/src/Models/Channels/Emoji.cs new file mode 100644 index 000000000..b0039104f --- /dev/null +++ b/src/Models/Channels/Emoji.cs @@ -0,0 +1,64 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord emoji object. + /// + /// + /// + /// + public record Emoji + { + /// + /// Emoji id. + /// + [JsonPropertyName("id")] + public Snowflake? Id { get; init; } + + /// + /// Emoji name. + /// + /// + /// Can be null only in reaction emoji objects. + /// + [JsonPropertyName("name")] + public string? Name { get; init; } + + /// + /// s allowed to use this emoji. + /// + [JsonPropertyName("roles")] + public Optional Roles { get; init; } + + /// + /// that created this emoji. + /// + [JsonPropertyName("user")] + public Optional User { get; init; } + + /// + /// Whether this emoji must be wrapped in colons. + /// + [JsonPropertyName("require_colons")] + public Optional RequireColons { get; init; } + + /// + /// Whether this emoji is managed. + /// + [JsonPropertyName("managed")] + public Optional Managed { get; init; } + + /// + /// Whether this emoji is animated. + /// + [JsonPropertyName("animated")] + public Optional Animated { get; init; } + + /// + /// Whether this emoji can be used, may be false due to loss of Server Boosts. + /// + [JsonPropertyName("available")] + public Optional Available { get; init; } + } +} diff --git a/src/Models/Channels/FollowedChannel.cs b/src/Models/Channels/FollowedChannel.cs new file mode 100644 index 000000000..33c70208d --- /dev/null +++ b/src/Models/Channels/FollowedChannel.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord followed channel object. + /// + /// + /// + /// + public record FollowedChannel + { + /// + /// Source id. + /// + [JsonPropertyName("channel_id")] + public Snowflake ChannelId { get; init; } + + /// + /// Created target id. + /// + [JsonPropertyName("webhook_id")] + public Snowflake WebhookId { get; init; } + } +} diff --git a/src/Models/Channels/PrivacyLevel.cs b/src/Models/Channels/PrivacyLevel.cs new file mode 100644 index 000000000..49848aba0 --- /dev/null +++ b/src/Models/Channels/PrivacyLevel.cs @@ -0,0 +1,21 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the privacy level for a . + /// + /// + /// + /// + public enum PrivacyLevel + { + /// + /// The is visible publicly, such as on Stage discovery. + /// + Public = 1, + + /// + /// The is visible to only s. + /// + GuildOnly = 2, + } +} diff --git a/src/Models/Channels/StageInstance.cs b/src/Models/Channels/StageInstance.cs new file mode 100644 index 000000000..8279cb6f6 --- /dev/null +++ b/src/Models/Channels/StageInstance.cs @@ -0,0 +1,49 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord stage instance object. + /// + /// + /// + /// + public record StageInstance + { + /// + /// The id of this . + /// + [JsonPropertyName("id")] + public Snowflake Id { get; } + + /// + /// The id of the associated Stage . + /// + [JsonPropertyName("guild_id")] + public Snowflake GuildId { get; } + + /// + /// The id of the associated Stage . + /// + [JsonPropertyName("channel_id")] + public Snowflake ChannelId { get; } + + /// + /// The topic of the . + /// + [JsonPropertyName("topic")] + public string? Topic { get; } // Required property candidate + + /// + /// The of the . + /// + [JsonPropertyName("privacy_level")] + public PrivacyLevel PrivacyLevel { get; } + + /// + /// Whether or not Stage discovery is disabled. + /// + [JsonPropertyName("discoverable_disabled")] + public bool DiscoverableDisabled { get; } + } +} diff --git a/src/Models/Channels/ThreadMember.cs b/src/Models/Channels/ThreadMember.cs new file mode 100644 index 000000000..23a1470a3 --- /dev/null +++ b/src/Models/Channels/ThreadMember.cs @@ -0,0 +1,38 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord thread member object. + /// + /// + /// + /// + public record ThreadMember + { + /// + /// The id of the thread. + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// The id of the . + /// + [JsonPropertyName("user_id")] + public Snowflake UserId { get; init; } + + /// + /// The time the current last joined the thread. + /// + [JsonPropertyName("join_timestamp")] + public DateTimeOffset JoinTimestamp { get; init; } + + /// + /// Any user-thread settings, currently only used for notifications. + /// + [JsonPropertyName("flags")] + public int Flags { get; init; } + } +} diff --git a/src/Models/Channels/ThreadMetadata.cs b/src/Models/Channels/ThreadMetadata.cs new file mode 100644 index 000000000..4bd0feac5 --- /dev/null +++ b/src/Models/Channels/ThreadMetadata.cs @@ -0,0 +1,47 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord thread metadata object. + /// + /// + /// + /// + public record ThreadMetadata + { + /// + /// Whether the thread is archived. + /// + [JsonPropertyName("archived")] + public bool Archived { get; init; } + + /// + /// Id of the that last archived or unarchived the thread. + /// + [JsonPropertyName("archiver_id")] + public Optional ArchiverId { get; init; } + + /// + /// Duration in minutes to automatically archive the thread after + /// recent activity, can be set to: 60, 1440, 4320, 10080. + /// + [JsonPropertyName("auto_archive_duration")] + public int AutoArchiveDuration { get; init; } + + /// + /// Timestamp when the thread's archive status was last changed, used for + /// calculating recent activity. + /// + [JsonPropertyName("archive_timestamp")] + public DateTimeOffset ArchiveTimestamp { get; init; } + + /// + /// When a thread is locked, only s with + /// can unarchive it. + /// + [JsonPropertyName("locked")] + public Optional Locked { get; init; } + } +} diff --git a/src/Models/Channels/VideoQualityMode.cs b/src/Models/Channels/VideoQualityMode.cs new file mode 100644 index 000000000..69103a253 --- /dev/null +++ b/src/Models/Channels/VideoQualityMode.cs @@ -0,0 +1,21 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the video quality mode. + /// + /// + /// + /// + public enum VideoQualityMode + { + /// + /// Discord chooses the quality for optimal performance. + /// + Auto = 1, + + /// + /// 720p. + /// + Full = 2, + } +} diff --git a/src/Models/Channels/WelcomeScreenChannel.cs b/src/Models/Channels/WelcomeScreenChannel.cs new file mode 100644 index 000000000..28aad8256 --- /dev/null +++ b/src/Models/Channels/WelcomeScreenChannel.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a welcome screen channel object. + /// + /// + /// + /// + public record WelcomeScreenChannel + { + /// + /// The 's id. + /// + [JsonPropertyName("channel_id")] + public Snowflake ChannelId { get; init; } + + /// + /// The description shown for the . + /// + [JsonPropertyName("description")] + public string? Description { get; init; } // Required property candidate + + /// + /// The , if the is custom. + /// + [JsonPropertyName("emoji_id")] + public Snowflake? EmojiId { get; init; } + + /// + /// The if custom, the unicode character if standard, or null if no is set. + /// + [JsonPropertyName("emoji_name")] + public string? EmojiName { get; init; } + } +} diff --git a/src/Models/Color.cs b/src/Models/Color.cs new file mode 100644 index 000000000..c25884db5 --- /dev/null +++ b/src/Models/Color.cs @@ -0,0 +1,246 @@ +using System; +using System.Diagnostics; +using StandardColor = System.Drawing.Color; + +namespace Discord.Net +{ + /// + /// Represents a RGB (red, green, blue) color. + /// + [DebuggerDisplay(@"{DebuggerDisplay,nq}")] + public struct Color + { + #region Colors + /// + /// Gets the default user color value. + /// + public static readonly Color Default = new(0); + + /// + /// Gets the teal color value. + /// + public static readonly Color Teal = new(0x1ABC9C); + + /// + /// Gets the dark teal color value. + /// + public static readonly Color DarkTeal = new(0x11806A); + + /// + /// Gets the green color value. + /// + public static readonly Color Green = new(0x2ECC71); + + /// + /// Gets the dark green color value. + /// + public static readonly Color DarkGreen = new(0x1F8B4C); + + /// + /// Gets the blue color value. + /// + public static readonly Color Blue = new(0x3498DB); + + /// + /// Gets the dark blue color value. + /// + public static readonly Color DarkBlue = new(0x206694); + + /// + /// Gets the purple color value. + /// + public static readonly Color Purple = new(0x9B59B6); + + /// + /// Gets the dark purple color value. + /// + public static readonly Color DarkPurple = new(0x71368A); + + /// + /// Gets the magenta color value. + /// + public static readonly Color Magenta = new(0xE91E63); + + /// + /// Gets the dark magenta color value. + /// + public static readonly Color DarkMagenta = new(0xAD1457); + + /// + /// Gets the gold color value. + /// + public static readonly Color Gold = new(0xF1C40F); + + /// + /// Gets the light orange color value. + /// + public static readonly Color LightOrange = new(0xC27C0E); + + /// + /// Gets the orange color value. + /// + public static readonly Color Orange = new(0xE67E22); + + /// + /// Gets the dark orange color value. + /// + public static readonly Color DarkOrange = new(0xA84300); + + /// + /// Gets the red color value. + /// + public static readonly Color Red = new(0xE74C3C); + + /// + /// Gets the dark red color value. + /// + public static readonly Color DarkRed = new(0x992D22); + + /// + /// Gets the light grey color value. + /// + public static readonly Color LightGrey = new(0x979C9F); + + /// + /// Gets the lighter grey color value. + /// + public static readonly Color LighterGrey = new(0x95A5A6); + + /// + /// Gets the dark grey color value. + /// + public static readonly Color DarkGrey = new(0x607D8B); + + /// + /// Gets the darker grey color value. + /// + public static readonly Color DarkerGrey = new(0x546E7A); + + #endregion Colors + + /// + /// Gets the encoded value for this color. + /// + public uint RawValue { get; } + + /// + /// Gets the red component for this color. + /// + public byte R => (byte)(RawValue >> 16); + + /// + /// Gets the green component for this color. + /// + public byte G => (byte)(RawValue >> 8); + + /// + /// Gets the blue component for this color. + /// + public byte B => (byte)(RawValue); + + /// + /// Creates a based on an encoded value. + /// + /// + /// Color encoded value. + /// + public Color(uint rawValue) + { + RawValue = rawValue; + } + + /// + /// Creates a based on the RGB color provided by s. + /// + /// + /// Red color. + /// + /// + /// Green color. + /// + /// + /// Blue color. + /// + public Color(byte red, byte green, byte blue) + { + RawValue = ((uint)red << 16) | ((uint)green << 8) | blue; + } + + /// + /// Creates a based on the RGB color provided by s. + /// + /// + /// Red color. + /// + /// + /// Green color. + /// + /// + /// Blue color. + /// + public Color(int red, int green, int blue) + { + if (red < 0 || red > 255) + throw new ArgumentOutOfRangeException(nameof(red), "Value must be within [0,255]"); + if (green < 0 || green > 255) + throw new ArgumentOutOfRangeException(nameof(green), "Value must be within [0,255]"); + if (blue < 0 || blue > 255) + throw new ArgumentOutOfRangeException(nameof(blue), "Value must be within [0,255]"); + RawValue = ((uint)red << 16) | ((uint)green << 8) | (uint)blue; + } + + /// + /// Creates a based on the RGB color provided by s. + /// + /// + /// Red color. + /// + /// + /// Green color. + /// + /// + /// Blue color. + /// + public Color(float red, float green, float blue) + { + if (red < 0.0f || red > 1.0f) + throw new ArgumentOutOfRangeException(nameof(red), "Value must be within [0,1]"); + if (green < 0.0f || green > 1.0f) + throw new ArgumentOutOfRangeException(nameof(green), "Value must be within [0,1]"); + if (blue < 0.0f || blue > 1.0f) + throw new ArgumentOutOfRangeException(nameof(blue), "Value must be within [0,1]"); + RawValue = + ((uint)(red * 255.0f) << 16) | + ((uint)(green * 255.0f) << 8) | + (uint)(blue * 255.0f); + } + + /// + /// Implicitly converts this to . + /// + /// + /// to convert. + /// + public static implicit operator StandardColor(Color color) + => StandardColor.FromArgb((int)color.RawValue); + + /// + /// Explicitly converts a to a . + /// + /// + /// to convert. + /// + public static explicit operator Color(StandardColor color) + => new((uint)color.ToArgb() << 8 >> 8); + + /// + /// Returns the encoded raw value as . + /// + /// + public override string ToString() + => $"#{Convert.ToString(RawValue, 16)}"; + + private string DebuggerDisplay + => $"#{Convert.ToString(RawValue, 16)} ({RawValue})"; + } +} diff --git a/src/Models/Emoji/Emoji.cs b/src/Models/Emoji/Emoji.cs deleted file mode 100644 index b66d7da40..000000000 --- a/src/Models/Emoji/Emoji.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a emoji object. - /// - public record Emoji - { - /// - /// Creates a with the provided parameters. - /// - /// Emoji id. - /// Emoji name. - /// Roles allowed to use this emoji. - /// User that created this emoji. - /// Whether this emoji must be wrapped in colons. - /// Whether this emoji is managed. - /// Whether this emoji is animated. - /// Whether this emoji can be used, may be false due to loss of Server Boosts. - [JsonConstructor] - public Emoji(Snowflake? id, string? name, Optional roles, Optional user, Optional requireColons, Optional managed, Optional animated, Optional available) - { - Id = id; - Name = name; - Roles = roles; - User = user; - RequireColons = requireColons; - Managed = managed; - Animated = animated; - Available = available; - } - - /// - /// Emoji id. - /// - [JsonPropertyName("id")] - public Snowflake? Id { get; } - - /// - /// Emoji name. - /// - /// - /// Can be null only in reaction emoji objects. - /// - [JsonPropertyName("name")] - public string? Name { get; } - - /// - /// Roles allowed to use this emoji. - /// - [JsonPropertyName("roles")] - public Optional Roles { get; } - - /// - /// User that created this emoji. - /// - [JsonPropertyName("user")] - public Optional User { get; } - - /// - /// Whether this emoji must be wrapped in colons. - /// - [JsonPropertyName("require_colons")] - public Optional RequireColons { get; } - - /// - /// Whether this emoji is managed. - /// - [JsonPropertyName("managed")] - public Optional Managed { get; } - - /// - /// Whether this emoji is animated. - /// - [JsonPropertyName("animated")] - public Optional Animated { get; } - - /// - /// Whether this emoji can be used, may be false due to loss of Server Boosts. - /// - [JsonPropertyName("available")] - public Optional Available { get; } - } -} diff --git a/src/Models/Gateway/Activity.cs b/src/Models/Gateway/Activity.cs deleted file mode 100644 index 3ac1fb74e..000000000 --- a/src/Models/Gateway/Activity.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an activity object. - /// - public record Activity - { - /// - /// Creates a with the provided parameters. - /// - /// The activity's name. - /// Activity type. - /// Stream url, is validated when type is 1. - /// Unix timestamp of when the activity was added to the user's session. - /// Unix timestamps for start and/or end of the game. - /// Application id for the game. - /// What the player is currently doing. - /// The user's current party status. - /// The emoji used for a custom status. - /// Information for the current party of the player. - /// Images for the presence and their hover texts. - /// Secrets for Rich Presence joining and spectating. - /// Whether or not the activity is an instanced game session. - /// Activity flags ORd together, describes what the payload includes. - /// The custom buttons shown in the Rich Presence (max 2). - [JsonConstructor] - public Activity(string name, int type, Optional url, int createdAt, Optional timestamps, Optional applicationId, Optional details, Optional state, Optional emoji, Optional party, Optional assets, Optional secrets, Optional instance, Optional flags, Optional buttonLabels) - { - Name = name; - Type = type; - Url = url; - CreatedAt = createdAt; - Timestamps = timestamps; - ApplicationId = applicationId; - Details = details; - State = state; - Emoji = emoji; - Party = party; - Assets = assets; - Secrets = secrets; - Instance = instance; - Flags = flags; - ButtonLabels = buttonLabels; - } - - /// - /// The activity's name. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// Activity type. - /// - [JsonPropertyName("type")] - public int Type { get; } - - /// - /// Stream url, is validated when type is 1. - /// - [JsonPropertyName("url")] - public Optional Url { get; } - - /// - /// Unix timestamp of when the activity was added to the user's session. - /// - [JsonPropertyName("created_at")] - public int CreatedAt { get; } - - /// - /// Unix timestamps for start and/or end of the game. - /// - [JsonPropertyName("timestamps")] - public Optional Timestamps { get; } - - /// - /// Application id for the game. - /// - [JsonPropertyName("application_id")] - public Optional ApplicationId { get; } - - /// - /// What the player is currently doing. - /// - [JsonPropertyName("details")] - public Optional Details { get; } - - /// - /// The user's current party status. - /// - [JsonPropertyName("state")] - public Optional State { get; } - - /// - /// The emoji used for a custom status. - /// - [JsonPropertyName("emoji")] - public Optional Emoji { get; } - - /// - /// Information for the current party of the player. - /// - [JsonPropertyName("party")] - public Optional Party { get; } - - /// - /// Images for the presence and their hover texts. - /// - [JsonPropertyName("assets")] - public Optional Assets { get; } - - /// - /// Secrets for Rich Presence joining and spectating. - /// - [JsonPropertyName("secrets")] - public Optional Secrets { get; } - - /// - /// Whether or not the activity is an instanced game session. - /// - [JsonPropertyName("instance")] - public Optional Instance { get; } - - /// - /// Activity flags ORd together, describes what the payload includes. - /// - [JsonPropertyName("flags")] - public Optional Flags { get; } - - /// - /// The custom buttons shown in the Rich Presence (max 2). - /// - [JsonPropertyName("buttons")] - public Optional ButtonLabels { get; } - } -} diff --git a/src/Models/Gateway/ActivityAssets.cs b/src/Models/Gateway/ActivityAssets.cs deleted file mode 100644 index e80680280..000000000 --- a/src/Models/Gateway/ActivityAssets.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an activity assets object. - /// - public record ActivityAssets - { - /// - /// Creates a with the provided parameters. - /// - /// The id for a large asset of the activity, usually a snowflake. - /// Text displayed when hovering over the large image of the activity. - /// The id for a small asset of the activity, usually a snowflake. - /// Text displayed when hovering over the small image of the activity. - [JsonConstructor] - public ActivityAssets(Optional largeImage, Optional largeText, Optional smallImage, Optional smallText) - { - LargeImage = largeImage; - LargeText = largeText; - SmallImage = smallImage; - SmallText = smallText; - } - - /// - /// The id for a large asset of the activity, usually a snowflake. - /// - [JsonPropertyName("large_image")] - public Optional LargeImage { get; } - - /// - /// Text displayed when hovering over the large image of the activity. - /// - [JsonPropertyName("large_text")] - public Optional LargeText { get; } - - /// - /// The id for a small asset of the activity, usually a snowflake. - /// - [JsonPropertyName("small_image")] - public Optional SmallImage { get; } - - /// - /// Text displayed when hovering over the small image of the activity. - /// - [JsonPropertyName("small_text")] - public Optional SmallText { get; } - } -} diff --git a/src/Models/Gateway/ActivityEmoji.cs b/src/Models/Gateway/ActivityEmoji.cs deleted file mode 100644 index 123318ff1..000000000 --- a/src/Models/Gateway/ActivityEmoji.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an activity emoji object. - /// - public record ActivityEmoji - { - /// - /// Creates a with the provided parameters. - /// - /// The name of the emoji. - /// The id of the emoji. - /// Whether this emoji is animated. - [JsonConstructor] - public ActivityEmoji(string name, Optional id, Optional animated) - { - Name = name; - Id = id; - Animated = animated; - } - - /// - /// The name of the emoji. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// The id of the emoji. - /// - [JsonPropertyName("id")] - public Optional Id { get; } - - /// - /// Whether this emoji is animated. - /// - [JsonPropertyName("animated")] - public Optional Animated { get; } - } -} diff --git a/src/Models/Gateway/ActivityParty.cs b/src/Models/Gateway/ActivityParty.cs deleted file mode 100644 index 4512941ab..000000000 --- a/src/Models/Gateway/ActivityParty.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an activity party object. - /// - public record ActivityParty - { - /// - /// Creates a with the provided parameters. - /// - /// The id of the party. - /// Used to show the party's current and maximum size. - [JsonConstructor] - public ActivityParty(Optional id, Optional size) - { - Id = id; - Size = size; - } - - /// - /// The id of the party. - /// - [JsonPropertyName("id")] - public Optional Id { get; } - - /// - /// Used to show the party's current and maximum size. - /// - [JsonPropertyName("size")] - public Optional Size { get; } - } -} diff --git a/src/Models/Gateway/ActivitySecrets.cs b/src/Models/Gateway/ActivitySecrets.cs deleted file mode 100644 index dcae2096f..000000000 --- a/src/Models/Gateway/ActivitySecrets.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an activity secrets object. - /// - public record ActivitySecrets - { - /// - /// Creates a with the provided parameters. - /// - /// The secret for joining a party. - /// The secret for spectating a game. - /// The secret for a specific instanced match. - [JsonConstructor] - public ActivitySecrets(Optional join, Optional spectate, Optional match) - { - Join = join; - Spectate = spectate; - Match = match; - } - - /// - /// The secret for joining a party. - /// - [JsonPropertyName("join")] - public Optional Join { get; } - - /// - /// The secret for spectating a game. - /// - [JsonPropertyName("spectate")] - public Optional Spectate { get; } - - /// - /// The secret for a specific instanced match. - /// - [JsonPropertyName("match")] - public Optional Match { get; } - } -} diff --git a/src/Models/Gateway/ActivityTimestamps.cs b/src/Models/Gateway/ActivityTimestamps.cs deleted file mode 100644 index 89f752a43..000000000 --- a/src/Models/Gateway/ActivityTimestamps.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents an activity timestamp object. - /// - public record ActivityTimestamps - { - /// - /// Creates a with the provided parameters. - /// - /// When the activity started. - /// When the activity ends. - [JsonConstructor] - public ActivityTimestamps(Optional start, Optional end) - { - Start = start; - End = end; - } - - /// - /// When the activity started. - /// - [JsonPropertyName("start")] - public Optional Start { get; } - - /// - /// When the activity ends. - /// - [JsonPropertyName("end")] - public Optional End { get; } - } -} diff --git a/src/Models/Gateway/ClientStatus.cs b/src/Models/Gateway/ClientStatus.cs deleted file mode 100644 index 4bd49f18b..000000000 --- a/src/Models/Gateway/ClientStatus.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a client status object. - /// - public record ClientStatus - { - /// - /// Creates a with the provided parameters. - /// - /// The user's status set for an active desktop (Windows, Linux, Mac) application session. - /// The user's status set for an active mobile (iOS, Android) application session. - /// The user's status set for an active web (browser, bot account) application session. - [JsonConstructor] - public ClientStatus(Optional desktop, Optional mobile, Optional web) - { - Desktop = desktop; - Mobile = mobile; - Web = web; - } - - /// - /// The user's status set for an active desktop (Windows, Linux, Mac) application session. - /// - [JsonPropertyName("desktop")] - public Optional Desktop { get; } - - /// - /// The user's status set for an active mobile (iOS, Android) application session. - /// - [JsonPropertyName("mobile")] - public Optional Mobile { get; } - - /// - /// The user's status set for an active web (browser, bot account) application session. - /// - [JsonPropertyName("web")] - public Optional Web { get; } - } -} diff --git a/src/Models/Gateway/Presence.cs b/src/Models/Gateway/Presence.cs deleted file mode 100644 index 7fb8bff12..000000000 --- a/src/Models/Gateway/Presence.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a presence object. - /// - public record Presence - { - /// - /// Creates a with the provided parameters. - /// - /// The user presence is being updated for. - /// Id of the guild. - /// Either "idle", "dnd", "online", or "offline". - /// User's current activities. - /// User's platform-dependent status. - [JsonConstructor] - public Presence(User user, Snowflake guildId, string status, Activity[] activities, ClientStatus clientStatus) - { - User = user; - GuildId = guildId; - Status = status; - Activities = activities; - ClientStatus = clientStatus; - } - - /// - /// The user presence is being updated for. - /// - [JsonPropertyName("user")] - public User User { get; } - - /// - /// Id of the guild. - /// - [JsonPropertyName("guild_id")] - public Snowflake GuildId { get; } - - /// - /// Either "idle", "dnd", "online", or "offline". - /// - [JsonPropertyName("status")] - public string Status { get; } - - /// - /// User's current activities. - /// - [JsonPropertyName("activities")] - public Activity[] Activities { get; } - - /// - /// User's platform-dependent status. - /// - [JsonPropertyName("client_status")] - public ClientStatus ClientStatus { get; } - } -} diff --git a/src/Models/Guild/Ban.cs b/src/Models/Guild/Ban.cs deleted file mode 100644 index 6fac4bb22..000000000 --- a/src/Models/Guild/Ban.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a ban object. - /// - public record Ban - { - /// - /// Creates a with the provided parameters. - /// - /// The reason for the ban. - /// The banned user. - [JsonConstructor] - public Ban(string? reason, User user) - { - Reason = reason; - User = user; - } - - /// - /// The reason for the ban. - /// - [JsonPropertyName("reason")] - public string? Reason { get; } - - /// - /// The banned user. - /// - [JsonPropertyName("user")] - public User User { get; } - } -} diff --git a/src/Models/Guild/DefaultMessageNotificationLevel.cs b/src/Models/Guild/DefaultMessageNotificationLevel.cs deleted file mode 100644 index 9181de598..000000000 --- a/src/Models/Guild/DefaultMessageNotificationLevel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the default message notification level. - /// - public enum DefaultMessageNotificationLevel - { - /// - /// Members will receive notifications for all messages by default. - /// - AllMessages = 0, - - /// - /// Members will receive notifications only for messages that @mention them by default. - /// - OnlyMentions = 1, - } -} diff --git a/src/Models/Guild/ExplicitContentFilterLevel.cs b/src/Models/Guild/ExplicitContentFilterLevel.cs deleted file mode 100644 index 6bed9d43e..000000000 --- a/src/Models/Guild/ExplicitContentFilterLevel.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the explicit content filter level. - /// - public enum ExplicitContentFilterLevel - { - /// - /// Media content will not be scanned. - /// - Disabled = 0, - - /// - /// Media content sent by members without roles will be scanned. - /// - MembersWithoutRoles = 1, - - /// - /// Media content sent by all members will be scanned. - /// - AllMembers = 2, - } -} diff --git a/src/Models/Guild/Guild.cs b/src/Models/Guild/Guild.cs deleted file mode 100644 index 5c7c93c96..000000000 --- a/src/Models/Guild/Guild.cs +++ /dev/null @@ -1,411 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a guild object. - /// - public record Guild - { - /// - /// Creates a with the provided parameters. - /// - /// Guild id. - /// Guild name (2-100 characters, excluding trailing and leading whitespace). - /// Icon hash. - /// Icon hash, returned when in the template object. - /// Splash hash. - /// Discovery splash hash; only present for guilds with the "DISCOVERABLE" feature. - /// True if the user is the owner of the guild. - /// Id of owner. - /// Total permissions for the user in the guild (excludes overwrites). - /// Voice region id for the guild. - /// Id of afk channel. - /// Afk timeout in seconds. - /// True if the server widget is enabled. - /// The channel id that the widget will generate an invite to, or null if set to no invite. - /// Verification level required for the guild. - /// Default message notifications level. - /// Explicit content filter level. - /// Roles in the guild. - /// Custom guild emojis. - /// Enabled guild features. - /// Required MFA level for the guild. - /// Application id of the guild creator if it is bot-created. - /// The id of the channel where guild notices such as welcome messages and boost events are posted. - /// System channel flags. - /// The id of the channel where Community guilds can display rules and/or guidelines. - /// When this guild was joined at. - /// True if this is considered a large guild. - /// True if this guild is unavailable due to an outage. - /// Total number of members in this guild. - /// States of members currently in voice channels; lacks the guild_id key. - /// Users in the guild. - /// Channels in the guild. - /// All active threads in the guild that current user has permission to view. - /// Presences of the members in the guild, will only include non-offline members if the size is greater than large threshold. - /// The maximum number of presences for the guild (the default value, currently 25000, is in effect when null is returned). - /// The maximum number of members for the guild. - /// The vanity url code for the guild. - /// The description of a Community guild. - /// Banner hash. - /// Premium tier (Server Boost level). - /// The number of boosts this guild currently has. - /// The preferred locale of a Community guild; used in server discovery and notices from Discord; defaults to "en-US". - /// The id of the channel where admins and moderators of Community guilds receive notices from Discord. - /// The maximum amount of users in a video channel. - /// Approximate number of members in this guild. - /// Approximate number of non-offline members in this guild. - /// The welcome screen of a Community guild, shown to new members, returned in an Invite's guild object. - /// Guild NSFW level. - /// Stage instances in the guild. - [JsonConstructor] - public Guild(Snowflake id, string name, string? icon, Optional iconHash, string? splash, string? discoverySplash, Optional owner, Snowflake ownerId, Optional permissions, string region, Snowflake? afkChannelId, int afkTimeout, Optional widgetEnabled, Optional widgetChannelId, int verificationLevel, int defaultMessageNotifications, int explicitContentFilter, Role[] roles, Emoji[] emojis, string[] features, int mfaLevel, Snowflake? applicationId, Snowflake? systemChannelId, int systemChannelFlags, Snowflake? rulesChannelId, Optional joinedAt, Optional large, Optional unavailable, Optional memberCount, Optional voiceStates, Optional members, Optional channels, Optional threads, Optional presences, Optional maxPresences, Optional maxMembers, string? vanityUrlCode, string? description, string? banner, int premiumTier, Optional premiumSubscriptionCount, string preferredLocale, Snowflake? publicUpdatesChannelId, Optional maxVideoChannelUsers, Optional approximateMemberCount, Optional approximatePresenceCount, Optional welcomeScreen, int nsfwLevel, Optional stageInstances) - { - Id = id; - Name = name; - Icon = icon; - IconHash = iconHash; - Splash = splash; - DiscoverySplash = discoverySplash; - Owner = owner; - OwnerId = ownerId; - Permissions = permissions; - Region = region; - AfkChannelId = afkChannelId; - AfkTimeout = afkTimeout; - WidgetEnabled = widgetEnabled; - WidgetChannelId = widgetChannelId; - VerificationLevel = verificationLevel; - DefaultMessageNotifications = defaultMessageNotifications; - ExplicitContentFilter = explicitContentFilter; - Roles = roles; - Emojis = emojis; - Features = features; - MfaLevel = mfaLevel; - ApplicationId = applicationId; - SystemChannelId = systemChannelId; - SystemChannelFlags = systemChannelFlags; - RulesChannelId = rulesChannelId; - JoinedAt = joinedAt; - Large = large; - Unavailable = unavailable; - MemberCount = memberCount; - VoiceStates = voiceStates; - Members = members; - Channels = channels; - Threads = threads; - Presences = presences; - MaxPresences = maxPresences; - MaxMembers = maxMembers; - VanityUrlCode = vanityUrlCode; - Description = description; - Banner = banner; - PremiumTier = premiumTier; - PremiumSubscriptionCount = premiumSubscriptionCount; - PreferredLocale = preferredLocale; - PublicUpdatesChannelId = publicUpdatesChannelId; - MaxVideoChannelUsers = maxVideoChannelUsers; - ApproximateMemberCount = approximateMemberCount; - ApproximatePresenceCount = approximatePresenceCount; - WelcomeScreen = welcomeScreen; - NsfwLevel = nsfwLevel; - StageInstances = stageInstances; - } - - /// - /// Guild id. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// Guild name. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// Icon hash. - /// - [JsonPropertyName("icon")] - public string? Icon { get; } - - /// - /// Icon hash, returned when in the template object. - /// - [JsonPropertyName("icon_hash")] - public Optional IconHash { get; } - - /// - /// Splash hash. - /// - [JsonPropertyName("splash")] - public string? Splash { get; } - - /// - /// Discovery splash hash; only present for guilds with the "DISCOVERABLE" feature. - /// - [JsonPropertyName("discovery_splash")] - public string? DiscoverySplash { get; } - - /// - /// True if the user is the owner of the guild. - /// - [JsonPropertyName("owner")] - public Optional Owner { get; } - - /// - /// Id of owner. - /// - [JsonPropertyName("owner_id")] - public Snowflake OwnerId { get; } - - /// - /// Total permissions for the user in the guild (excludes overwrites). - /// - [JsonPropertyName("permissions")] - public Optional Permissions { get; } - - /// - /// Voice region id for the guild. - /// - [JsonPropertyName("region")] - public string Region { get; } - - /// - /// Id of afk channel. - /// - [JsonPropertyName("afk_channel_id")] - public Snowflake? AfkChannelId { get; } - - /// - /// Afk timeout in seconds. - /// - [JsonPropertyName("afk_timeout")] - public int AfkTimeout { get; } - - /// - /// True if the server widget is enabled. - /// - [JsonPropertyName("widget_enabled")] - public Optional WidgetEnabled { get; } - - /// - /// The channel id that the widget will generate an invite to, or null if set to no invite. - /// - [JsonPropertyName("widget_channel_id")] - public Optional WidgetChannelId { get; } - - /// - /// Verification level required for the guild. - /// - [JsonPropertyName("verification_level")] - public int VerificationLevel { get; } - - /// - /// Default message notifications level. - /// - [JsonPropertyName("default_message_notifications")] - public int DefaultMessageNotifications { get; } - - /// - /// Explicit content filter level. - /// - [JsonPropertyName("explicit_content_filter")] - public int ExplicitContentFilter { get; } - - /// - /// Roles in the guild. - /// - [JsonPropertyName("roles")] - public Role[] Roles { get; } - - /// - /// Custom guild emojis. - /// - [JsonPropertyName("emojis")] - public Emoji[] Emojis { get; } - - /// - /// Enabled guild features. - /// - [JsonPropertyName("features")] - public string[] Features { get; } - - /// - /// Required MFA level for the guild. - /// - [JsonPropertyName("mfa_level")] - public int MfaLevel { get; } - - /// - /// Application id of the guild creator if it is bot-created. - /// - [JsonPropertyName("application_id")] - public Snowflake? ApplicationId { get; } - - /// - /// The id of the channel where guild notices such as welcome messages and boost events are posted. - /// - [JsonPropertyName("system_channel_id")] - public Snowflake? SystemChannelId { get; } - - /// - /// System channel flags. - /// - [JsonPropertyName("system_channel_flags")] - public int SystemChannelFlags { get; } - - /// - /// The id of the channel where Community guilds can display rules and/or guidelines. - /// - [JsonPropertyName("rules_channel_id")] - public Snowflake? RulesChannelId { get; } - - /// - /// When this guild was joined at. - /// - [JsonPropertyName("joined_at")] - public Optional JoinedAt { get; } - - /// - /// True if this is considered a large guild. - /// - [JsonPropertyName("large")] - public Optional Large { get; } - - /// - /// True if this guild is unavailable due to an outage. - /// - [JsonPropertyName("unavailable")] - public Optional Unavailable { get; } - - /// - /// Total number of members in this guild. - /// - [JsonPropertyName("member_count")] - public Optional MemberCount { get; } - - /// - /// States of members currently in voice channels; lacks the guild_id key. - /// - [JsonPropertyName("voice_states")] - public Optional VoiceStates { get; } - - /// - /// Users in the guild. - /// - [JsonPropertyName("members")] - public Optional Members { get; } - - /// - /// Channels in the guild. - /// - [JsonPropertyName("channels")] - public Optional Channels { get; } - - /// - /// All active threads in the guild that current user has permission to view. - /// - [JsonPropertyName("threads")] - public Optional Threads { get; } - - /// - /// Presences of the members in the guild, will only include non-offline members if the size is greater than large threshold. - /// - [JsonPropertyName("presences")] - public Optional Presences { get; } - - /// - /// The maximum number of presences for the guild (the default value, currently 25000, is in effect when null is returned). - /// - [JsonPropertyName("max_presences")] - public Optional MaxPresences { get; } - - /// - /// The maximum number of members for the guild. - /// - [JsonPropertyName("max_members")] - public Optional MaxMembers { get; } - - /// - /// The vanity url code for the guild. - /// - [JsonPropertyName("vanity_url_code")] - public string? VanityUrlCode { get; } - - /// - /// The description of a Community guild. - /// - [JsonPropertyName("description")] - public string? Description { get; } - - /// - /// Banner hash. - /// - [JsonPropertyName("banner")] - public string? Banner { get; } - - /// - /// Premium tier (Server Boost level). - /// - [JsonPropertyName("premium_tier")] - public int PremiumTier { get; } - - /// - /// The number of boosts this guild currently has. - /// - [JsonPropertyName("premium_subscription_count")] - public Optional PremiumSubscriptionCount { get; } - - /// - /// The preferred locale of a Community guild; used in server discovery and notices from Discord; defaults to "en-US". - /// - [JsonPropertyName("preferred_locale")] - public string PreferredLocale { get; } - - /// - /// The id of the channel where admins and moderators of Community guilds receive notices from Discord. - /// - [JsonPropertyName("public_updates_channel_id")] - public Snowflake? PublicUpdatesChannelId { get; } - - /// - /// The maximum amount of users in a video channel. - /// - [JsonPropertyName("max_video_channel_users")] - public Optional MaxVideoChannelUsers { get; } - - /// - /// Approximate number of members in this guild. - /// - [JsonPropertyName("approximate_member_count")] - public Optional ApproximateMemberCount { get; } - - /// - /// Approximate number of non-offline members in this guild. - /// - [JsonPropertyName("approximate_presence_count")] - public Optional ApproximatePresenceCount { get; } - - /// - /// The welcome screen of a Community guild, shown to new members, returned in an Invite's guild object. - /// - [JsonPropertyName("welcome_screen")] - public Optional WelcomeScreen { get; } - - /// - /// Guild NSFW level. - /// - [JsonPropertyName("nsfw_level")] - public int NsfwLevel { get; } - - /// - /// Stage instances in the guild. - /// - [JsonPropertyName("stage_instances")] - public Optional StageInstances { get; } - } -} diff --git a/src/Models/Guild/GuildMember.cs b/src/Models/Guild/GuildMember.cs deleted file mode 100644 index e38491278..000000000 --- a/src/Models/Guild/GuildMember.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a guild member object. - /// - public record GuildMember - { - /// - /// Creates a with the provided parameters. - /// - /// The user this guild member represents. - /// This users guild nickname. - /// Array of role object ids. - /// When the user joined the guild. - /// When the user started boosting the guild. - /// Whether the user is deafened in voice channels. - /// Whether the user is muted in voice channels. - /// Whether the user has not yet passed the guild's Membership Screening requirements. - /// Total permissions of the member in the channel, including overwrites, returned when in the interaction object. - [JsonConstructor] - public GuildMember(Optional user, Optional nick, Snowflake[] roles, DateTimeOffset joinedAt, Optional premiumSince, bool deaf, bool mute, Optional pending, Optional permissions) - { - User = user; - Nick = nick; - Roles = roles; - JoinedAt = joinedAt; - PremiumSince = premiumSince; - Deaf = deaf; - Mute = mute; - Pending = pending; - Permissions = permissions; - } - - /// - /// The user this guild member represents. - /// - [JsonPropertyName("user")] - public Optional User { get; } - - /// - /// This users guild nickname. - /// - [JsonPropertyName("nick")] - public Optional Nick { get; } - - /// - /// Array of role object ids. - /// - [JsonPropertyName("roles")] - public Snowflake[] Roles { get; } - - /// - /// When the user joined the guild. - /// - [JsonPropertyName("joined_at")] - public DateTimeOffset JoinedAt { get; } - - /// - /// When the user started boosting the guild. - /// - [JsonPropertyName("premium_since")] - public Optional PremiumSince { get; } - - /// - /// Whether the user is deafened in voice channels. - /// - [JsonPropertyName("deaf")] - public bool Deaf { get; } - - /// - /// Whether the user is muted in voice channels. - /// - [JsonPropertyName("mute")] - public bool Mute { get; } - - /// - /// Whether the user has not yet passed the guild's Membership Screening requirements. - /// - [JsonPropertyName("pending")] - public Optional Pending { get; } - - /// - /// Total permissions of the member in the channel, including overwrites, returned when in the interaction object. - /// - [JsonPropertyName("permissions")] - public Optional Permissions { get; } - } -} diff --git a/src/Models/Guild/GuildPreview.cs b/src/Models/Guild/GuildPreview.cs deleted file mode 100644 index 570bf3a02..000000000 --- a/src/Models/Guild/GuildPreview.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a guild preview object. - /// - public record GuildPreview - { - /// - /// Creates a with the provided parameters. - /// - /// Guild id. - /// Guild name (2-100 characters). - /// Icon hash. - /// Splash hash. - /// Discovery splash hash. - /// Custom guild emojis. - /// Enabled guild features. - /// Approximate number of members in this guild. - /// Approximate number of online members in this guild. - /// The description for the guild, if the guild is discoverable. - [JsonConstructor] - public GuildPreview(Snowflake id, string name, string? icon, string? splash, string? discoverySplash, Emoji[] emojis, string[] features, int approximateMemberCount, int approximatePresenceCount, string? description) - { - Id = id; - Name = name; - Icon = icon; - Splash = splash; - DiscoverySplash = discoverySplash; - Emojis = emojis; - Features = features; - ApproximateMemberCount = approximateMemberCount; - ApproximatePresenceCount = approximatePresenceCount; - Description = description; - } - - /// - /// Guild id. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// Guild name (2-100 characters). - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// Icon hash. - /// - [JsonPropertyName("icon")] - public string? Icon { get; } - - /// - /// Splash hash. - /// - [JsonPropertyName("splash")] - public string? Splash { get; } - - /// - /// Discovery splash hash. - /// - [JsonPropertyName("discovery_splash")] - public string? DiscoverySplash { get; } - - /// - /// Custom guild emojis. - /// - [JsonPropertyName("emojis")] - public Emoji[] Emojis { get; } - - /// - /// Enabled guild features. - /// - [JsonPropertyName("features")] - public string[] Features { get; } - - /// - /// Approximate number of members in this guild. - /// - [JsonPropertyName("approximate_member_count")] - public int ApproximateMemberCount { get; } - - /// - /// Approximate number of online members in this guild. - /// - [JsonPropertyName("approximate_presence_count")] - public int ApproximatePresenceCount { get; } - - /// - /// The description for the guild, if the guild is discoverable. - /// - [JsonPropertyName("description")] - public string? Description { get; } - } -} diff --git a/src/Models/Guild/GuildWidget.cs b/src/Models/Guild/GuildWidget.cs deleted file mode 100644 index 1fec9a51c..000000000 --- a/src/Models/Guild/GuildWidget.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a guild widget object. - /// - public record GuildWidget - { - /// - /// Creates a with the provided parameters. - /// - /// Whether the widget is enabled. - /// The widget channel id. - [JsonConstructor] - public GuildWidget(bool enabled, Snowflake? channelId) - { - Enabled = enabled; - ChannelId = channelId; - } - - /// - /// Whether the widget is enabled. - /// - [JsonPropertyName("enabled")] - public bool Enabled { get; } - - /// - /// The widget channel id. - /// - [JsonPropertyName("channel_id")] - public Snowflake? ChannelId { get; } - } -} diff --git a/src/Models/Guild/Integration.cs b/src/Models/Guild/Integration.cs deleted file mode 100644 index 3dbf7a753..000000000 --- a/src/Models/Guild/Integration.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a integration object. - /// - public record Integration - { - /// - /// Creates a with the provided parameters. - /// - /// Integration id. - /// Integration name. - /// Integration type (twitch, youtube, or discord). - /// Is this integration enabled. - /// Is this integration syncing. - /// Id that this integration uses for "subscribers". - /// Whether emoticons should be synced for this integration (twitch only currently). - /// The behavior of expiring subscribers. - /// The grace period (in days) before expiring subscribers. - /// User for this integration. - /// Integration account information. - /// When this integration was last synced. - /// How many subscribers this integration has. - /// Has this integration been revoked. - /// The bot/OAuth2 application for discord integrations. - [JsonConstructor] - public Integration(Snowflake id, string name, string type, bool enabled, Optional syncing, Optional roleId, Optional enableEmoticons, Optional expireBehavior, Optional expireGracePeriod, Optional user, IntegrationAccount account, Optional syncedAt, Optional subscriberCount, Optional revoked, Optional application) - { - Id = id; - Name = name; - Type = type; - Enabled = enabled; - Syncing = syncing; - RoleId = roleId; - EnableEmoticons = enableEmoticons; - ExpireBehavior = expireBehavior; - ExpireGracePeriod = expireGracePeriod; - User = user; - Account = account; - SyncedAt = syncedAt; - SubscriberCount = subscriberCount; - Revoked = revoked; - Application = application; - } - - /// - /// Integration id. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// Integration name. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// Integration type (twitch, youtube, or discord). - /// - [JsonPropertyName("type")] - public string Type { get; } - - /// - /// Is this integration enabled. - /// - [JsonPropertyName("enabled")] - public bool Enabled { get; } - - /// - /// Is this integration syncing. - /// - [JsonPropertyName("syncing")] - public Optional Syncing { get; } - - /// - /// Id that this integration uses for "subscribers". - /// - [JsonPropertyName("role_id")] - public Optional RoleId { get; } - - /// - /// Whether emoticons should be synced for this integration (twitch only currently). - /// - [JsonPropertyName("enable_emoticons")] - public Optional EnableEmoticons { get; } - - /// - /// The behavior of expiring subscribers. - /// - [JsonPropertyName("expire_behavior")] - public Optional ExpireBehavior { get; } - - /// - /// The grace period (in days) before expiring subscribers. - /// - [JsonPropertyName("expire_grace_period")] - public Optional ExpireGracePeriod { get; } - - /// - /// User for this integration. - /// - [JsonPropertyName("user")] - public Optional User { get; } - - /// - /// Integration account information. - /// - [JsonPropertyName("account")] - public IntegrationAccount Account { get; } - - /// - /// When this integration was last synced. - /// - [JsonPropertyName("synced_at")] - public Optional SyncedAt { get; } - - /// - /// How many subscribers this integration has. - /// - [JsonPropertyName("subscriber_count")] - public Optional SubscriberCount { get; } - - /// - /// Has this integration been revoked. - /// - [JsonPropertyName("revoked")] - public Optional Revoked { get; } - - /// - /// The bot/OAuth2 application for discord integrations. - /// - [JsonPropertyName("application")] - public Optional Application { get; } - } -} diff --git a/src/Models/Guild/IntegrationAccount.cs b/src/Models/Guild/IntegrationAccount.cs deleted file mode 100644 index 2f16117e8..000000000 --- a/src/Models/Guild/IntegrationAccount.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a integration account object. - /// - public record IntegrationAccount - { - /// - /// Creates a with the provided parameters. - /// - /// Id of the account. - /// Name of the account. - [JsonConstructor] - public IntegrationAccount(string id, string name) - { - Id = id; - Name = name; - } - - /// - /// Id of the account. - /// - [JsonPropertyName("id")] - public string Id { get; } - - /// - /// Name of the account. - /// - [JsonPropertyName("name")] - public string Name { get; } - } -} diff --git a/src/Models/Guild/IntegrationApplication.cs b/src/Models/Guild/IntegrationApplication.cs deleted file mode 100644 index 50e8c4ab7..000000000 --- a/src/Models/Guild/IntegrationApplication.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a integration application object. - /// - public record IntegrationApplication - { - /// - /// Creates a with the provided parameters. - /// - /// The id of the app. - /// The name of the app. - /// The icon hash of the app. - /// The description of the app. - /// The description of the app. - /// The bot associated with this application. - [JsonConstructor] - public IntegrationApplication(Snowflake id, string name, string? icon, string description, string summary, Optional bot) - { - Id = id; - Name = name; - Icon = icon; - Description = description; - Summary = summary; - Bot = bot; - } - - /// - /// The id of the app. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// The name of the app. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// The icon hash of the app. - /// - [JsonPropertyName("icon")] - public string? Icon { get; } - - /// - /// The description of the app. - /// - [JsonPropertyName("description")] - public string Description { get; } - - /// - /// The description of the app. - /// - [JsonPropertyName("summary")] - public string Summary { get; } - - /// - /// The bot associated with this application. - /// - [JsonPropertyName("bot")] - public Optional Bot { get; } - } -} diff --git a/src/Models/Guild/IntegrationExpireBehavior.cs b/src/Models/Guild/IntegrationExpireBehavior.cs deleted file mode 100644 index 1f121cfc1..000000000 --- a/src/Models/Guild/IntegrationExpireBehavior.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the integration expire behavior. - /// - public enum IntegrationExpireBehavior - { - /// - /// It will remove the role. - /// - RemoveRole = 0, - - /// - /// It will kick the member. - /// - Kick = 1, - } -} diff --git a/src/Models/Guild/MFALevel.cs b/src/Models/Guild/MFALevel.cs deleted file mode 100644 index 4b0a2628c..000000000 --- a/src/Models/Guild/MFALevel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the m f a level. - /// - public enum MfaLevel - { - /// - /// Guild has no MFA/2FA requirement for moderation actions. - /// - None = 0, - - /// - /// Guild has a 2FA requirement for moderation actions. - /// - Elevated = 1, - } -} diff --git a/src/Models/Guild/PremiumTier.cs b/src/Models/Guild/PremiumTier.cs deleted file mode 100644 index 18264b093..000000000 --- a/src/Models/Guild/PremiumTier.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the premium tier. - /// - public enum PremiumTier - { - /// - /// Guild has not unlocked any Server Boost perks. - /// - None = 0, - - /// - /// Guild has unlocked Server Boost level 1 perks. - /// - Tier1 = 1, - - /// - /// Guild has unlocked Server Boost level 2 perks. - /// - Tier2 = 2, - - /// - /// Guild has unlocked Server Boost level 3 perks. - /// - Tier3 = 3, - } -} diff --git a/src/Models/Guild/VerificationLevel.cs b/src/Models/Guild/VerificationLevel.cs deleted file mode 100644 index 4e16e1ba8..000000000 --- a/src/Models/Guild/VerificationLevel.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the verification level. - /// - public enum VerificationLevel - { - /// - /// Unrestricted. - /// - None = 0, - - /// - /// Must have verified email on account. - /// - Low = 1, - - /// - /// Must be registered on Discord for longer than 5 minutes. - /// - Medium = 2, - - /// - /// Must be a member of the server for longer than 10 minutes. - /// - High = 3, - - /// - /// Must have a verified phone number. - /// - VeryHigh = 4, - } -} diff --git a/src/Models/Guild/WelcomeScreen.cs b/src/Models/Guild/WelcomeScreen.cs deleted file mode 100644 index eaddf1ae3..000000000 --- a/src/Models/Guild/WelcomeScreen.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a welcome screen object. - /// - public record WelcomeScreen - { - /// - /// Creates a with the provided parameters. - /// - /// The server description shown in the welcome screen. - /// The channels shown in the welcome screen, up to 5. - [JsonConstructor] - public WelcomeScreen(string? description, WelcomeScreenChannel[] welcomeChannels) - { - Description = description; - WelcomeChannels = welcomeChannels; - } - - /// - /// The server description shown in the welcome screen. - /// - [JsonPropertyName("description")] - public string? Description { get; } - - /// - /// The channels shown in the welcome screen, up to 5. - /// - [JsonPropertyName("welcome_channels")] - public WelcomeScreenChannel[] WelcomeChannels { get; } - } -} diff --git a/src/Models/Guild/WelcomeScreenChannel.cs b/src/Models/Guild/WelcomeScreenChannel.cs deleted file mode 100644 index e77bde5d8..000000000 --- a/src/Models/Guild/WelcomeScreenChannel.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a welcome screen channel object. - /// - public record WelcomeScreenChannel - { - /// - /// Creates a with the provided parameters. - /// - /// The channel's id. - /// The description shown for the channel. - /// The emoji id, if the emoji is custom. - /// The emoji name if custom, the unicode character if standard, or null if no emoji is set. - [JsonConstructor] - public WelcomeScreenChannel(Snowflake channelId, string description, Snowflake? emojiId, string? emojiName) - { - ChannelId = channelId; - Description = description; - EmojiId = emojiId; - EmojiName = emojiName; - } - - /// - /// The channel's id. - /// - [JsonPropertyName("channel_id")] - public Snowflake ChannelId { get; } - - /// - /// The description shown for the channel. - /// - [JsonPropertyName("description")] - public string Description { get; } - - /// - /// The emoji id, if the emoji is custom. - /// - [JsonPropertyName("emoji_id")] - public Snowflake? EmojiId { get; } - - /// - /// The emoji name if custom, the unicode character if standard, or null if no emoji is set. - /// - [JsonPropertyName("emoji_name")] - public string? EmojiName { get; } - } -} diff --git a/src/Models/GuildTemplate/GuildTemplate.cs b/src/Models/GuildTemplate/GuildTemplate.cs deleted file mode 100644 index fbbb96fe7..000000000 --- a/src/Models/GuildTemplate/GuildTemplate.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a guild template object. - /// - public record GuildTemplate - { - /// - /// Creates a with the provided parameters. - /// - /// The template code (unique ID). - /// Template name. - /// The description for the template. - /// Number of times this template has been used. - /// The ID of the user who created the template. - /// The user who created the template. - /// When this template was created. - /// When this template was last synced to the source guild. - /// The ID of the guild this template is based on. - /// The guild snapshot this template contains. - /// Whether the template has unsynced changes. - [JsonConstructor] - public GuildTemplate(string code, string name, string? description, int usageCount, Snowflake creatorId, User creator, DateTimeOffset createdAt, DateTimeOffset updatedAt, Snowflake sourceGuildId, Guild serializedSourceGuild, bool? isDirty) - { - Code = code; - Name = name; - Description = description; - UsageCount = usageCount; - CreatorId = creatorId; - Creator = creator; - CreatedAt = createdAt; - UpdatedAt = updatedAt; - SourceGuildId = sourceGuildId; - SerializedSourceGuild = serializedSourceGuild; - IsDirty = isDirty; - } - - /// - /// The template code (unique ID). - /// - [JsonPropertyName("code")] - public string Code { get; } - - /// - /// Template name. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// The description for the template. - /// - [JsonPropertyName("description")] - public string? Description { get; } - - /// - /// Number of times this template has been used. - /// - [JsonPropertyName("usage_count")] - public int UsageCount { get; } - - /// - /// The ID of the user who created the template. - /// - [JsonPropertyName("creator_id")] - public Snowflake CreatorId { get; } - - /// - /// The user who created the template. - /// - [JsonPropertyName("creator")] - public User Creator { get; } - - /// - /// When this template was created. - /// - [JsonPropertyName("created_at")] - public DateTimeOffset CreatedAt { get; } - - /// - /// When this template was last synced to the source guild. - /// - [JsonPropertyName("updated_at")] - public DateTimeOffset UpdatedAt { get; } - - /// - /// The ID of the guild this template is based on. - /// - [JsonPropertyName("source_guild_id")] - public Snowflake SourceGuildId { get; } - - /// - /// The guild snapshot this template contains. - /// - [JsonPropertyName("serialized_source_guild")] - public Guild SerializedSourceGuild { get; } - - /// - /// Whether the template has unsynced changes. - /// - [JsonPropertyName("is_dirty")] - public bool? IsDirty { get; } - } -} diff --git a/src/Models/Guilds/Ban.cs b/src/Models/Guilds/Ban.cs new file mode 100644 index 000000000..06ebfe276 --- /dev/null +++ b/src/Models/Guilds/Ban.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord ban object. + /// + /// + /// + /// + public record Ban + { + /// + /// The reason for the ban. + /// + [JsonPropertyName("reason")] + public string? Reason { get; init; } + + /// + /// The banned . + /// + [JsonPropertyName("user")] + public User? User { get; init; } // Required property candidate + } +} diff --git a/src/Models/Guilds/DefaultMessageNotificationLevel.cs b/src/Models/Guilds/DefaultMessageNotificationLevel.cs new file mode 100644 index 000000000..eac5618fd --- /dev/null +++ b/src/Models/Guilds/DefaultMessageNotificationLevel.cs @@ -0,0 +1,21 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the default message notification level for a . + /// + /// + /// + /// + public enum DefaultMessageNotificationLevel + { + /// + /// s will receive notifications for all s by default. + /// + AllMessages = 0, + + /// + /// s will receive notifications only for s that @mention them by default. + /// + OnlyMentions = 1, + } +} diff --git a/src/Models/Guilds/ExplicitContentFilterLevel.cs b/src/Models/Guilds/ExplicitContentFilterLevel.cs new file mode 100644 index 000000000..c3f62bd0b --- /dev/null +++ b/src/Models/Guilds/ExplicitContentFilterLevel.cs @@ -0,0 +1,27 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the explicit content filter level for a . + /// + /// + /// + /// + public enum ExplicitContentFilterLevel + { + /// + /// Media content will not be scanned. + /// + Disabled = 0, + + /// + /// Media content sent by s without + /// s will be scanned. + /// + MembersWithoutRoles = 1, + + /// + /// Media content sent by all s will be scanned. + /// + AllMembers = 2, + } +} diff --git a/src/Models/Guilds/Guild.cs b/src/Models/Guilds/Guild.cs new file mode 100644 index 000000000..81ce601c1 --- /dev/null +++ b/src/Models/Guilds/Guild.cs @@ -0,0 +1,325 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord guild object. + /// + /// + /// + /// + public record Guild + { + /// + /// id. + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// name. + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// Icon hash. + /// + [JsonPropertyName("icon")] + public string? Icon { get; init; } + + /// + /// Icon hash, returned when in the template object. + /// + [JsonPropertyName("icon_hash")] + public Optional IconHash { get; init; } + + /// + /// Splash hash. + /// + [JsonPropertyName("splash")] + public string? Splash { get; init; } + + /// + /// Discovery splash hash; only present for s + /// with the "DISCOVERABLE" feature. + /// + [JsonPropertyName("discovery_splash")] + public string? DiscoverySplash { get; init; } + + /// + /// True if the is the owner of the . + /// + [JsonPropertyName("owner")] + public Optional Owner { get; init; } + + /// + /// Id of owner. + /// + [JsonPropertyName("owner_id")] + public Snowflake OwnerId { get; init; } + + /// + /// for the in the + /// (excludes overwrites). + /// + [JsonPropertyName("permissions")] + public Optional Permissions { get; init; } + + /// + /// Voice region id for the . + /// + [JsonPropertyName("region")] + public string? Region { get; init; } // Required property candidate + + /// + /// Id of afk . + /// + [JsonPropertyName("afk_channel_id")] + public Snowflake? AfkChannelId { get; init; } + + /// + /// Afk timeout in seconds. + /// + [JsonPropertyName("afk_timeout")] + public int AfkTimeout { get; init; } + + /// + /// True if the server widget is enabled. + /// + [JsonPropertyName("widget_enabled")] + public Optional WidgetEnabled { get; init; } + + /// + /// The id that the widget will generate an invite to, or null if set to no invite. + /// + [JsonPropertyName("widget_channel_id")] + public Optional WidgetChannelId { get; init; } + + /// + /// Verification level required for the . + /// + [JsonPropertyName("verification_level")] + public VerificationLevel VerificationLevel { get; init; } + + /// + /// Default message notifications level. + /// + [JsonPropertyName("default_message_notifications")] + public DefaultMessageNotificationLevel DefaultMessageNotifications { get; init; } + + /// + /// Explicit content filter level. + /// + [JsonPropertyName("explicit_content_filter")] + public ExplicitContentFilterLevel ExplicitContentFilter { get; init; } + + /// + /// s in the . + /// + [JsonPropertyName("roles")] + public Role[]? Roles { get; init; } // Required property candidate + + /// + /// Custom s. + /// + [JsonPropertyName("emojis")] + public Emoji[]? Emojis { get; init; } // Required property candidate + + /// + /// Enabled features. + /// + [JsonPropertyName("features")] + public string[]? Features { get; init; } // Required property candidate + + /// + /// Required MFA level for the . + /// + [JsonPropertyName("mfa_level")] + public MfaLevel MfaLevel { get; init; } + + /// + /// id of the creator if it is bot-created. + /// + [JsonPropertyName("application_id")] + public Snowflake? ApplicationId { get; init; } + + /// + /// The id of the where notices such + /// as welcome messages and boost events are posted. + /// + [JsonPropertyName("system_channel_id")] + public Snowflake? SystemChannelId { get; init; } + + /// + /// System flags. + /// + [JsonPropertyName("system_channel_flags")] + public int SystemChannelFlags { get; init; } + + /// + /// The id of the where Community s + /// can display rules and/or guidelines. + /// + [JsonPropertyName("rules_channel_id")] + public Snowflake? RulesChannelId { get; init; } + + /// + /// When this was joined at. + /// + [JsonPropertyName("joined_at")] + public Optional JoinedAt { get; init; } + + /// + /// True if this is considered a large . + /// + [JsonPropertyName("large")] + public Optional Large { get; init; } + + /// + /// True if this is unavailable due to an outage. + /// + [JsonPropertyName("unavailable")] + public Optional Unavailable { get; init; } + + /// + /// Total number of s in this . + /// + [JsonPropertyName("member_count")] + public Optional MemberCount { get; init; } + + /// + /// States of s currently in voice s. + /// + /// + /// Lacks the . + /// + [JsonPropertyName("voice_states")] + public Optional VoiceStates { get; init; } + + /// + /// s in the . + /// + [JsonPropertyName("members")] + public Optional Members { get; init; } + + /// + /// s in the . + /// + [JsonPropertyName("channels")] + public Optional Channels { get; init; } + + /// + /// All active thread s in the that current + /// has permission to view. + /// + [JsonPropertyName("threads")] + public Optional Threads { get; init; } + + /// + /// s of the s in the , + /// will only include non-offline s if the size is greater than large threshold. + /// + [JsonPropertyName("presences")] + public Optional Presences { get; init; } + + /// + /// The maximum number of for the . + /// + /// + /// The default value, currently 25000, is in effect when null is returned. + /// + [JsonPropertyName("max_presences")] + public Optional MaxPresences { get; init; } + + /// + /// The maximum number of s for the . + /// + [JsonPropertyName("max_members")] + public Optional MaxMembers { get; init; } + + /// + /// The vanity url code for the . + /// + [JsonPropertyName("vanity_url_code")] + public string? VanityUrlCode { get; init; } + + /// + /// The description of a Community . + /// + [JsonPropertyName("description")] + public string? Description { get; init; } + + /// + /// Banner hash. + /// + [JsonPropertyName("banner")] + public string? Banner { get; init; } + + /// + /// Premium tier (Server Boost level). + /// + [JsonPropertyName("premium_tier")] + public PremiumTier PremiumTier { get; init; } + + /// + /// The number of boosts this currently has. + /// + [JsonPropertyName("premium_subscription_count")] + public Optional PremiumSubscriptionCount { get; init; } + + /// + /// The preferred locale of a Community . + /// + /// + /// Used in server discovery and notices from Discord, defaults to "en-US". + /// + [JsonPropertyName("preferred_locale")] + public string? PreferredLocale { get; init; } // Required property candidate + + /// + /// The id of the where admins and moderators of Community + /// receive notices from Discord. + /// + [JsonPropertyName("public_updates_channel_id")] + public Snowflake? PublicUpdatesChannelId { get; init; } + + /// + /// The maximum amount of s in a video . + /// + [JsonPropertyName("max_video_channel_users")] + public Optional MaxVideoChannelUsers { get; init; } + + /// + /// Approximate number of s in this . + /// + [JsonPropertyName("approximate_member_count")] + public Optional ApproximateMemberCount { get; init; } + + /// + /// Approximate number of non-offline s in this . + /// + [JsonPropertyName("approximate_presence_count")] + public Optional ApproximatePresenceCount { get; init; } + + /// + /// The welcome screen of a Community , shown to new s, + /// returned in . + /// + [JsonPropertyName("welcome_screen")] + public Optional WelcomeScreen { get; init; } + + /// + /// Guild NSFW level. + /// + [JsonPropertyName("nsfw_level")] + public GuildNsfwLevel NsfwLevel { get; init; } + + /// + /// s in the . + /// + [JsonPropertyName("stage_instances")] + public Optional StageInstances { get; init; } + } +} diff --git a/src/Models/Guilds/GuildMember.cs b/src/Models/Guilds/GuildMember.cs new file mode 100644 index 000000000..5fa878c75 --- /dev/null +++ b/src/Models/Guilds/GuildMember.cs @@ -0,0 +1,71 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord guild member object. + /// + /// + /// + /// + public record GuildMember + { + /// + /// The this represents. + /// + [JsonPropertyName("user")] + public Optional User { get; init; } + + /// + /// This users nickname. + /// + [JsonPropertyName("nick")] + public Optional Nick { get; init; } + + /// + /// Array of ids. + /// + [JsonPropertyName("roles")] + public Snowflake[]? Roles { get; init; } // Required property candidate + + /// + /// When the user joined the . + /// + [JsonPropertyName("joined_at")] + public DateTimeOffset JoinedAt { get; init; } + + /// + /// When the user started boosting the . + /// + [JsonPropertyName("premium_since")] + public Optional PremiumSince { get; init; } + + /// + /// Whether the user is deafened in voice s. + /// + [JsonPropertyName("deaf")] + public bool Deaf { get; init; } + + /// + /// Whether the user is muted in voice s. + /// + [JsonPropertyName("mute")] + public bool Mute { get; init; } + + /// + /// Whether the user has not yet passed the 's + /// Membership Screening requirements. + /// + [JsonPropertyName("pending")] + public Optional Pending { get; init; } + + /// + /// Total of the + /// in the , including s, returned + /// when in the interaction object. + /// + [JsonPropertyName("permissions")] + public Optional Permissions { get; init; } + } +} diff --git a/src/Models/Guild/GuildNSFWLevel.cs b/src/Models/Guilds/GuildNsfwLevel.cs similarity index 62% rename from src/Models/Guild/GuildNSFWLevel.cs rename to src/Models/Guilds/GuildNsfwLevel.cs index d04740df1..04d635c8c 100644 --- a/src/Models/Guild/GuildNSFWLevel.cs +++ b/src/Models/Guilds/GuildNsfwLevel.cs @@ -1,29 +1,27 @@ -using System; - namespace Discord.Net.Models { /// - /// Represents the guild NSFW level. + /// Declares an enum which represents the guild nsfw level for a . /// public enum GuildNsfwLevel { /// - /// Default level. + /// Default level. /// Default = 0, /// - /// Guild contains explicit content. + /// Guild has explicit content. /// Explicit = 1, /// - /// Guild is safe for work. + /// Guild is safe for work. /// Safe = 2, /// - /// Guild has an age restriction. + /// Guild is age-restricted. /// AgeRestricted = 3, } diff --git a/src/Models/Guilds/GuildTemplate.cs b/src/Models/Guilds/GuildTemplate.cs new file mode 100644 index 000000000..1a14433d1 --- /dev/null +++ b/src/Models/Guilds/GuildTemplate.cs @@ -0,0 +1,80 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord guild template object. + /// + /// + /// + /// + public record GuildTemplate + { + /// + /// The template code (unique ID). + /// + [JsonPropertyName("code")] + public string? Code { get; init; } // Required property candidate + + /// + /// Template name. + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// The description for the template. + /// + [JsonPropertyName("description")] + public string? Description { get; init; } + + /// + /// Number of times this template has been used. + /// + [JsonPropertyName("usage_count")] + public int UsageCount { get; init; } + + /// + /// The ID of the user who created the template. + /// + [JsonPropertyName("creator_id")] + public Snowflake CreatorId { get; init; } + + /// + /// The user who created the template. + /// + [JsonPropertyName("creator")] + public User? Creator { get; init; } // Required property candidate + + /// + /// When this template was created. + /// + [JsonPropertyName("created_at")] + public DateTimeOffset CreatedAt { get; init; } + + /// + /// When this template was last synced to the source guild. + /// + [JsonPropertyName("updated_at")] + public DateTimeOffset UpdatedAt { get; init; } + + /// + /// The ID of the this template is based on. + /// + [JsonPropertyName("source_guild_id")] + public Snowflake SourceGuildId { get; init; } + + /// + /// The snapshot this template contains. + /// + [JsonPropertyName("serialized_source_guild")] + public Guild? SerializedSourceGuild { get; init; } // Required property candidate + + /// + /// Whether the template has unsynced changes. + /// + [JsonPropertyName("is_dirty")] + public bool? IsDirty { get; init; } + } +} diff --git a/src/Models/Guilds/GuildWidget.cs b/src/Models/Guilds/GuildWidget.cs new file mode 100644 index 000000000..8b0af611e --- /dev/null +++ b/src/Models/Guilds/GuildWidget.cs @@ -0,0 +1,26 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord guild widget object. + /// + /// + /// + /// + public record GuildWidget + { + + /// + /// Whether the widget is enabled. + /// + [JsonPropertyName("enabled")] + public bool Enabled { get; init; } + + /// + /// The widget id. + /// + [JsonPropertyName("channel_id")] + public Snowflake? ChannelId { get; init; } + } +} diff --git a/src/Models/Guilds/MfaLevel.cs b/src/Models/Guilds/MfaLevel.cs new file mode 100644 index 000000000..f5b732912 --- /dev/null +++ b/src/Models/Guilds/MfaLevel.cs @@ -0,0 +1,21 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the mfa/2fa level for a . + /// + /// + /// + /// + public enum MfaLevel + { + /// + /// has no MFA/2FA requirement for moderation actions. + /// + None = 0, + + /// + /// has a 2FA requirement for moderation actions. + /// + Elevated = 1, + } +} diff --git a/src/Models/Guilds/PremiumTier.cs b/src/Models/Guilds/PremiumTier.cs new file mode 100644 index 000000000..6b23bb0e8 --- /dev/null +++ b/src/Models/Guilds/PremiumTier.cs @@ -0,0 +1,31 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the premium tier (server boost tier) for a . + /// + /// + /// + /// + public enum PremiumTier + { + /// + /// has not unlocked any Server Boost perks. + /// + None = 0, + + /// + /// has unlocked Server Boost level 1 perks. + /// + Tier1 = 1, + + /// + /// has unlocked Server Boost level 2 perks. + /// + Tier2 = 2, + + /// + /// has unlocked Server Boost level 3 perks. + /// + Tier3 = 3, + } +} diff --git a/src/Models/Guild/SystemChannelFlags.cs b/src/Models/Guilds/SystemChannelFlags.cs similarity index 52% rename from src/Models/Guild/SystemChannelFlags.cs rename to src/Models/Guilds/SystemChannelFlags.cs index c5c040ac8..d14f08313 100644 --- a/src/Models/Guild/SystemChannelFlags.cs +++ b/src/Models/Guilds/SystemChannelFlags.cs @@ -3,23 +3,26 @@ using System; namespace Discord.Net.Models { /// - /// Represents the system channel flags. + /// Declares a flag enum which represents the system channel flags for a . /// + /// + /// + /// [Flags] public enum SystemChannelFlags { /// - /// Suppress member join notifications. + /// Suppress member join notifications. /// SuppressJoinNotifications = 1 << 0, /// - /// Suppress server boost notifications. + /// Suppress server boost notifications. /// SuppressPremiumSubscriptions = 1 << 1, /// - /// Suppress server setup tips. + /// Suppress server setup tips. /// SuppressGuildReminderNotifications = 1 << 2, } diff --git a/src/Models/Guilds/VerificationLevel.cs b/src/Models/Guilds/VerificationLevel.cs new file mode 100644 index 000000000..985fe18ee --- /dev/null +++ b/src/Models/Guilds/VerificationLevel.cs @@ -0,0 +1,36 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the verification level for a . + /// + /// + /// + /// + public enum VerificationLevel + { + /// + /// Unrestricted. + /// + None = 0, + + /// + /// Must have verified email on account. + /// + Low = 1, + + /// + /// Must be registered on Discord for longer than 5 minutes. + /// + Medium = 2, + + /// + /// Must be a of the server for longer than 10 minutes. + /// + High = 3, + + /// + /// Must have a verified phone number. + /// + VeryHigh = 4, + } +} diff --git a/src/Models/Guilds/WelcomeScreen.cs b/src/Models/Guilds/WelcomeScreen.cs new file mode 100644 index 000000000..24133ca02 --- /dev/null +++ b/src/Models/Guilds/WelcomeScreen.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord welcome screen object. + /// + /// + /// + /// + public record WelcomeScreen + { + /// + /// The shown in the . + /// + [JsonPropertyName("description")] + public string? Description { get; init; } + + /// + /// The s shown in the , up to 5. + /// + [JsonPropertyName("welcome_channels")] + public WelcomeScreenChannel[]? WelcomeChannels { get; init; } // Required property candidate + } +} diff --git a/src/Models/Integrations/Integration.cs b/src/Models/Integrations/Integration.cs new file mode 100644 index 000000000..9568b5e99 --- /dev/null +++ b/src/Models/Integrations/Integration.cs @@ -0,0 +1,104 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord integration object. + /// + /// + /// + /// + public record Integration + { + /// + /// id. + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// name. + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// type (twitch, youtube, or discord). + /// + [JsonPropertyName("type")] + public string? Type { get; init; } // Required property candidate + + /// + /// Returns if this is enabled. + /// + [JsonPropertyName("enabled")] + public bool Enabled { get; init; } + + /// + /// Returns if this is syncing. + /// + [JsonPropertyName("syncing")] + public Optional Syncing { get; init; } + + /// + /// Id that this uses for "subscribers". + /// + [JsonPropertyName("role_id")] + public Optional RoleId { get; init; } + + /// + /// Whether emoticons should be synced for this (twitch only currently). + /// + [JsonPropertyName("enable_emoticons")] + public Optional EnableEmoticons { get; init; } + + /// + /// The behavior of expiring subscribers. + /// + [JsonPropertyName("expire_behavior")] + public Optional ExpireBehavior { get; init; } + + /// + /// The grace period (in days) before expiring subscribers. + /// + [JsonPropertyName("expire_grace_period")] + public Optional ExpireGracePeriod { get; init; } + + /// + /// for this . + /// + [JsonPropertyName("user")] + public Optional User { get; init; } + + /// + /// information. + /// + [JsonPropertyName("account")] + public IntegrationAccount? Account { get; init; } // Required property candidate + + /// + /// When this was last synced. + /// + [JsonPropertyName("synced_at")] + public Optional SyncedAt { get; init; } + + /// + /// How many subscribers this has. + /// + [JsonPropertyName("subscriber_count")] + public Optional SubscriberCount { get; init; } + + /// + /// Has this been revoked. + /// + [JsonPropertyName("revoked")] + public Optional Revoked { get; init; } + + /// + /// The bot/OAuth2 for discord integrations. + /// + [JsonPropertyName("application")] + public Optional Application { get; init; } + } +} diff --git a/src/Models/Integrations/IntegrationAccount.cs b/src/Models/Integrations/IntegrationAccount.cs new file mode 100644 index 000000000..4f88bf184 --- /dev/null +++ b/src/Models/Integrations/IntegrationAccount.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord integration account object. + /// + /// + /// + /// + public record IntegrationAccount + { + /// + /// Id of the account. + /// + [JsonPropertyName("id")] + public string? Id { get; init; } // Required property candidate + + /// + /// Name of the account. + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + } +} diff --git a/src/Models/Integrations/IntegrationApplication.cs b/src/Models/Integrations/IntegrationApplication.cs new file mode 100644 index 000000000..fcb86cc14 --- /dev/null +++ b/src/Models/Integrations/IntegrationApplication.cs @@ -0,0 +1,49 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord integration application object. + /// + /// + /// + /// + public record IntegrationApplication + { + /// + /// The id of the . + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// The name of the . + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// The icon hash of the . + /// + [JsonPropertyName("icon")] + public string? Icon { get; init; } + + /// + /// The description of the . + /// + [JsonPropertyName("description")] + public string? Description { get; init; } // Required property candidate + + /// + /// The summary of the . + /// + [JsonPropertyName("summary")] + public string? Summary { get; init; } // Required property candidate + + /// + /// The bot associated with this . + /// + [JsonPropertyName("bot")] + public Optional Bot { get; init; } + } +} diff --git a/src/Models/Integrations/IntegrationExpireBehavior.cs b/src/Models/Integrations/IntegrationExpireBehavior.cs new file mode 100644 index 000000000..3e4ad442c --- /dev/null +++ b/src/Models/Integrations/IntegrationExpireBehavior.cs @@ -0,0 +1,21 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the integration expire behavior for an . + /// + /// + /// + /// + public enum IntegrationExpireBehavior + { + /// + /// It will remove the role. + /// + RemoveRole = 0, + + /// + /// It will kick the member. + /// + Kick = 1, + } +} diff --git a/src/Models/Interactions/InteractionType.cs b/src/Models/Interactions/InteractionType.cs new file mode 100644 index 000000000..5241ec60f --- /dev/null +++ b/src/Models/Interactions/InteractionType.cs @@ -0,0 +1,26 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the type of interaction. + /// + /// + /// + /// + public enum InteractionType + { + /// + /// Received when registering an interaction, replied with a pong. + /// + Ping = 1, + + /// + /// This interaction is from a slash command. + /// + ApplicationCommand = 2, + + /// + /// This interaction is from a . + /// + MessageComponent = 3, + } +} diff --git a/src/Models/Invite/Invite.cs b/src/Models/Invite/Invite.cs deleted file mode 100644 index ba926000d..000000000 --- a/src/Models/Invite/Invite.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a invite object. - /// - public record Invite - { - /// - /// Creates a with the provided parameters. - /// - /// The invite code (unique ID). - /// The guild this invite is for. - /// The channel this invite is for. - /// The user who created the invite. - /// The type of target for this voice channel invite. - /// The user whose stream to display for this voice channel stream invite. - /// The embedded application to open for this voice channel embedded application invite. - /// Approximate count of online members. - /// Approximate count of total members. - /// The expiration date of this invite. - [JsonConstructor] - public Invite(string code, Optional guild, Channel channel, Optional inviter, Optional targetType, Optional targetUser, Optional targetApplication, Optional approximatePresenceCount, Optional approximateMemberCount, Optional expiresAt) - { - Code = code; - Guild = guild; - Channel = channel; - Inviter = inviter; - TargetType = targetType; - TargetUser = targetUser; - TargetApplication = targetApplication; - ApproximatePresenceCount = approximatePresenceCount; - ApproximateMemberCount = approximateMemberCount; - ExpiresAt = expiresAt; - } - - /// - /// The invite code (unique ID). - /// - [JsonPropertyName("code")] - public string Code { get; } - - /// - /// The guild this invite is for. - /// - [JsonPropertyName("guild")] - public Optional Guild { get; } - - /// - /// The channel this invite is for. - /// - [JsonPropertyName("channel")] - public Channel Channel { get; } - - /// - /// The user who created the invite. - /// - [JsonPropertyName("inviter")] - public Optional Inviter { get; } - - /// - /// The type of target for this voice channel invite. - /// - [JsonPropertyName("target_type")] - public Optional TargetType { get; } - - /// - /// The user whose stream to display for this voice channel stream invite. - /// - [JsonPropertyName("target_user")] - public Optional TargetUser { get; } - - /// - /// The embedded application to open for this voice channel embedded application invite. - /// - [JsonPropertyName("target_application")] - public Optional TargetApplication { get; } - - /// - /// Approximate count of online members. - /// - [JsonPropertyName("approximate_presence_count")] - public Optional ApproximatePresenceCount { get; } - - /// - /// Approximate count of total members. - /// - [JsonPropertyName("approximate_member_count")] - public Optional ApproximateMemberCount { get; } - - /// - /// The expiration date of this invite. - /// - [JsonPropertyName("expires_at")] - public Optional ExpiresAt { get; } - } -} diff --git a/src/Models/Invite/InviteMetadata.cs b/src/Models/Invite/InviteMetadata.cs deleted file mode 100644 index d39d6faee..000000000 --- a/src/Models/Invite/InviteMetadata.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a invite metadata object. - /// - public record InviteMetadata : Invite - { - /// - /// Creates a with the provided parameters. - /// - /// The invite code (unique ID). - /// The guild this invite is for. - /// The channel this invite is for. - /// The user who created the invite. - /// The type of target for this voice channel invite. - /// The user whose stream to display for this voice channel stream invite. - /// The embedded application to open for this voice channel embedded application invite. - /// Approximate count of online members. - /// Approximate count of total members. - /// The expiration date of this invite. - /// Number of times this invite has been used. - /// Max number of times this invite can be used. - /// Duration (in seconds) after which the invite expires. - /// Whether this invite only grants temporary membership. - /// When this invite was created. - [JsonConstructor] - public InviteMetadata(string code, Optional guild, Channel channel, Optional inviter, Optional targetType, Optional targetUser, Optional targetApplication, Optional approximatePresenceCount, Optional approximateMemberCount, Optional expiresAt, int uses, int maxUses, int maxAge, bool temporary, DateTimeOffset createdAt) - : base(code, guild, channel, inviter, targetType, targetUser, targetApplication, approximatePresenceCount, approximateMemberCount, expiresAt) - { - Uses = uses; - MaxUses = maxUses; - MaxAge = maxAge; - Temporary = temporary; - CreatedAt = createdAt; - } - - /// - /// Number of times this invite has been used. - /// - [JsonPropertyName("uses")] - public int Uses { get; } - - /// - /// Max number of times this invite can be used. - /// - [JsonPropertyName("max_uses")] - public int MaxUses { get; } - - /// - /// Duration (in seconds) after which the invite expires. - /// - [JsonPropertyName("max_age")] - public int MaxAge { get; } - - /// - /// Whether this invite only grants temporary membership. - /// - [JsonPropertyName("temporary")] - public bool Temporary { get; } - - /// - /// When this invite was created. - /// - [JsonPropertyName("created_at")] - public DateTimeOffset CreatedAt { get; } - } -} diff --git a/src/Models/Invite/InviteTargetType.cs b/src/Models/Invite/InviteTargetType.cs deleted file mode 100644 index 8e236920c..000000000 --- a/src/Models/Invite/InviteTargetType.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the invite target type. - /// - public enum InviteTargetType - { - /// - /// - /// - Stream = 1, - - /// - /// - /// - EmbeddedApplication = 2, - } -} diff --git a/src/Models/Invites/Invite.cs b/src/Models/Invites/Invite.cs new file mode 100644 index 000000000..f17d9d44a --- /dev/null +++ b/src/Models/Invites/Invite.cs @@ -0,0 +1,74 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord invite object. + /// + /// + /// + /// + public record Invite + { + /// + /// The code (unique ID). + /// + [JsonPropertyName("code")] + public string? Code { get; init; } // Required property candidate + + /// + /// The this is for. + /// + [JsonPropertyName("guild")] + public Optional Guild { get; init; } + + /// + /// The this invite is for. + /// + [JsonPropertyName("channel")] + public Channel? Channel { get; init; } // Required property candidate + + /// + /// The who created the . + /// + [JsonPropertyName("inviter")] + public Optional Inviter { get; init; } + + /// + /// The type of target for this voice . + /// + [JsonPropertyName("target_type")] + public Optional TargetType { get; init; } + + /// + /// The whose stream to display for this voice stream . + /// + [JsonPropertyName("target_user")] + public Optional TargetUser { get; init; } + + /// + /// The embedded to open for this voice embedded . + /// + [JsonPropertyName("target_application")] + public Optional TargetApplication { get; init; } + + /// + /// Approximate count of online s. + /// + [JsonPropertyName("approximate_presence_count")] + public Optional ApproximatePresenceCount { get; init; } + + /// + /// Approximate count of total . + /// + [JsonPropertyName("approximate_member_count")] + public Optional ApproximateMemberCount { get; init; } + + /// + /// The expiration date of this . + /// + [JsonPropertyName("expires_at")] + public Optional ExpiresAt { get; init; } + } +} diff --git a/src/Models/Invites/InviteMetadata.cs b/src/Models/Invites/InviteMetadata.cs new file mode 100644 index 000000000..70aec1f3f --- /dev/null +++ b/src/Models/Invites/InviteMetadata.cs @@ -0,0 +1,44 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord invite metadata object. + /// + /// + /// + /// + public record InviteMetadata : Invite + { + /// + /// Number of times this has been used. + /// + [JsonPropertyName("uses")] + public int Uses { get; init; } + + /// + /// Max number of times this can be used. + /// + [JsonPropertyName("max_uses")] + public int MaxUses { get; init; } + + /// + /// Duration (in seconds) after which the expires. + /// + [JsonPropertyName("max_age")] + public int MaxAge { get; init; } + + /// + /// Whether this only grants temporary membership. + /// + [JsonPropertyName("temporary")] + public bool Temporary { get; init; } + + /// + /// When this was created. + /// + [JsonPropertyName("created_at")] + public DateTimeOffset CreatedAt { get; init; } + } +} diff --git a/src/Models/Invites/InviteTargetType.cs b/src/Models/Invites/InviteTargetType.cs new file mode 100644 index 000000000..919ae873c --- /dev/null +++ b/src/Models/Invites/InviteTargetType.cs @@ -0,0 +1,21 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the invite target type for an . + /// + /// + /// + /// + public enum InviteTargetType + { + /// + /// The invite target is a stream. + /// + Stream = 1, + + /// + /// The invite target is an embedded application. + /// + EmbeddedApplication = 2, + } +} diff --git a/src/Models/MessageComponents/ActionRowComponent.cs b/src/Models/MessageComponents/ActionRowComponent.cs deleted file mode 100644 index aca1df2dd..000000000 --- a/src/Models/MessageComponents/ActionRowComponent.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a component object. - /// - public record ActionRowComponent : Component - { - /// - /// Creates an with the provided parameters. - /// - /// Component type. - [JsonConstructor] - public ActionRowComponent(ComponentType type) - : base(type) - { - } - - /// - /// Components inside this action row, like buttons or other interactive components. - /// - [JsonPropertyName("components")] - public Optional Components { get; } - } -} diff --git a/src/Models/MessageComponents/ButtonComponent.cs b/src/Models/MessageComponents/ButtonComponent.cs deleted file mode 100644 index 406f151f7..000000000 --- a/src/Models/MessageComponents/ButtonComponent.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a button component object. - /// - public record ButtonComponent : Component - { - /// - /// Creates a with the provided parameters. - /// - /// Component type. - /// One of button styles. - /// Text that appears on the button, max 80 characters. - /// Name, id, and animated. - /// A developer-defined identifier for the button, max 100 characters. - /// A url for link-style buttons. - /// Whether the button is disabled, default false. - [JsonConstructor] - public ButtonComponent(ComponentType type, Optional style, Optional label, Optional emoji, Optional customId, Optional url, Optional disabled) - : base(type) - { - Style = style; - Label = label; - Emoji = emoji; - CustomId = customId; - Url = url; - Disabled = disabled; - } - - /// - /// One of button styles. - /// - [JsonPropertyName("style")] - public Optional Style { get; } - - /// - /// Text that appears on the button, max 80 characters. - /// - [JsonPropertyName("label")] - public Optional Label { get; } - - /// - /// Name, id, and animated. - /// - [JsonPropertyName("emoji")] - public Optional Emoji { get; } - - /// - /// A developer-defined identifier for the button, max 100 characters. - /// - [JsonPropertyName("custom_id")] - public Optional CustomId { get; } - - /// - /// A url for link-style buttons. - /// - [JsonPropertyName("url")] - public Optional Url { get; } - - /// - /// Whether the button is disabled, default false. - /// - [JsonPropertyName("disabled")] - public Optional Disabled { get; } - } -} diff --git a/src/Models/MessageComponents/Component.cs b/src/Models/MessageComponents/Component.cs deleted file mode 100644 index 7fe2ed9bd..000000000 --- a/src/Models/MessageComponents/Component.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a component object. - /// - public record Component - { - /// - /// Creates a with the provided parameters. - /// - /// Component type. - [JsonConstructor] - public Component(ComponentType type) - { - Type = type; - } - - /// - /// Component type. - /// - [JsonPropertyName("type")] - public ComponentType Type { get; } - } -} diff --git a/src/Models/MessageComponents/ComponentType.cs b/src/Models/MessageComponents/ComponentType.cs deleted file mode 100644 index 76fcd0833..000000000 --- a/src/Models/MessageComponents/ComponentType.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the component type. - /// - public enum ComponentType - { - /// - /// A container for other components. - /// - ActionRow = 1, - - /// - /// A clickable button. - /// - Button = 2, - } -} diff --git a/src/Models/Messages/AllowedMentionType.cs b/src/Models/Messages/AllowedMentionType.cs new file mode 100644 index 000000000..009f3eab8 --- /dev/null +++ b/src/Models/Messages/AllowedMentionType.cs @@ -0,0 +1,26 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the allowed mention types flags for a . + /// + /// + /// + /// + public enum AllowedMentionType + { + /// + /// Controls role mentions. + /// + Role, + + /// + /// Controls user mentions. + /// + User, + + /// + /// Controls @everyone and @here mentions. + /// + Everyone, + } +} diff --git a/src/Models/Messages/AllowedMentions.cs b/src/Models/Messages/AllowedMentions.cs new file mode 100644 index 000000000..d10697394 --- /dev/null +++ b/src/Models/Messages/AllowedMentions.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord allowed mentions object. + /// + /// + /// + /// + public record AllowedMentions + { + /// + /// An array of allowed mention types to parse from the content. + /// + [JsonPropertyName("parse")] + public AllowedMentionType[]? Parse { get; init; } // Required property candidate + + /// + /// Array of ids to mention (Max size of 100). + /// + [JsonPropertyName("roles")] + public Snowflake[]? Roles { get; init; } // Required property candidate + + /// + /// Array of ids to mention (Max size of 100). + /// + [JsonPropertyName("users")] + public Snowflake[]? Users { get; init; } // Required property candidate + + /// + /// For replies, whether to mention the author of the being replied to (default false). + /// + [JsonPropertyName("replied_user")] + public bool RepliedUser { get; init; } + } +} diff --git a/src/Models/Messages/Attachment.cs b/src/Models/Messages/Attachment.cs new file mode 100644 index 000000000..ddb2c2ab1 --- /dev/null +++ b/src/Models/Messages/Attachment.cs @@ -0,0 +1,61 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord attachment object. + /// + /// + /// + /// + public record Attachment + { + /// + /// id. + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// Name of file attached. + /// + [JsonPropertyName("filename")] + public string? Filename { get; init; } // Required property candidate + + /// + /// The 's media type. + /// + [JsonPropertyName("content_type")] + public Optional ContentType { get; init; } + + /// + /// Size of file in bytes. + /// + [JsonPropertyName("size")] + public int Size { get; init; } + + /// + /// Source url of file. + /// + [JsonPropertyName("url")] + public string? Url { get; init; } // Required property candidate + + /// + /// A proxied url of file. + /// + [JsonPropertyName("proxy_url")] + public string? ProxyUrl { get; init; } // Required property candidate + + /// + /// Height of file (if image). + /// + [JsonPropertyName("height")] + public Optional Height { get; init; } + + /// + /// Width of file (if image). + /// + [JsonPropertyName("width")] + public Optional Width { get; init; } + } +} diff --git a/src/Models/Messages/ChannelMention.cs b/src/Models/Messages/ChannelMention.cs new file mode 100644 index 000000000..4835b0d8f --- /dev/null +++ b/src/Models/Messages/ChannelMention.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord channel mention object. + /// + /// + /// + /// + public record ChannelMention + { + /// + /// Id of the . + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// Id of the containing the . + /// + [JsonPropertyName("guild_id")] + public Snowflake GuildId { get; init; } + + /// + /// The type of . + /// + [JsonPropertyName("type")] + public ChannelType Type { get; init; } + + /// + /// The name of the . + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + } +} diff --git a/src/Models/Messages/Components/ActionRowComponent.cs b/src/Models/Messages/Components/ActionRowComponent.cs new file mode 100644 index 000000000..ec17a7327 --- /dev/null +++ b/src/Models/Messages/Components/ActionRowComponent.cs @@ -0,0 +1,28 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord action row component. + /// + /// + /// + /// + public record ActionRowComponent : Component + { + /// + /// Creates a with a type of . + /// + public ActionRowComponent() + { + Type = ComponentType.ActionRow; + } + + /// + /// Components inside this action row, like s + /// or other interactive components. + /// + [JsonPropertyName("components")] + public Optional Components { get; init; } + } +} diff --git a/src/Models/Messages/Components/ButtonComponent.cs b/src/Models/Messages/Components/ButtonComponent.cs new file mode 100644 index 000000000..090763489 --- /dev/null +++ b/src/Models/Messages/Components/ButtonComponent.cs @@ -0,0 +1,57 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord button component object. + /// + /// + /// + /// + public record ButtonComponent : Component + { + /// + /// Creates a with a type of . + /// + public ButtonComponent() + { + Type = ComponentType.Button; + } + + /// + /// One of button styles. + /// + [JsonPropertyName("style")] + public Optional Style { get; init; } + + /// + /// Text that appears on the button, max 80 characters. + /// + [JsonPropertyName("label")] + public Optional Label { get; init; } + + /// + /// Name, id, and animated. + /// + [JsonPropertyName("emoji")] + public Optional Emoji { get; init; } + + /// + /// A developer-defined identifier for the button, max 100 characters. + /// + [JsonPropertyName("custom_id")] + public Optional CustomId { get; init; } + + /// + /// A url for link-style buttons. + /// + [JsonPropertyName("url")] + public Optional Url { get; init; } + + /// + /// Whether the button is disabled, default false. + /// + [JsonPropertyName("disabled")] + public Optional Disabled { get; init; } + } +} diff --git a/src/Models/MessageComponents/ButtonStyle.cs b/src/Models/Messages/Components/ButtonStyle.cs similarity index 55% rename from src/Models/MessageComponents/ButtonStyle.cs rename to src/Models/Messages/Components/ButtonStyle.cs index 38a808c77..758c81ccb 100644 --- a/src/Models/MessageComponents/ButtonStyle.cs +++ b/src/Models/Messages/Components/ButtonStyle.cs @@ -1,32 +1,35 @@ namespace Discord.Net.Models { /// - /// Represents the button style type. + /// Declares an enum which represents the style for a . /// + /// + /// + /// public enum ButtonStyle { /// - /// Blurple. + /// Blurple. /// Primary = 1, /// - /// Grey. + /// Grey. /// Secondary = 2, /// - /// Green. + /// Green. /// Success = 3, /// - /// Red. + /// Red. /// Danger = 4, /// - /// Grey, navigates to a URL. + /// Grey, navigates to a URL. /// Link = 5, } diff --git a/src/Models/Messages/Components/Component.cs b/src/Models/Messages/Components/Component.cs new file mode 100644 index 000000000..517642dc4 --- /dev/null +++ b/src/Models/Messages/Components/Component.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a generic component object. + /// + /// + /// + /// + public record Component + { + /// + /// Component type. + /// + [JsonPropertyName("type")] + public ComponentType Type { get; init; } + } +} diff --git a/src/Models/Messages/Components/ComponentType.cs b/src/Models/Messages/Components/ComponentType.cs new file mode 100644 index 000000000..fc1bfcc5a --- /dev/null +++ b/src/Models/Messages/Components/ComponentType.cs @@ -0,0 +1,21 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the type for a . + /// + /// + /// + /// + public enum ComponentType + { + /// + /// A container for other components. + /// + ActionRow = 1, + + /// + /// A clickable button. + /// + Button = 2, + } +} diff --git a/src/Models/Messages/Embeds/Embed.cs b/src/Models/Messages/Embeds/Embed.cs new file mode 100644 index 000000000..d7fa5a64c --- /dev/null +++ b/src/Models/Messages/Embeds/Embed.cs @@ -0,0 +1,92 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord embed object. + /// + /// + /// + /// + public record Embed + { + /// + /// Title of . + /// + [JsonPropertyName("title")] + public Optional Title { get; init; } + + /// + /// Type of (always for webhook embeds). + /// + [JsonPropertyName("type")] + public Optional Type { get; init; } + + /// + /// Description of . + /// + [JsonPropertyName("description")] + public Optional Description { get; init; } + + /// + /// Url of . + /// + [JsonPropertyName("url")] + public Optional Url { get; init; } + + /// + /// Timestamp of content. + /// + [JsonPropertyName("timestamp")] + public Optional Timestamp { get; init; } + + /// + /// of the . + /// + [JsonPropertyName("color")] + public Optional Color { get; init; } + + /// + /// Footer information. + /// + [JsonPropertyName("footer")] + public Optional Footer { get; init; } + + /// + /// Image information. + /// + [JsonPropertyName("image")] + public Optional Image { get; init; } + + /// + /// Thumbnail information. + /// + [JsonPropertyName("thumbnail")] + public Optional Thumbnail { get; init; } + + /// + /// Video information. + /// + [JsonPropertyName("video")] + public Optional Video { get; init; } + + /// + /// Provider information. + /// + [JsonPropertyName("provider")] + public Optional Provider { get; init; } + + /// + /// Author information. + /// + [JsonPropertyName("author")] + public Optional Author { get; init; } + + /// + /// Fields information. + /// + [JsonPropertyName("fields")] + public Optional Fields { get; init; } + } +} diff --git a/src/Models/Messages/Embeds/EmbedAuthor.cs b/src/Models/Messages/Embeds/EmbedAuthor.cs new file mode 100644 index 000000000..77fc1aa1e --- /dev/null +++ b/src/Models/Messages/Embeds/EmbedAuthor.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord embed author object. + /// + /// + /// + /// + public record EmbedAuthor + { + /// + /// Name of author. + /// + [JsonPropertyName("name")] + public Optional Name { get; init; } + + /// + /// Url of author. + /// + [JsonPropertyName("url")] + public Optional Url { get; init; } + + /// + /// Url of author icon (only supports http(s) and attachments). + /// + [JsonPropertyName("icon_url")] + public Optional IconUrl { get; init; } + + /// + /// A proxied url of author icon. + /// + [JsonPropertyName("proxy_icon_url")] + public Optional ProxyIconUrl { get; init; } + } +} diff --git a/src/Models/Messages/Embeds/EmbedField.cs b/src/Models/Messages/Embeds/EmbedField.cs new file mode 100644 index 000000000..4ea252d38 --- /dev/null +++ b/src/Models/Messages/Embeds/EmbedField.cs @@ -0,0 +1,31 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord embed field object. + /// + /// + /// + /// + public record EmbedField + { + /// + /// Name of the field. + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// Value of the field. + /// + [JsonPropertyName("value")] + public string? Value { get; init; } // Required property candidate + + /// + /// Whether or not this field should display inline. + /// + [JsonPropertyName("inline")] + public Optional Inline { get; init; } + } +} diff --git a/src/Models/Messages/Embeds/EmbedFooter.cs b/src/Models/Messages/Embeds/EmbedFooter.cs new file mode 100644 index 000000000..4f3d30d52 --- /dev/null +++ b/src/Models/Messages/Embeds/EmbedFooter.cs @@ -0,0 +1,31 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord embed footer object. + /// + /// + /// + /// + public record EmbedFooter + { + /// + /// Footer text. + /// + [JsonPropertyName("text")] + public string? Text { get; init; } // Required property candidate + + /// + /// Url of footer icon (only supports http(s) and attachments). + /// + [JsonPropertyName("icon_url")] + public Optional IconUrl { get; init; } + + /// + /// A proxied url of footer icon. + /// + [JsonPropertyName("proxy_icon_url")] + public Optional ProxyIconUrl { get; init; } + } +} diff --git a/src/Models/Messages/Embeds/EmbedImage.cs b/src/Models/Messages/Embeds/EmbedImage.cs new file mode 100644 index 000000000..704a1db05 --- /dev/null +++ b/src/Models/Messages/Embeds/EmbedImage.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord embed image object. + /// + /// + /// + /// + public record EmbedImage + { + /// + /// Source url of image (only supports http(s) and attachments). + /// + [JsonPropertyName("url")] + public Optional Url { get; init; } + + /// + /// A proxied url of the image. + /// + [JsonPropertyName("proxy_url")] + public Optional ProxyUrl { get; init; } + + /// + /// Height of image. + /// + [JsonPropertyName("height")] + public Optional Height { get; init; } + + /// + /// Width of image. + /// + [JsonPropertyName("width")] + public Optional Width { get; init; } + } +} diff --git a/src/Models/Messages/Embeds/EmbedProvider.cs b/src/Models/Messages/Embeds/EmbedProvider.cs new file mode 100644 index 000000000..44ac066a2 --- /dev/null +++ b/src/Models/Messages/Embeds/EmbedProvider.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord embed provider object. + /// + /// + /// + /// + public record EmbedProvider + { + /// + /// Name of provider. + /// + [JsonPropertyName("name")] + public Optional Name { get; init; } + + /// + /// Url of provider. + /// + [JsonPropertyName("url")] + public Optional Url { get; init; } + } +} diff --git a/src/Models/Messages/Embeds/EmbedThumbnail.cs b/src/Models/Messages/Embeds/EmbedThumbnail.cs new file mode 100644 index 000000000..7b752331f --- /dev/null +++ b/src/Models/Messages/Embeds/EmbedThumbnail.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord embed thumbnail object. + /// + /// + /// + /// + public record EmbedThumbnail + { + /// + /// Source url of thumbnail (only supports http(s) and attachments). + /// + [JsonPropertyName("url")] + public Optional Url { get; init; } + + /// + /// A proxied url of the thumbnail. + /// + [JsonPropertyName("proxy_url")] + public Optional ProxyUrl { get; init; } + + /// + /// Height of thumbnail. + /// + [JsonPropertyName("height")] + public Optional Height { get; init; } + + /// + /// Width of thumbnail. + /// + [JsonPropertyName("width")] + public Optional Width { get; init; } + } +} diff --git a/src/Models/Channel/Message/Embed/EmbedType.cs b/src/Models/Messages/Embeds/EmbedType.cs similarity index 51% rename from src/Models/Channel/Message/Embed/EmbedType.cs rename to src/Models/Messages/Embeds/EmbedType.cs index 5955608df..6f5ee191a 100644 --- a/src/Models/Channel/Message/Embed/EmbedType.cs +++ b/src/Models/Messages/Embeds/EmbedType.cs @@ -1,37 +1,40 @@ namespace Discord.Net.Models { /// - /// Represents the type of embed. + /// Declares an enum which represents the type of embed for an . /// + /// + /// + /// public enum EmbedType { /// - /// Generic embed rendered from embed attributes. + /// Generic embed rendered from embed attributes. /// Rich, /// - /// Image embed. + /// Image embed. /// Image, /// - /// Video embed. + /// Video embed. /// Video, /// - /// Animated gif image embed rendered as a video embed. + /// Animated gif image embed rendered as a video embed. /// Gifv, /// - /// Article embed. + /// Article embed. /// Article, /// - /// Link embed. + /// Link embed. /// Link, } diff --git a/src/Models/Messages/Embeds/EmbedVideo.cs b/src/Models/Messages/Embeds/EmbedVideo.cs new file mode 100644 index 000000000..8685acd63 --- /dev/null +++ b/src/Models/Messages/Embeds/EmbedVideo.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord embed video object. + /// + /// + /// + /// + public record EmbedVideo + { + /// + /// Source url of video. + /// + [JsonPropertyName("url")] + public Optional Url { get; init; } + + /// + /// A proxied url of the video. + /// + [JsonPropertyName("proxy_url")] + public Optional ProxyUrl { get; init; } + + /// + /// Height of video. + /// + [JsonPropertyName("height")] + public Optional Height { get; init; } + + /// + /// Width of video. + /// + [JsonPropertyName("width")] + public Optional Width { get; init; } + } +} diff --git a/src/Models/Messages/Message.cs b/src/Models/Messages/Message.cs new file mode 100644 index 000000000..aaad35b2b --- /dev/null +++ b/src/Models/Messages/Message.cs @@ -0,0 +1,199 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord message object. + /// + /// + /// + /// + public record Message + { + /// + /// Id of the . + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// Id of the the was sent in. + /// + [JsonPropertyName("channel_id")] + public Snowflake ChannelId { get; init; } + + /// + /// Id of the the message was sent in. + /// + [JsonPropertyName("guild_id")] + public Optional GuildId { get; init; } + + /// + /// The author of this message (not guaranteed to be a valid user, but a webhook). + /// + [JsonPropertyName("author")] + public User? Author { get; init; } // Required property candidate + + /// + /// properties for this 's author. + /// + [JsonPropertyName("member")] + public Optional Member { get; init; } + + /// + /// Contents of the . + /// + [JsonPropertyName("content")] + public string? Content { get; init; } // Required property candidate + + /// + /// When this was sent. + /// + [JsonPropertyName("timestamp")] + public DateTimeOffset Timestamp { get; init; } + + /// + /// When this was edited (or null if never). + /// + [JsonPropertyName("edited_timestamp")] + public DateTimeOffset? EditedTimestamp { get; init; } + + /// + /// Whether this was a TTS . + /// + [JsonPropertyName("tts")] + public bool Tts { get; init; } + + /// + /// Whether this mentions everyone. + /// + [JsonPropertyName("mention_everyone")] + public bool MentionEveryone { get; init; } + + /// + /// Users specifically mentioned in the . + /// + [JsonPropertyName("mentions")] + public UserMention[]? Mentions { get; init; } // Required property candidate + + /// + /// s specifically mentioned in this . + /// + [JsonPropertyName("mention_roles")] + public Snowflake[]? MentionRoles { get; init; } // Required property candidate + + /// + /// s specifically mentioned in this . + /// + [JsonPropertyName("mention_channels")] + public Optional MentionChannels { get; init; } + + /// + /// Any attached files. + /// + [JsonPropertyName("attachments")] + public Attachment[]? Attachments { get; init; } // Required property candidate + + /// + /// Any embedded content. + /// + [JsonPropertyName("embeds")] + public Embed[]? Embeds { get; init; } // Required property candidate + + /// + /// s to the . + /// + [JsonPropertyName("reactions")] + public Optional Reactions { get; init; } + + /// + /// Used for validating a was sent. + /// + [JsonPropertyName("nonce")] + public Optional Nonce { get; init; } + + /// + /// Whether this is pinned. + /// + [JsonPropertyName("pinned")] + public bool Pinned { get; init; } + + /// + /// If the is generated by a , + /// this is the 's id. + /// + [JsonPropertyName("webhook_id")] + public Optional WebhookId { get; init; } + + /// + /// Type of . + /// + [JsonPropertyName("type")] + public MessageType Type { get; init; } + + /// + /// Sent with Rich Presence-related chat embeds. + /// + [JsonPropertyName("activity")] + public Optional Activity { get; init; } + + /// + /// Sent with Rich Presence-related chat embeds. + /// + [JsonPropertyName("application")] + public Optional Application { get; init; } + + /// + /// If the is a response to an Interaction, + /// this is the id of the interaction's application. + /// + [JsonPropertyName("application_id")] + public Optional ApplicationId { get; init; } + + /// + /// Data showing the source of a crosspost, channel follow add, pin, or reply message. + /// + [JsonPropertyName("message_reference")] + public Optional MessageReference { get; init; } + + /// + /// Message flags combined as a bitfield. + /// + [JsonPropertyName("flags")] + public Optional Flags { get; init; } + + /// + /// The s sent with the . + /// + [JsonPropertyName("stickers")] + public Optional Stickers { get; init; } + + /// + /// The associated with the . + /// + [JsonPropertyName("referenced_message")] + public Optional ReferencedMessage { get; init; } + + /// + /// Sent if the is a response to an Interaction. + /// + [JsonPropertyName("interaction")] + public Optional Interaction { get; init; } + + /// + /// The thread that was started from this , + /// includes s. + /// + [JsonPropertyName("thread")] + public Optional Thread { get; init; } + + /// + /// Sent if the contains s like + /// s, s, or other + /// interactive components. + /// + [JsonPropertyName("components")] + public Optional Components { get; init; } + } +} diff --git a/src/Models/Messages/MessageActivity.cs b/src/Models/Messages/MessageActivity.cs new file mode 100644 index 000000000..a1ba8530c --- /dev/null +++ b/src/Models/Messages/MessageActivity.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord message activity object. + /// + /// + /// + /// + public record MessageActivity + { + /// + /// Type of message activity. + /// + [JsonPropertyName("type")] + public MessageActivityType Type { get; init; } + + /// + /// from a Rich Presence event. + /// + [JsonPropertyName("party_id")] + public Optional PartyId { get; init; } + } +} diff --git a/src/Models/Messages/MessageActivityType.cs b/src/Models/Messages/MessageActivityType.cs new file mode 100644 index 000000000..5e12ddbed --- /dev/null +++ b/src/Models/Messages/MessageActivityType.cs @@ -0,0 +1,31 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the message activity type for a . + /// + /// + /// + /// + public enum MessageActivityType + { + /// + /// The message activity is to join. + /// + Join = 1, + + /// + /// The message activity is to spectate a stream. + /// + Spectate = 2, + + /// + /// The message activity is to listen to music. + /// + Listen = 3, + + /// + /// The message activity is to request to join. + /// + JoinRequest = 5, + } +} diff --git a/src/Models/Messages/MessageFlags.cs b/src/Models/Messages/MessageFlags.cs new file mode 100644 index 000000000..1d0fe1150 --- /dev/null +++ b/src/Models/Messages/MessageFlags.cs @@ -0,0 +1,58 @@ +using System; + +namespace Discord.Net.Models +{ + /// + /// Declares a flag enum which represents the message flags for a . + /// + /// + /// + /// + [Flags] + public enum MessageFlags + { + /// + /// This has been published to subscribed + /// s (via Channel Following). + /// + Crossposted = 1 << 0, + + /// + /// This originated from a + /// in another (via Channel Following). + /// + IsCrosspost = 1 << 1, + + /// + /// Do not include any s when serializing this . + /// + SuppressEmbeds = 1 << 2, + + /// + /// The source for this crosspost has been + /// deleted (via Channel Following). + /// + SourceMessageDeleted = 1 << 3, + + /// + /// This came from the urgent message system. + /// + Urgent = 1 << 4, + + /// + /// This has an associated , + /// with the same id as the message. + /// + HasThread = 1 << 5, + + /// + /// This is only visible to the user who invoked the Interaction. + /// + Ephemeral = 1 << 6, + + /// + /// This is an Interaction Response and the bot is "thinking". + /// + Loading = 1 << 7, + } +} diff --git a/src/Models/Messages/MessageInteraction.cs b/src/Models/Messages/MessageInteraction.cs new file mode 100644 index 000000000..9abfcc3e4 --- /dev/null +++ b/src/Models/Messages/MessageInteraction.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord message interaction object. + /// + /// + /// + /// + public record MessageInteraction + { + /// + /// Id of the interaction. + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// The type of interaction. + /// + [JsonPropertyName("type")] + public InteractionType Type { get; init; } + + /// + /// The name of the ApplicationCommand. + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// The who invoked the interaction. + /// + [JsonPropertyName("user")] + public User? User { get; init; } // Required property candidate + } +} diff --git a/src/Models/Messages/MessageReference.cs b/src/Models/Messages/MessageReference.cs new file mode 100644 index 000000000..ded23e8a6 --- /dev/null +++ b/src/Models/Messages/MessageReference.cs @@ -0,0 +1,38 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord message reference object. + /// + /// + /// + /// + public record MessageReference + { + /// + /// Id of the originating . + /// + [JsonPropertyName("message_id")] + public Optional MessageId { get; init; } + + /// + /// Id of the originating 's . + /// + [JsonPropertyName("channel_id")] + public Optional ChannelId { get; init; } + + /// + /// Id of the originating 's . + /// + [JsonPropertyName("guild_id")] + public Optional GuildId { get; init; } + + /// + /// When sending, whether to error if the referenced doesn't + /// exist instead of sending as a normal (non-reply) , default true. + /// + [JsonPropertyName("fail_if_not_exists")] + public Optional FailIfNotExists { get; init; } + } +} diff --git a/src/Models/Channel/Message/MessageType.cs b/src/Models/Messages/MessageType.cs similarity index 53% rename from src/Models/Channel/Message/MessageType.cs rename to src/Models/Messages/MessageType.cs index 042433d36..6265b9f61 100644 --- a/src/Models/Channel/Message/MessageType.cs +++ b/src/Models/Messages/MessageType.cs @@ -1,120 +1,122 @@ -using System; - namespace Discord.Net.Models { /// - /// Represents the message type. + /// Declares an enum which represents the message type for a . /// - [Flags] + /// + /// + /// public enum MessageType { /// - /// Default message type. + /// Default message type. /// Default = 0, /// - /// Recipient was added. + /// Recipient was added to a group . /// RecipientAdd = 1, /// - /// Recipient was removed. + /// Recipient was removed from a group . /// RecipientRemove = 2, /// - /// Request to join a call. + /// Request to join a call. /// Call = 3, /// - /// Channel name was changed. + /// Group name was changed. /// ChannelNameChange = 4, /// - /// Channel icon was changed. + /// Group icon was changed. /// ChannelIconChange = 5, /// - /// Message was pinned in this channel. + /// was pinned in this . /// ChannelPinnedMessage = 6, /// - /// User joined the guild. + /// joined the . /// GuildMemberJoin = 7, /// - /// + /// A boosted the . /// UserPremiumGuildSubscription = 8, /// - /// + /// reached tier one of nitro boost. /// UserPremiumGuildSubscriptionTier1 = 9, /// - /// + /// reached tier two of nitro boost. /// UserPremiumGuildSubscriptionTier2 = 10, /// - /// + /// reached tier three of nitro boost. /// UserPremiumGuildSubscriptionTier3 = 11, /// - /// + /// has been followed (for news channels). /// ChannelFollowAdd = 12, /// - /// + /// removed from guild discovery. /// GuildDiscoveryDisqualified = 14, /// - /// + /// requalified to guild discovery. /// GuildDiscoveryRequalified = 15, /// - /// + /// First warning that the failed to reach + /// guild discovery requirements. /// GuildDiscoveryGracePeriodInitialWarning = 16, /// - /// + /// Last warning that the failed to reach + /// guild discovery requirements. /// GuildDiscoveryGracePeriodFinalWarning = 17, /// - /// + /// A thread was created. /// ThreadCreated = 18, /// - /// + /// This is a reply. /// Reply = 19, /// - /// + /// An application command was executed. /// ApplicationCommand = 20, /// - /// + /// Starter message for a thread . /// ThreadStarterMessage = 21, /// - /// + /// Reminder to invite people to the . /// GuildInviteReminder = 22, } diff --git a/src/Models/Messages/Reaction.cs b/src/Models/Messages/Reaction.cs new file mode 100644 index 000000000..28b5306a0 --- /dev/null +++ b/src/Models/Messages/Reaction.cs @@ -0,0 +1,31 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord reaction object. + /// + /// + /// + /// + public record Reaction + { + /// + /// Times this has been used to react. + /// + [JsonPropertyName("count")] + public int Count { get; init; } + + /// + /// Whether the current user reacted using this . + /// + [JsonPropertyName("me")] + public bool Me { get; init; } + + /// + /// information. + /// + [JsonPropertyName("emoji")] + public Emoji? Emoji { get; init; } // Required property candidate + } +} diff --git a/src/Models/Messages/Sticker.cs b/src/Models/Messages/Sticker.cs new file mode 100644 index 000000000..79acc86b8 --- /dev/null +++ b/src/Models/Messages/Sticker.cs @@ -0,0 +1,55 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord sticker object. + /// + /// + /// + /// + public record Sticker + { + /// + /// Id of the . + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// Id of the pack the is from. + /// + [JsonPropertyName("pack_id")] + public Snowflake PackId { get; init; } + + /// + /// Name of the . + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// Description of the . + /// + [JsonPropertyName("description")] + public string? Description { get; init; } // Required property candidate + + /// + /// A comma-separated list of tags for the . + /// + [JsonPropertyName("tags")] + public Optional Tags { get; init; } + + /// + /// asset hash. + /// + [JsonPropertyName("asset")] + public string? Asset { get; init; } // Required property candidate + + /// + /// Type of format. + /// + [JsonPropertyName("format_type")] + public StickerFormatType FormatType { get; init; } + } +} diff --git a/src/Models/Messages/StickerFormatType.cs b/src/Models/Messages/StickerFormatType.cs new file mode 100644 index 000000000..0c55d30bf --- /dev/null +++ b/src/Models/Messages/StickerFormatType.cs @@ -0,0 +1,26 @@ +namespace Discord.Net.Models +{ + /// + /// Declares a flag enum which represents the format type for a . + /// + /// + /// + /// + public enum StickerFormatType + { + /// + /// The sticker format is a png. + /// + Png = 1, + + /// + /// The sticker format is a apng. + /// + Apng = 2, + + /// + /// The sticker format is a lottie. + /// + Lottie = 3, + } +} diff --git a/src/Models/Optional.cs b/src/Models/Optional.cs index ba31cb061..91bbc177b 100644 --- a/src/Models/Optional.cs +++ b/src/Models/Optional.cs @@ -3,41 +3,46 @@ using System; namespace Discord.Net { /// - /// Container to keep a type that might not be present. + /// Container to keep a type that might not be present. /// /// Inner type public struct Optional { + /// + /// Creates a default with no specified value. + /// + public static Optional Unspecified => default; + private readonly T _value; /// - /// Gets the inner value of this if present. + /// Gets the inner value of this if present. /// /// The value inside this . /// This has no inner value. public T Value => !IsSpecified ? throw new InvalidOperationException("This property has no value set.") : _value; /// - /// Gets if this has an inner value. + /// Gets if this has an inner value. /// /// A boolean that determines if this has a . public bool IsSpecified { get; } - private Optional(T value) + internal Optional(T value) { _value = value; IsSpecified = true; } /// - /// Creates a new unspecified . + /// Creates a new unspecified . /// /// An unspecified . public static Optional Create() => default; /// - /// Creates a new with the specified . + /// Creates a new with the specified . /// /// Value that will be specified for this . /// A specified with the provided value inside. @@ -45,14 +50,14 @@ namespace Discord.Net => new(value); /// - /// Gets the or their value. + /// Gets the or their value. /// /// The value inside this or their value. public T GetValueOrDefault() => _value; /// - /// Gets the or the default value provided. + /// Gets the or the default value provided. /// /// The value inside this or default value provided. public T GetValueOrDefault(T defaultValue) @@ -73,14 +78,14 @@ namespace Discord.Net => IsSpecified ? _value?.GetHashCode() ?? default : default; /// - /// Returns the inner value ToString value or this type fully qualified name. + /// Returns the inner value ToString value or this type fully qualified name. /// /// The inner value string value or this type fully qualified name. public override string? ToString() => IsSpecified ? _value?.ToString() : default; /// - /// Creates a new with the specified . + /// Creates a new with the specified . /// /// Value to convert /// A new with the specified @@ -88,11 +93,60 @@ namespace Discord.Net => new(value); /// - /// Gets the inner value. + /// Gets the inner value. /// /// Value to convert /// The inner value public static explicit operator T(Optional value) => value.Value; } + + /// + /// Helper class to create s. + /// + public static class Optional + { + /// + /// Creates an unspecified . + /// + /// + /// Inner type. + /// + /// + /// An unspecified . + /// + public static Optional Create() + => Optional.Unspecified; + + /// + /// Creates a specified with the provided value. + /// + /// + /// Inner type. + /// + /// + /// Inner value. + /// + /// + /// An specified with provided value. + /// + public static Optional Create(T value) + => new(value); + + /// + /// Converts an into a . + /// + /// + /// Inner type. + /// + /// + /// Value to be converted. + /// + /// + /// A based on the provided value. + /// + public static T? ToNullable(this Optional value) + where T : struct + => value.IsSpecified ? value.Value : null; + } } diff --git a/src/Models/Permissions/Overwrite.cs b/src/Models/Permissions/Overwrite.cs new file mode 100644 index 000000000..7cecba0f9 --- /dev/null +++ b/src/Models/Permissions/Overwrite.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord overwrite object. + /// + /// + /// + /// + public record Overwrite + { + /// + /// or id. + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// Type of entity this belongs to. + /// + [JsonPropertyName("type")] + public OverwriteType Type { get; init; } + + /// + /// bit set. + /// + [JsonPropertyName("allow")] + public Permissions Allow { get; init; } + + /// + /// bit set. + /// + [JsonPropertyName("deny")] + public Permissions Deny { get; init; } + } +} diff --git a/src/Models/Permissions/OverwriteType.cs b/src/Models/Permissions/OverwriteType.cs new file mode 100644 index 000000000..5f1868ae1 --- /dev/null +++ b/src/Models/Permissions/OverwriteType.cs @@ -0,0 +1,18 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the type of the . + /// + public enum OverwriteType + { + /// + /// The type of the is a . + /// + Role = 0, + + /// + /// The type of the is a . + /// + GuildMember = 1, + } +} diff --git a/src/Models/Permissions/Permissions.cs b/src/Models/Permissions/Permissions.cs index 46313fcaa..6af3b70e8 100644 --- a/src/Models/Permissions/Permissions.cs +++ b/src/Models/Permissions/Permissions.cs @@ -3,189 +3,194 @@ using System; namespace Discord.Net.Models { /// - /// Represents the permissions flags. + /// Represents the permissions flags. /// [Flags] - public enum Permissions + public enum Permissions : ulong { /// - /// Allows creation of instant invites. + /// Default value. + /// + None = 0, + + /// + /// Allows creation of instant invites. /// CreateInstantInvite = 1 << 0, /// - /// Allows kicking members. + /// Allows kicking members. /// KickMembers = 1 << 1, /// - /// Allows banning members. + /// Allows banning members. /// BanMembers = 1 << 2, /// - /// Allows all permissions and bypasses channel permission overwrites. + /// Allows all permissions and bypasses channel permission overwrites. /// Administrator = 1 << 3, /// - /// Allows management and editing of channels. + /// Allows management and editing of channels. /// ManageChannels = 1 << 4, /// - /// Allows management and editing of the guild. + /// Allows management and editing of the guild. /// ManageGuild = 1 << 5, /// - /// Allows for the addition of reactions to messages. + /// Allows for the addition of reactions to messages. /// AddReactions = 1 << 6, /// - /// Allows for viewing of audit logs. + /// Allows for viewing of audit logs. /// ViewAuditLog = 1 << 7, /// - /// Allows for using priority speaker in a voice channel. + /// Allows for using priority speaker in a voice channel. /// PrioritySpeaker = 1 << 8, /// - /// Allows the user to go live. + /// Allows the user to go live. /// Stream = 1 << 9, /// - /// Allows guild members to view a channel, which includes reading messages in text channels. + /// Allows guild members to view a channel, which includes reading messages in text channels. /// ViewChannel = 1 << 10, /// - /// Allows for sending messages in a channel. + /// Allows for sending messages in a channel. /// SendMessages = 1 << 11, /// - /// Allows for sending of /tts messages. + /// Allows for sending of /tts messages. /// SendTtsMessages = 1 << 12, /// - /// Allows for deletion of other users messages. + /// Allows for deletion of other users messages. /// ManageMessages = 1 << 13, /// - /// Links sent by users with this permission will be auto-embedded. + /// Links sent by users with this permission will be auto-embedded. /// EmbedLinks = 1 << 14, /// - /// Allows for uploading images and files. + /// Allows for uploading images and files. /// AttachFiles = 1 << 15, /// - /// Allows for reading of message history. + /// Allows for reading of message history. /// ReadMessageHistory = 1 << 16, /// - /// Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel. + /// Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel. /// MentionEveryone = 1 << 17, /// - /// Allows the usage of custom emojis from other servers. + /// Allows the usage of custom emojis from other servers. /// UseExternalEmojis = 1 << 18, /// - /// Allows for viewing guild insights. + /// Allows for viewing guild insights. /// ViewGuildInsights = 1 << 19, /// - /// Allows for joining of a voice channel. + /// Allows for joining of a voice channel. /// Connect = 1 << 20, /// - /// Allows for speaking in a voice channel. + /// Allows for speaking in a voice channel. /// Speak = 1 << 21, /// - /// Allows for muting members in a voice channel. + /// Allows for muting members in a voice channel. /// MuteMembers = 1 << 22, /// - /// Allows for deafening of members in a voice channel. + /// Allows for deafening of members in a voice channel. /// DeafenMembers = 1 << 23, /// - /// Allows for moving of members between voice channels. + /// Allows for moving of members between voice channels. /// MoveMembers = 1 << 24, /// - /// Allows for using voice-activity-detection in a voice channel. + /// Allows for using voice-activity-detection in a voice channel. /// UseVad = 1 << 25, /// - /// Allows for modification of own nickname. + /// Allows for modification of own nickname. /// ChangeNickname = 1 << 26, /// - /// Allows for modification of other users nicknames. + /// Allows for modification of other users nicknames. /// ManageNicknames = 1 << 27, /// - /// Allows management and editing of roles. + /// Allows management and editing of roles. /// ManageRoles = 1 << 28, /// - /// Allows management and editing of webhooks. + /// Allows management and editing of webhooks. /// ManageWebhooks = 1 << 29, /// - /// Allows management and editing of emojis. + /// Allows management and editing of emojis. /// ManageEmojis = 1 << 30, /// - /// Allows members to use slash commands in text channels. + /// Allows members to use slash commands in text channels. /// - UseSlashCommands = 1 << 31, + UseSlashCommands = 1UL << 31, /// - /// Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.). + /// Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.). /// - RequestToSpeak = 1 << 32, + RequestToSpeak = 1UL << 32, /// - /// Allows for deleting and archiving threads, and viewing all private threads. + /// Allows for deleting and archiving threads, and viewing all private threads. /// - ManageThreads = 1 << 34, + ManageThreads = 1UL << 34, /// - /// Allows for creating and participating in threads. + /// Allows for creating and participating in threads. /// - UsePublicThreads = 1 << 35, + UsePublicThreads = 1UL << 35, /// - /// Allows for creating and participating in private threads. + /// Allows for creating and participating in private threads. /// - UsePrivateThreads = 1 << 36, + UsePrivateThreads = 1UL << 36, } } diff --git a/src/Models/Permissions/Role.cs b/src/Models/Permissions/Role.cs index f51d3ddc6..ba3000fbf 100644 --- a/src/Models/Permissions/Role.cs +++ b/src/Models/Permissions/Role.cs @@ -3,88 +3,65 @@ using System.Text.Json.Serialization; namespace Discord.Net.Models { /// - /// Represents a role object. + /// Represents a discord role object. /// + /// + /// + /// public record Role { /// - /// Creates a with the provided parameters. - /// - /// Role id. - /// Role name. - /// Integer representation of hexadecimal color code. - /// If this role is pinned in the user listing. - /// Position of this role. - /// Permission bit set. - /// Whether this role is managed by an integration. - /// Whether this role is mentionable. - /// The tags this role has. - [JsonConstructor] - public Role(Snowflake id, string name, int color, bool hoist, int position, Permissions permissions, bool managed, bool mentionable, Optional tags) - { - Id = id; - Name = name; - Color = color; - Hoist = hoist; - Position = position; - Permissions = permissions; - Managed = managed; - Mentionable = mentionable; - Tags = tags; - } - - /// - /// Role id. + /// id. /// [JsonPropertyName("id")] - public Snowflake Id { get; } + public Snowflake Id { get; init; } /// - /// Role name. + /// name. /// [JsonPropertyName("name")] - public string Name { get; } + public string? Name { get; init; } // Required property candidate /// - /// Integer representation of hexadecimal color code. + /// of this . /// [JsonPropertyName("color")] - public int Color { get; } + public Color Color { get; init; } /// - /// If this role is pinned in the user listing. + /// If this is pinned in the listing. /// [JsonPropertyName("hoist")] - public bool Hoist { get; } + public bool Hoist { get; init; } /// - /// Position of this role. + /// Position of this . /// [JsonPropertyName("position")] - public int Position { get; } + public int Position { get; init; } /// - /// Permission bit set. + /// bit set. /// [JsonPropertyName("permissions")] - public Permissions Permissions { get; } + public Permissions Permissions { get; init; } /// - /// Whether this role is managed by an integration. + /// Whether this is managed by an . /// [JsonPropertyName("managed")] - public bool Managed { get; } + public bool Managed { get; init; } /// - /// Whether this role is mentionable. + /// Whether this is mentionable. /// [JsonPropertyName("mentionable")] - public bool Mentionable { get; } + public bool Mentionable { get; init; } /// - /// The tags this role has. + /// The tags this has. /// [JsonPropertyName("tags")] - public Optional Tags { get; } + public Optional Tags { get; init; } } } diff --git a/src/Models/Permissions/RoleTags.cs b/src/Models/Permissions/RoleTags.cs index c12f22058..4f76d8e00 100644 --- a/src/Models/Permissions/RoleTags.cs +++ b/src/Models/Permissions/RoleTags.cs @@ -3,38 +3,27 @@ using System.Text.Json.Serialization; namespace Discord.Net.Models { /// - /// Represents a role tags object. + /// Represents a discord role tags object. /// + /// + /// + /// public record RoleTags { /// - /// Creates a with the provided parameters. - /// - /// The id of the bot this role belongs to. - /// The id of the integration this role belongs to. - /// Whether this is the guild's premium subscriber role. - [JsonConstructor] - public RoleTags(Optional botId, Optional integrationId, Optional premiumSubscriber) - { - BotId = botId; - IntegrationId = integrationId; - PremiumSubscriber = premiumSubscriber; - } - - /// - /// The id of the bot this role belongs to. + /// The id of the bot this belongs to. /// [JsonPropertyName("bot_id")] public Optional BotId { get; } /// - /// The id of the integration this role belongs to. + /// The id of the this role belongs to. /// [JsonPropertyName("integration_id")] public Optional IntegrationId { get; } /// - /// Whether this is the guild's premium subscriber role. + /// Whether this is the 's premium subscriber . /// [JsonPropertyName("premium_subscriber")] public Optional PremiumSubscriber { get; } diff --git a/src/Models/Presences/Activity.cs b/src/Models/Presences/Activity.cs new file mode 100644 index 000000000..72a9a99f7 --- /dev/null +++ b/src/Models/Presences/Activity.cs @@ -0,0 +1,103 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord activity object. + /// + /// + /// + /// + public record Activity + { + /// + /// The 's name. + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// Activity type. + /// + [JsonPropertyName("type")] + public ActivityType Type { get; init; } + + /// + /// Stream url, is validated when is . + /// + [JsonPropertyName("url")] + public Optional Url { get; init; } + + /// + /// Unix timestamp of when the was added to the 's session. + /// + [JsonPropertyName("created_at")] + public int CreatedAt { get; init; } + + /// + /// Unix timestamps for start and/or end of the game. + /// + [JsonPropertyName("timestamps")] + public Optional Timestamps { get; init; } + + /// + /// id for the game. + /// + [JsonPropertyName("application_id")] + public Optional ApplicationId { get; init; } + + /// + /// What the player is currently doing. + /// + [JsonPropertyName("details")] + public Optional Details { get; init; } + + /// + /// The 's current party status. + /// + [JsonPropertyName("state")] + public Optional State { get; init; } + + /// + /// The used for a custom status. + /// + [JsonPropertyName("emoji")] + public Optional Emoji { get; init; } + + /// + /// Information for the current party of the player. + /// + [JsonPropertyName("party")] + public Optional Party { get; init; } + + /// + /// Images for the presence and their hover texts. + /// + [JsonPropertyName("assets")] + public Optional Assets { get; init; } + + /// + /// Secrets for Rich Presence joining and spectating. + /// + [JsonPropertyName("secrets")] + public Optional Secrets { get; init; } + + /// + /// Whether or not the is an instanced game session. + /// + [JsonPropertyName("instance")] + public Optional Instance { get; init; } + + /// + /// Activity flags ORd together, describes what the payload includes. + /// + [JsonPropertyName("flags")] + public Optional Flags { get; init; } + + /// + /// The custom buttons shown in the Rich Presence (max 2). + /// + [JsonPropertyName("buttons")] + public Optional ButtonLabels { get; init; } + } +} diff --git a/src/Models/Presences/ActivityAssets.cs b/src/Models/Presences/ActivityAssets.cs new file mode 100644 index 000000000..e693f843c --- /dev/null +++ b/src/Models/Presences/ActivityAssets.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord activity assets object. + /// + /// + /// + /// + public record ActivityAssets + { + /// + /// The id for a large asset of the , usually a snowflake. + /// + [JsonPropertyName("large_image")] + public Optional LargeImage { get; init; } + + /// + /// Text displayed when hovering over the large image of the . + /// + [JsonPropertyName("large_text")] + public Optional LargeText { get; init; } + + /// + /// The id for a small asset of the , usually a snowflake. + /// + [JsonPropertyName("small_image")] + public Optional SmallImage { get; init; } + + /// + /// Text displayed when hovering over the small image of the . + /// + [JsonPropertyName("small_text")] + public Optional SmallText { get; init; } + } +} diff --git a/src/Models/Gateway/ActivityFlags.cs b/src/Models/Presences/ActivityFlags.cs similarity index 57% rename from src/Models/Gateway/ActivityFlags.cs rename to src/Models/Presences/ActivityFlags.cs index e5563c8db..c86ee7ea2 100644 --- a/src/Models/Gateway/ActivityFlags.cs +++ b/src/Models/Presences/ActivityFlags.cs @@ -3,38 +3,41 @@ using System; namespace Discord.Net.Models { /// - /// Represents the activity flags. + /// Declares a flag enum which represents the activity flags for an . /// + /// + /// + /// [Flags] public enum ActivityFlags { /// - /// Activity instance. + /// Activity instance. /// Instance = 1 << 0, /// - /// Activity join. + /// Activity join. /// Join = 1 << 1, /// - /// Activity spectate. + /// Activity spectate. /// Spectate = 1 << 2, /// - /// Activity join request. + /// Activity join request. /// JoinRequest = 1 << 3, /// - /// Activity sync. + /// Activity sync. /// Sync = 1 << 4, /// - /// Activity play. + /// Activity play. /// Play = 1 << 5, } diff --git a/src/Models/Presences/ActivityParty.cs b/src/Models/Presences/ActivityParty.cs new file mode 100644 index 000000000..b6168b647 --- /dev/null +++ b/src/Models/Presences/ActivityParty.cs @@ -0,0 +1,28 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord activity party object. + /// + /// + /// + /// + public record ActivityParty + { + /// + /// The id of the party. + /// + [JsonPropertyName("id")] + public Optional Id { get; init; } + + /// + /// Used to show the party's current and maximum size. + /// + /// + /// Array of two integers (current_size, max_size). + /// + [JsonPropertyName("size")] + public Optional Size { get; init; } + } +} diff --git a/src/Models/Presences/ActivitySecrets.cs b/src/Models/Presences/ActivitySecrets.cs new file mode 100644 index 000000000..4db6b3a22 --- /dev/null +++ b/src/Models/Presences/ActivitySecrets.cs @@ -0,0 +1,31 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord activity secrets object. + /// + /// + /// + /// + public record ActivitySecrets + { + /// + /// The secret for joining a party. + /// + [JsonPropertyName("join")] + public Optional Join { get; init; } + + /// + /// The secret for spectating a game. + /// + [JsonPropertyName("spectate")] + public Optional Spectate { get; init; } + + /// + /// The secret for a specific instanced match. + /// + [JsonPropertyName("match")] + public Optional Match { get; init; } + } +} diff --git a/src/Models/Presences/ActivityTimestamps.cs b/src/Models/Presences/ActivityTimestamps.cs new file mode 100644 index 000000000..e97b9b4d8 --- /dev/null +++ b/src/Models/Presences/ActivityTimestamps.cs @@ -0,0 +1,26 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord activity timestamp object. + /// + /// + /// + /// + public record ActivityTimestamps + { + /// + /// When the started. + /// + [JsonPropertyName("start")] + public Optional Start { get; init; } + + /// + /// When the ends. + /// + [JsonPropertyName("end")] + public Optional End { get; init; } + } +} diff --git a/src/Models/Gateway/ActivityType.cs b/src/Models/Presences/ActivityType.cs similarity index 55% rename from src/Models/Gateway/ActivityType.cs rename to src/Models/Presences/ActivityType.cs index 150f627f5..21c973c75 100644 --- a/src/Models/Gateway/ActivityType.cs +++ b/src/Models/Presences/ActivityType.cs @@ -1,37 +1,40 @@ namespace Discord.Net.Models { /// - /// Represents the activity type. + /// Declares a flag enum which represents the activity type for an . /// + /// + /// + /// public enum ActivityType { /// - /// Playing {name}. + /// Playing {name}. /// Game = 0, /// - /// Streaming {details}. + /// Streaming {details}. /// Streaming = 1, /// - /// Listening to {name}. + /// Listening to {name}. /// Listening = 2, /// - /// Watching {name}. + /// Watching {name}. /// Watching = 3, /// - /// {emoji} {name}. + /// {emoji} {name}. /// Custom = 4, /// - /// Competing in {name}. + /// Competing in {name}. /// Competing = 5, } diff --git a/src/Models/Presences/ClientStatus.cs b/src/Models/Presences/ClientStatus.cs new file mode 100644 index 000000000..8675916a3 --- /dev/null +++ b/src/Models/Presences/ClientStatus.cs @@ -0,0 +1,34 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord client status object. + /// + /// + /// + /// + public record ClientStatus + { + /// + /// The 's status set for an active + /// desktop (Windows, Linux, Mac) application session. + /// + [JsonPropertyName("desktop")] + public Optional Desktop { get; init; } + + /// + /// The 's status set for an active mobile + /// (iOS, Android) application session. + /// + [JsonPropertyName("mobile")] + public Optional Mobile { get; init; } + + /// + /// The 's status set for an active web + /// (browser, bot account) application session. + /// + [JsonPropertyName("web")] + public Optional Web { get; init; } + } +} diff --git a/src/Models/Presences/Presence.cs b/src/Models/Presences/Presence.cs new file mode 100644 index 000000000..d78ddcd51 --- /dev/null +++ b/src/Models/Presences/Presence.cs @@ -0,0 +1,43 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord presence object. + /// + /// + /// + /// + public record Presence + { + /// + /// The presence is being updated for. + /// + [JsonPropertyName("user")] + public User? User { get; init; } // Required property candidate + + /// + /// Id of the . + /// + [JsonPropertyName("guild_id")] + public Snowflake GuildId { get; init; } + + /// + /// The status. + /// + [JsonPropertyName("status")] + public UserStatus Status { get; init; } + + /// + /// 's current activities. + /// + [JsonPropertyName("activities")] + public Activity[]? Activities { get; init; } // Required property candidate + + /// + /// 's platform-dependent status. + /// + [JsonPropertyName("client_status")] + public ClientStatus? ClientStatus { get; init; } // Required property candidate + } +} diff --git a/src/Models/SlashCommands/InteractionType.cs b/src/Models/SlashCommands/InteractionType.cs deleted file mode 100644 index ec6a431af..000000000 --- a/src/Models/SlashCommands/InteractionType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Discord.Net.Models -{ - /// - /// Represents the interaction type. - /// - public enum InteractionType - { - /// - /// Received when registering an interaction, replied with a pong. - /// - Ping = 1, - - /// - /// This interaction is from a slash command. - /// - ApplicationCommand = 2, - - /// - /// This interaction is from a component. - /// - MessageComponent = 3, - } -} diff --git a/src/Models/SlashCommands/MessageInteraction.cs b/src/Models/SlashCommands/MessageInteraction.cs deleted file mode 100644 index c34127068..000000000 --- a/src/Models/SlashCommands/MessageInteraction.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a message interaction object. - /// - public record MessageInteraction - { - /// - /// Creates a with the provided parameters. - /// - /// Id of the interaction. - /// The type of interaction. - /// The name of the ApplicationCommand. - /// The user who invoked the interaction. - [JsonConstructor] - public MessageInteraction(Snowflake id, InteractionType type, string name, User user) - { - Id = id; - Type = type; - Name = name; - User = user; - } - - /// - /// Id of the interaction. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// The type of interaction. - /// - [JsonPropertyName("type")] - public InteractionType Type { get; } - - /// - /// The name of the ApplicationCommand. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// The user who invoked the interaction. - /// - [JsonPropertyName("user")] - public User User { get; } - } -} diff --git a/src/Models/Snowflake.cs b/src/Models/Snowflake.cs index 08bb4d6a9..931820203 100644 --- a/src/Models/Snowflake.cs +++ b/src/Models/Snowflake.cs @@ -3,20 +3,20 @@ using System; namespace Discord.Net { /// - /// Represents a discord snowflake. + /// Represents a discord snowflake. /// public struct Snowflake { private const ulong DiscordEpoch = 1420070400000UL; /// - /// Gets the raw value of this snowflake. + /// Gets the raw value of this snowflake. /// /// A with the rae value. public ulong RawValue { get; } /// - /// Creates a based on the provided. + /// Creates a based on the provided. /// /// Raw value of the snowflake. public Snowflake(ulong value) @@ -25,7 +25,7 @@ namespace Discord.Net } /// - /// Creates a based on the provided. + /// Creates a based on the provided. /// /// DateTimeOffset of this snowflake. public Snowflake(DateTimeOffset dateTimeOffset) @@ -34,40 +34,40 @@ namespace Discord.Net } /// - /// Creates a based on the provided. + /// Creates a based on the provided. /// /// DateTime of this snowflake. public Snowflake(DateTime dateTime) : this(new DateTimeOffset(dateTime)) { } /// - /// Converts this to a . + /// Converts this to a . /// /// A of this snowflake. public DateTimeOffset ToDateTimeOffset() => DateTimeOffset.FromUnixTimeMilliseconds((long)((RawValue >> 22) + DiscordEpoch)); /// - /// Converts this to a . + /// Converts this to a . /// /// A of this snowflake. public DateTimeOffset ToDateTime() => ToDateTimeOffset().UtcDateTime; /// - /// Converts this to a . + /// Converts this to a . /// /// Value that will be converted /// A with the raw value. public static implicit operator ulong(Snowflake snowflake) => snowflake.RawValue; /// - /// Converts this to a . + /// Converts this to a . /// /// Value that will be converted /// A with as the raw value. public static implicit operator Snowflake(ulong value) => new Snowflake(value); /// - /// Returns the raw value as . + /// Returns the raw value as . /// /// A that is the raw value. public override string ToString() diff --git a/src/Models/StageInstance/PrivacyLevel.cs b/src/Models/StageInstance/PrivacyLevel.cs deleted file mode 100644 index 45e539318..000000000 --- a/src/Models/StageInstance/PrivacyLevel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the privacy level. - /// - public enum PrivacyLevel - { - /// - /// The Stage instance is visible publicly, such as on Stage discovery. - /// - Public = 1, - - /// - /// The Stage instance is visible to only guild members. - /// - GuildOnly = 2, - } -} diff --git a/src/Models/StageInstance/StageInstance.cs b/src/Models/StageInstance/StageInstance.cs deleted file mode 100644 index cf63c8337..000000000 --- a/src/Models/StageInstance/StageInstance.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a stage instance object. - /// - public record StageInstance - { - /// - /// Creates a with the provided parameters. - /// - /// The id of this Stage instance. - /// The guild id of the associated Stage channel. - /// The id of the associated Stage channel. - /// The topic of the Stage instance (1-120 characters). - /// The privacy level of the Stage instance. - /// Whether or not Stage discovery is disabled. - [JsonConstructor] - public StageInstance(Snowflake id, Snowflake guildId, Snowflake channelId, string topic, PrivacyLevel privacyLevel, bool discoverableDisabled) - { - Id = id; - GuildId = guildId; - ChannelId = channelId; - Topic = topic; - PrivacyLevel = privacyLevel; - DiscoverableDisabled = discoverableDisabled; - } - - /// - /// The id of this Stage instance. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// The guild id of the associated Stage channel. - /// - [JsonPropertyName("guild_id")] - public Snowflake GuildId { get; } - - /// - /// The id of the associated Stage channel. - /// - [JsonPropertyName("channel_id")] - public Snowflake ChannelId { get; } - - /// - /// The topic of the Stage instance (1-120 characters). - /// - [JsonPropertyName("topic")] - public string Topic { get; } - - /// - /// The privacy level of the Stage instance. - /// - [JsonPropertyName("privacy_level")] - public PrivacyLevel PrivacyLevel { get; } - - /// - /// Whether or not Stage discovery is disabled. - /// - [JsonPropertyName("discoverable_disabled")] - public bool DiscoverableDisabled { get; } - } -} diff --git a/src/Models/Teams/MembershipState.cs b/src/Models/Teams/MembershipState.cs index e8d41b8b8..0cc70e649 100644 --- a/src/Models/Teams/MembershipState.cs +++ b/src/Models/Teams/MembershipState.cs @@ -1,19 +1,20 @@ -using System; - namespace Discord.Net.Models { /// - /// Represents the membership state type. + /// Declares an enum which represents the membership state for a . /// + /// + /// + /// public enum MembershipState { /// - /// This member has been invited, but did not accept yet. + /// This has been invited, but did not accept yet. /// Invited = 1, /// - /// This member accepted the invite. + /// This accepted the invite. /// Accepted = 2, } diff --git a/src/Models/Teams/Team.cs b/src/Models/Teams/Team.cs index 9fa8fb472..b80a6e99f 100644 --- a/src/Models/Teams/Team.cs +++ b/src/Models/Teams/Team.cs @@ -3,56 +3,41 @@ using System.Text.Json.Serialization; namespace Discord.Net.Models { /// - /// Represents a team object. + /// Represents a discord team object. /// + /// + /// + /// public record Team { /// - /// Creates a with the provided parameters. - /// - /// A hash of the image of the team's icon. - /// The unique id of the team. - /// The members of the team. - /// The name of the team. - /// The user id of the current team owner. - [JsonConstructor] - public Team(string? icon, Snowflake id, TeamMember[] members, string name, Snowflake ownerUserId) - { - Icon = icon; - Id = id; - Members = members; - Name = name; - OwnerUserId = ownerUserId; - } - - /// - /// A hash of the image of the team's icon. + /// A hash of the image of the 's icon. /// [JsonPropertyName("icon")] - public string? Icon { get; } + public string? Icon { get; init; } /// - /// The unique id of the team. + /// The unique id of the . /// [JsonPropertyName("id")] - public Snowflake Id { get; } + public Snowflake Id { get; init; } /// - /// The members of the team. + /// The members of the . /// [JsonPropertyName("members")] - public TeamMember[] Members { get; } + public TeamMember[]? Members { get; init; } // Required property candidate /// - /// The name of the team. + /// The name of the . /// [JsonPropertyName("name")] - public string Name { get; } + public string? Name { get; init; } // Required property candidate /// - /// The user id of the current team owner. + /// The id of the current owner. /// [JsonPropertyName("owner_user_id")] - public Snowflake OwnerUserId { get; } + public Snowflake OwnerUserId { get; init; } } } diff --git a/src/Models/Teams/TeamMember.cs b/src/Models/Teams/TeamMember.cs index 5e31223e2..c019c8503 100644 --- a/src/Models/Teams/TeamMember.cs +++ b/src/Models/Teams/TeamMember.cs @@ -3,48 +3,35 @@ using System.Text.Json.Serialization; namespace Discord.Net.Models { /// - /// Represents a team member object. + /// Represents a discord team member object. /// + /// + /// + /// public record TeamMember { /// - /// Creates a with the provided parameters. - /// - /// The user's membership state on the team. - /// Will always be ["*"]. - /// The id of the parent team of which they are a member. - /// The avatar, discriminator, id, and username of the user. - [JsonConstructor] - public TeamMember(MembershipState membershipState, string[] permissions, Snowflake teamId, User user) - { - MembershipState = membershipState; - Permissions = permissions; - TeamId = teamId; - User = user; - } - - /// - /// The user's membership state on the team. + /// The 's on the . /// [JsonPropertyName("membership_state")] - public MembershipState MembershipState { get; } + public MembershipState MembershipState { get; init; } /// - /// Will always be ["*"]. + /// Will always be ["*"]. /// [JsonPropertyName("permissions")] - public string[] Permissions { get; } + public string[]? Permissions { get; init; } // Required property candidate /// - /// The id of the parent team of which they are a member. + /// The id of the parent of which they are a . /// [JsonPropertyName("team_id")] - public Snowflake TeamId { get; } + public Snowflake TeamId { get; init; } /// - /// The avatar, discriminator, id, and username of the user. + /// The avatar, discriminator, id, and username of the . /// [JsonPropertyName("user")] - public User User { get; } + public User? User { get; init; } // Required property candidate } } diff --git a/src/Models/User/Connection.cs b/src/Models/User/Connection.cs deleted file mode 100644 index 6d77b84c5..000000000 --- a/src/Models/User/Connection.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a connection object. - /// - public record Connection - { - /// - /// Creates a with the provided parameters. - /// - /// Id of the connection account. - /// The username of the connection account. - /// The service of the connection (twitch, youtube). - /// Whether the connection is revoked. - /// An array of partial server integrations. - /// Whether the connection is verified. - /// Whether friend sync is enabled for this connection. - /// Whether activities related to this connection will be shown in presence updates. - /// Visibility of this connection. - [JsonConstructor] - public Connection(string id, string name, string type, Optional revoked, Optional integrations, bool verified, bool friendSync, bool showActivity, VisibilityType visibility) - { - Id = id; - Name = name; - Type = type; - Revoked = revoked; - Integrations = integrations; - Verified = verified; - FriendSync = friendSync; - ShowActivity = showActivity; - Visibility = visibility; - } - - /// - /// Id of the connection account. - /// - [JsonPropertyName("id")] - public string Id { get; } - - /// - /// The username of the connection account. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// The service of the connection (twitch, youtube). - /// - [JsonPropertyName("type")] - public string Type { get; } - - /// - /// Whether the connection is revoked. - /// - [JsonPropertyName("revoked")] - public Optional Revoked { get; } - - /// - /// An array of partial server integrations. - /// - [JsonPropertyName("integrations")] - public Optional Integrations { get; } - - /// - /// Whether the connection is verified. - /// - [JsonPropertyName("verified")] - public bool Verified { get; } - - /// - /// Whether friend sync is enabled for this connection. - /// - [JsonPropertyName("friend_sync")] - public bool FriendSync { get; } - - /// - /// Whether activities related to this connection will be shown in presence updates. - /// - [JsonPropertyName("show_activity")] - public bool ShowActivity { get; } - - /// - /// Visibility of this connection. - /// - [JsonPropertyName("visibility")] - public VisibilityType Visibility { get; } - } -} diff --git a/src/Models/User/PremiumType.cs b/src/Models/User/PremiumType.cs deleted file mode 100644 index 7913adbf7..000000000 --- a/src/Models/User/PremiumType.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace Discord.Net.Models -{ - /// - /// Represents the premium type. - /// - public enum PremiumType - { - /// - /// User does not have Nitro. - /// - None = 0, - - /// - /// User has Nitro Classic. - /// - NitroClassic = 1, - - /// - /// User has Nitro. - /// - Nitro = 2, - } -} diff --git a/src/Models/User/User.cs b/src/Models/User/User.cs deleted file mode 100644 index 857d99b40..000000000 --- a/src/Models/User/User.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a user object. - /// - public record User - { - /// - /// Creates a with the provided parameters. - /// - /// The user's id. - /// The user's username, not unique across the platform. - /// The user's 4-digit discord-tag. - /// The user's avatar hash. - /// Whether the user belongs to an OAuth2 application. - /// Whether the user is an Official Discord System user (part of the urgent message system). - /// Whether the user has two factor enabled on their account. - /// The user's chosen language option. - /// Whether the email on this account has been verified. - /// The user's email. - /// The flags on a user's account. - /// The type of Nitro subscription on a user's account. - /// The public flags on a user's account. - [JsonConstructor] - public User(Snowflake id, string username, string discriminator, string? avatar, Optional bot, Optional system, Optional mfaEnabled, Optional locale, Optional verified, Optional email, Optional flags, Optional premiumType, Optional publicFlags) - { - Id = id; - Username = username; - Discriminator = discriminator; - Avatar = avatar; - Bot = bot; - System = system; - MfaEnabled = mfaEnabled; - Locale = locale; - Verified = verified; - Email = email; - Flags = flags; - PremiumType = premiumType; - PublicFlags = publicFlags; - } - - /// - /// The user's id. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// The user's username, not unique across the platform. - /// - [JsonPropertyName("username")] - public string Username { get; } - - /// - /// The user's 4-digit discord-tag. - /// - [JsonPropertyName("discriminator")] - public string Discriminator { get; } - - /// - /// The user's avatar hash. - /// - [JsonPropertyName("avatar")] - public string? Avatar { get; } - - /// - /// Whether the user belongs to an OAuth2 application. - /// - [JsonPropertyName("bot")] - public Optional Bot { get; } - - /// - /// Whether the user is an Official Discord System user (part of the urgent message system). - /// - [JsonPropertyName("system")] - public Optional System { get; } - - /// - /// Whether the user has two factor enabled on their account. - /// - [JsonPropertyName("mfa_enabled")] - public Optional MfaEnabled { get; } - - /// - /// The user's chosen language option. - /// - [JsonPropertyName("locale")] - public Optional Locale { get; } - - /// - /// Whether the email on this account has been verified. - /// - [JsonPropertyName("verified")] - public Optional Verified { get; } - - /// - /// The user's email. - /// - [JsonPropertyName("email")] - public Optional Email { get; } - - /// - /// The flags on a user's account. - /// - [JsonPropertyName("flags")] - public Optional Flags { get; } - - /// - /// The type of Nitro subscription on a user's account. - /// - [JsonPropertyName("premium_type")] - public Optional PremiumType { get; } - - /// - /// The public flags on a user's account. - /// - [JsonPropertyName("public_flags")] - public Optional PublicFlags { get; } - } -} diff --git a/src/Models/User/VisibilityType.cs b/src/Models/User/VisibilityType.cs deleted file mode 100644 index 77cb5a44b..000000000 --- a/src/Models/User/VisibilityType.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Discord.Net.Models -{ - /// - /// Represents the visibility type. - /// - public enum VisibilityType - { - /// - /// Invisible to everyone except the user themselves. - /// - None = 0, - - /// - /// Visible to everyone. - /// - Everyone = 1, - } -} diff --git a/src/Models/Users/Connection.cs b/src/Models/Users/Connection.cs new file mode 100644 index 000000000..2433d4fe1 --- /dev/null +++ b/src/Models/Users/Connection.cs @@ -0,0 +1,67 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord connection object. + /// + /// + /// + /// + public record Connection + { + /// + /// Id of the account. + /// + [JsonPropertyName("id")] + public string? Id { get; } // Required property candidate + + /// + /// The username of the account. + /// + [JsonPropertyName("name")] + public string? Name { get; } // Required property candidate + + /// + /// The service of the (twitch, youtube). + /// + [JsonPropertyName("type")] + public string? Type { get; } // Required property candidate + + /// + /// Whether the is revoked. + /// + [JsonPropertyName("revoked")] + public Optional Revoked { get; } + + /// + /// An array of partial server . + /// + [JsonPropertyName("integrations")] + public Optional Integrations { get; } + + /// + /// Whether the is verified. + /// + [JsonPropertyName("verified")] + public bool Verified { get; } + + /// + /// Whether friend sync is enabled for this . + /// + [JsonPropertyName("friend_sync")] + public bool FriendSync { get; } + + /// + /// Whether activities related to this will be shown in presence updates. + /// + [JsonPropertyName("show_activity")] + public bool ShowActivity { get; } + + /// + /// Visibility of this . + /// + [JsonPropertyName("visibility")] + public VisibilityType Visibility { get; } + } +} diff --git a/src/Models/Users/PremiumType.cs b/src/Models/Users/PremiumType.cs new file mode 100644 index 000000000..cb4e6dc11 --- /dev/null +++ b/src/Models/Users/PremiumType.cs @@ -0,0 +1,26 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the premium type for a . + /// + /// + /// + /// + public enum PremiumType + { + /// + /// User does not have Nitro. + /// + None = 0, + + /// + /// User has Nitro Classic. + /// + NitroClassic = 1, + + /// + /// User has Nitro. + /// + Nitro = 2, + } +} diff --git a/src/Models/Users/User.cs b/src/Models/Users/User.cs new file mode 100644 index 000000000..7f6246e98 --- /dev/null +++ b/src/Models/Users/User.cs @@ -0,0 +1,91 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord user object. + /// + /// + /// + /// + public record User + { + /// + /// The 's id. + /// + [JsonPropertyName("id")] + public Snowflake Id { get; init; } + + /// + /// The 's username, not unique across the platform. + /// + [JsonPropertyName("username")] + public string? Username { get; init; } // Required property candidate + + /// + /// The 's 4-digit discord-tag. + /// + [JsonPropertyName("discriminator")] + public string? Discriminator { get; init; } // Required property candidate + + /// + /// The 's avatar hash. + /// + [JsonPropertyName("avatar")] + public string? Avatar { get; init; } + + /// + /// Whether the belongs to an OAuth2 . + /// + [JsonPropertyName("bot")] + public Optional Bot { get; init; } + + /// + /// Whether the is an Official Discord System user (part of the urgent message system). + /// + [JsonPropertyName("system")] + public Optional System { get; init; } + + /// + /// Whether the has two factor enabled on their account. + /// + [JsonPropertyName("mfa_enabled")] + public Optional MfaEnabled { get; init; } + + /// + /// The 's chosen language option. + /// + [JsonPropertyName("locale")] + public Optional Locale { get; init; } + + /// + /// Whether the email on this account has been verified. + /// + [JsonPropertyName("verified")] + public Optional Verified { get; init; } + + /// + /// The 's email. + /// + [JsonPropertyName("email")] + public Optional Email { get; init; } + + /// + /// The flags on a 's account. + /// + [JsonPropertyName("flags")] + public Optional Flags { get; init; } + + /// + /// The type of Nitro subscription on a 's account. + /// + [JsonPropertyName("premium_type")] + public Optional PremiumType { get; init; } + + /// + /// The public flags on a 's account. + /// + [JsonPropertyName("public_flags")] + public Optional PublicFlags { get; init; } + } +} diff --git a/src/Models/User/UserFlags.cs b/src/Models/Users/UserFlags.cs similarity index 60% rename from src/Models/User/UserFlags.cs rename to src/Models/Users/UserFlags.cs index f021b5459..c4c772d94 100644 --- a/src/Models/User/UserFlags.cs +++ b/src/Models/Users/UserFlags.cs @@ -3,78 +3,81 @@ using System; namespace Discord.Net.Models { /// - /// Represents the user flags. + /// Declares a flag enum which represents the user flags for a . /// + /// + /// + /// [Flags] public enum UserFlags { /// - /// Default flag. + /// Default flag. /// None = 0, /// - /// User is a Discord Employee. + /// User is a Discord Employee. /// DiscordEmployee = 1 << 0, /// - /// User is the owner of a partnered server. + /// User is the owner of a partnered server. /// PartneredServerOwner = 1 << 1, /// - /// User participated in HypeSquad events. + /// User participated in HypeSquad events. /// HypeSquadEvents = 1 << 2, /// - /// User is a level 1 Bug Hunter. + /// User is a level 1 Bug Hunter. /// BugHunterLevel1 = 1 << 3, /// - /// User is part of House Bravery. + /// User is part of House Bravery. /// HouseBravery = 1 << 6, /// - /// User is part of House Brilliance. + /// User is part of House Brilliance. /// HouseBrilliance = 1 << 7, /// - /// User is part of House Balance. + /// User is part of House Balance. /// HouseBalance = 1 << 8, /// - /// User is an early supporter. + /// User is an early supporter. /// EarlySupporter = 1 << 9, /// - /// User is part of a team. + /// User is part of a team. /// TeamUser = 1 << 10, /// - /// User is a level 2 Bug Hunter. + /// User is a level 2 Bug Hunter. /// BugHunterLevel2 = 1 << 14, /// - /// User is a verified bot. + /// User is a verified bot. /// VerifiedBot = 1 << 16, /// - /// User is an early verified bot developer. + /// User is an early verified bot developer. /// EarlyVerifiedBotDeveloper = 1 << 17, /// - /// User is a Discord certified moderator. + /// User is a Discord certified moderator. /// DiscordCertifiedModerator = 1 << 18, } diff --git a/src/Models/Users/UserMention.cs b/src/Models/Users/UserMention.cs new file mode 100644 index 000000000..14413b17a --- /dev/null +++ b/src/Models/Users/UserMention.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord user mention, that is a with + /// an additional partial . + /// + public record UserMention : User + { + /// + /// Additional partial member field. + /// + [JsonPropertyName("member")] + public Optional Member { get; init; } + } +} diff --git a/src/Models/Users/UserStatus.cs b/src/Models/Users/UserStatus.cs new file mode 100644 index 000000000..2e4bafaef --- /dev/null +++ b/src/Models/Users/UserStatus.cs @@ -0,0 +1,28 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the status for an . + /// + public enum UserStatus + { + /// + /// is offline. + /// + Offline, + + /// + /// is online. + /// + Online, + + /// + /// is idle. + /// + Idle, + + /// + /// is on do not disturb. + /// + DoNotDisturb, + } +} diff --git a/src/Models/Users/VisibilityType.cs b/src/Models/Users/VisibilityType.cs new file mode 100644 index 000000000..208da6345 --- /dev/null +++ b/src/Models/Users/VisibilityType.cs @@ -0,0 +1,21 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the visibility type for a . + /// + /// + /// + /// + public enum VisibilityType + { + /// + /// Invisible to everyone except the user themselves. + /// + None = 0, + + /// + /// Visible to everyone. + /// + Everyone = 1, + } +} diff --git a/src/Models/Voice/VoiceRegion.cs b/src/Models/Voice/VoiceRegion.cs deleted file mode 100644 index bd01a62c8..000000000 --- a/src/Models/Voice/VoiceRegion.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a voice region object. - /// - public record VoiceRegion - { - /// - /// Creates a with the provided parameters. - /// - /// Unique ID for the region. - /// Name of the region. - /// True if this is a vip-only server. - /// True for a single server that is closest to the current user's client. - /// Whether this is a deprecated voice region (avoid switching to these). - /// Whether this is a custom voice region (used for events/etc). - [JsonConstructor] - public VoiceRegion(string id, string name, bool vip, bool optimal, bool deprecated, bool custom) - { - Id = id; - Name = name; - Vip = vip; - Optimal = optimal; - Deprecated = deprecated; - Custom = custom; - } - - /// - /// Unique ID for the region. - /// - [JsonPropertyName("id")] - public string Id { get; } - - /// - /// Name of the region. - /// - [JsonPropertyName("name")] - public string Name { get; } - - /// - /// True if this is a vip-only server. - /// - [JsonPropertyName("vip")] - public bool Vip { get; } - - /// - /// True for a single server that is closest to the current user's client. - /// - [JsonPropertyName("optimal")] - public bool Optimal { get; } - - /// - /// Whether this is a deprecated voice region (avoid switching to these). - /// - [JsonPropertyName("deprecated")] - public bool Deprecated { get; } - - /// - /// Whether this is a custom voice region (used for events/etc). - /// - [JsonPropertyName("custom")] - public bool Custom { get; } - } -} diff --git a/src/Models/Voice/VoiceState.cs b/src/Models/Voice/VoiceState.cs deleted file mode 100644 index fbea6637a..000000000 --- a/src/Models/Voice/VoiceState.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a voice state object. - /// - public record VoiceState - { - /// - /// Creates a with the provided parameters. - /// - /// The guild id this voice state is for. - /// The channel id this user is connected to. - /// The user id this voice state is for. - /// The guild member this voice state is for. - /// The session id for this voice state. - /// Whether this user is deafened by the server. - /// Whether this user is muted by the server. - /// Whether this user is locally deafened. - /// Whether this user is locally muted. - /// Whether this user is streaming using "Go Live". - /// Whether this user's camera is enabled. - /// Whether this user is muted by the current user. - /// The time at which the user requested to speak. - [JsonConstructor] - public VoiceState(Optional guildId, Snowflake? channelId, Snowflake userId, Optional member, string sessionId, bool deaf, bool mute, bool selfDeaf, bool selfMute, Optional selfStream, bool selfVideo, bool suppress, DateTimeOffset? requestToSpeakTimestamp) - { - GuildId = guildId; - ChannelId = channelId; - UserId = userId; - Member = member; - SessionId = sessionId; - Deaf = deaf; - Mute = mute; - SelfDeaf = selfDeaf; - SelfMute = selfMute; - SelfStream = selfStream; - SelfVideo = selfVideo; - Suppress = suppress; - RequestToSpeakTimestamp = requestToSpeakTimestamp; - } - - /// - /// The guild id this voice state is for. - /// - [JsonPropertyName("guild_id")] - public Optional GuildId { get; } - - /// - /// The channel id this user is connected to. - /// - [JsonPropertyName("channel_id")] - public Snowflake? ChannelId { get; } - - /// - /// The user id this voice state is for. - /// - [JsonPropertyName("user_id")] - public Snowflake UserId { get; } - - /// - /// The guild member this voice state is for. - /// - [JsonPropertyName("member")] - public Optional Member { get; } - - /// - /// The session id for this voice state. - /// - [JsonPropertyName("session_id")] - public string SessionId { get; } - - /// - /// Whether this user is deafened by the server. - /// - [JsonPropertyName("deaf")] - public bool Deaf { get; } - - /// - /// Whether this user is muted by the server. - /// - [JsonPropertyName("mute")] - public bool Mute { get; } - - /// - /// Whether this user is locally deafened. - /// - [JsonPropertyName("self_deaf")] - public bool SelfDeaf { get; } - - /// - /// Whether this user is locally muted. - /// - [JsonPropertyName("self_mute")] - public bool SelfMute { get; } - - /// - /// Whether this user is streaming using "Go Live". - /// - [JsonPropertyName("self_stream")] - public Optional SelfStream { get; } - - /// - /// Whether this user's camera is enabled. - /// - [JsonPropertyName("self_video")] - public bool SelfVideo { get; } - - /// - /// Whether this user is muted by the current user. - /// - [JsonPropertyName("suppress")] - public bool Suppress { get; } - - /// - /// The time at which the user requested to speak. - /// - [JsonPropertyName("request_to_speak_timestamp")] - public DateTimeOffset? RequestToSpeakTimestamp { get; } - } -} diff --git a/src/Models/Voices/VoiceRegion.cs b/src/Models/Voices/VoiceRegion.cs new file mode 100644 index 000000000..fda8eeb27 --- /dev/null +++ b/src/Models/Voices/VoiceRegion.cs @@ -0,0 +1,49 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord voice region object. + /// + /// + /// + /// + public record VoiceRegion + { + /// + /// Unique ID for the . + /// + [JsonPropertyName("id")] + public string? Id { get; init; } // Required property candidate + + /// + /// Name of the . + /// + [JsonPropertyName("name")] + public string? Name { get; init; } // Required property candidate + + /// + /// True if this is a vip-only server. + /// + [JsonPropertyName("vip")] + public bool Vip { get; init; } + + /// + /// True for a single server that is closest to the current user's client. + /// + [JsonPropertyName("optimal")] + public bool Optimal { get; init; } + + /// + /// Whether this is a deprecated (avoid switching to these). + /// + [JsonPropertyName("deprecated")] + public bool Deprecated { get; init; } + + /// + /// Whether this is a custom (used for events, etc). + /// + [JsonPropertyName("custom")] + public bool Custom { get; init; } + } +} diff --git a/src/Models/Voices/VoiceState.cs b/src/Models/Voices/VoiceState.cs new file mode 100644 index 000000000..92a9b8bf2 --- /dev/null +++ b/src/Models/Voices/VoiceState.cs @@ -0,0 +1,92 @@ +using System; +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord voice state object. + /// + /// + /// + /// + public record VoiceState + { + /// + /// The id this is for. + /// + [JsonPropertyName("guild_id")] + public Optional GuildId { get; init; } + + /// + /// The id this is connected to. + /// + [JsonPropertyName("channel_id")] + public Snowflake? ChannelId { get; init; } + + /// + /// The id this is for. + /// + [JsonPropertyName("user_id")] + public Snowflake UserId { get; init; } + + /// + /// The this is for. + /// + [JsonPropertyName("member")] + public Optional Member { get; init; } + + /// + /// The session id for this . + /// + [JsonPropertyName("session_id")] + public string? SessionId { get; init; } // Required property candidate + + /// + /// Whether this is deafened by the server. + /// + [JsonPropertyName("deaf")] + public bool Deaf { get; init; } + + /// + /// Whether this is muted by the server. + /// + [JsonPropertyName("mute")] + public bool Mute { get; init; } + + /// + /// Whether this is locally deafened. + /// + [JsonPropertyName("self_deaf")] + public bool SelfDeaf { get; init; } + + /// + /// Whether this is locally muted. + /// + [JsonPropertyName("self_mute")] + public bool SelfMute { get; init; } + + /// + /// Whether this is streaming using "Go Live". + /// + [JsonPropertyName("self_stream")] + public Optional SelfStream { get; init; } + + /// + /// Whether this 's camera is enabled. + /// + [JsonPropertyName("self_video")] + public bool SelfVideo { get; init; } + + /// + /// Whether this is muted by the current . + /// + [JsonPropertyName("suppress")] + public bool Suppress { get; init; } + + /// + /// The time at which the requested to speak. + /// + [JsonPropertyName("request_to_speak_timestamp")] + public DateTimeOffset? RequestToSpeakTimestamp { get; init; } + } +} diff --git a/src/Models/Webhook/Webhook.cs b/src/Models/Webhook/Webhook.cs deleted file mode 100644 index b202bcdb5..000000000 --- a/src/Models/Webhook/Webhook.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Discord.Net.Models -{ - /// - /// Represents a webhook object. - /// - public record Webhook - { - /// - /// Creates a with the provided parameters. - /// - /// The id of the webhook. - /// The type of the webhook. - /// The guild id this webhook is for, if any. - /// The channel id this webhook is for, if any. - /// The user this webhook was created by (not returned when getting a webhook with its token). - /// The default name of the webhook. - /// The default user avatar hash of the webhook. - /// The secure token of the webhook (returned for Incoming Webhooks). - /// The bot/OAuth2 application that created this webhook. - /// The guild of the channel that this webhook is following (returned for Channel Follower Webhooks). - /// The channel that this webhook is following (returned for Channel Follower Webhooks). - /// The url used for executing the webhook (returned by the webhooks OAuth2 flow). - [JsonConstructor] - public Webhook(Snowflake id, WebhookType type, Optional guildId, Snowflake? channelId, Optional user, string? name, string? avatar, Optional token, Snowflake? applicationId, Optional sourceGuild, Optional sourceChannel, Optional url) - { - Id = id; - Type = type; - GuildId = guildId; - ChannelId = channelId; - User = user; - Name = name; - Avatar = avatar; - Token = token; - ApplicationId = applicationId; - SourceGuild = sourceGuild; - SourceChannel = sourceChannel; - Url = url; - } - - /// - /// The id of the webhook. - /// - [JsonPropertyName("id")] - public Snowflake Id { get; } - - /// - /// The type of the webhook. - /// - [JsonPropertyName("type")] - public WebhookType Type { get; } - - /// - /// The guild id this webhook is for, if any. - /// - [JsonPropertyName("guild_id")] - public Optional GuildId { get; } - - /// - /// The channel id this webhook is for, if any. - /// - [JsonPropertyName("channel_id")] - public Snowflake? ChannelId { get; } - - /// - /// The user this webhook was created by (not returned when getting a webhook with its token). - /// - [JsonPropertyName("user")] - public Optional User { get; } - - /// - /// The default name of the webhook. - /// - [JsonPropertyName("name")] - public string? Name { get; } - - /// - /// The default user avatar hash of the webhook. - /// - [JsonPropertyName("avatar")] - public string? Avatar { get; } - - /// - /// The secure token of the webhook (returned for Incoming Webhooks). - /// - [JsonPropertyName("token")] - public Optional Token { get; } - - /// - /// The bot/OAuth2 application that created this webhook. - /// - [JsonPropertyName("application_id")] - public Snowflake? ApplicationId { get; } - - /// - /// The guild of the channel that this webhook is following (returned for Channel Follower Webhooks). - /// - [JsonPropertyName("source_guild")] - public Optional SourceGuild { get; } - - /// - /// The channel that this webhook is following (returned for Channel Follower Webhooks). - /// - [JsonPropertyName("source_channel")] - public Optional SourceChannel { get; } - - /// - /// The url used for executing the webhook (returned by the webhooks OAuth2 flow). - /// - [JsonPropertyName("url")] - public Optional Url { get; } - } -} diff --git a/src/Models/Webhook/WebhookType.cs b/src/Models/Webhook/WebhookType.cs deleted file mode 100644 index d66ed6af1..000000000 --- a/src/Models/Webhook/WebhookType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Discord.Net.Models -{ - /// - /// Represents the webhook type. - /// - public enum WebhookType - { - /// - /// Incoming Webhooks can post messages to channels with a generated token. - /// - Incoming = 1, - - /// - /// Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels. - /// - ChannelFollower = 2, - - /// - /// Application webhooks are webhooks used with Interactions. - /// - Application = 3, - } -} diff --git a/src/Models/Webhooks/Webhook.cs b/src/Models/Webhooks/Webhook.cs new file mode 100644 index 000000000..a3267abd3 --- /dev/null +++ b/src/Models/Webhooks/Webhook.cs @@ -0,0 +1,88 @@ +using System.Text.Json.Serialization; + +namespace Discord.Net.Models +{ + /// + /// Represents a discord webhook object. + /// + /// + /// + /// + public record Webhook + { + /// + /// The id of the . + /// + [JsonPropertyName("id")] + public Snowflake Id { get; } + + /// + /// The type of the . + /// + [JsonPropertyName("type")] + public WebhookType Type { get; } + + /// + /// The id this is for, if any. + /// + [JsonPropertyName("guild_id")] + public Optional GuildId { get; } + + /// + /// The id this is for, if any. + /// + [JsonPropertyName("channel_id")] + public Snowflake? ChannelId { get; } + + /// + /// The this was created by (not + /// returned when getting a with its token). + /// + [JsonPropertyName("user")] + public Optional User { get; } + + /// + /// The default name of the . + /// + [JsonPropertyName("name")] + public string? Name { get; } + + /// + /// The default user avatar hash of the . + /// + [JsonPropertyName("avatar")] + public string? Avatar { get; } + + /// + /// The secure token of the (returned for Incoming Webhooks). + /// + [JsonPropertyName("token")] + public Optional Token { get; } + + /// + /// The bot/OAuth2 that created this . + /// + [JsonPropertyName("application_id")] + public Snowflake? ApplicationId { get; } + + /// + /// The of the that this + /// is following (returned for Channel Follower Webhooks). + /// + [JsonPropertyName("source_guild")] + public Optional SourceGuild { get; } + + /// + /// The that this is following + /// (returned for Channel Follower Webhooks). + /// + [JsonPropertyName("source_channel")] + public Optional SourceChannel { get; } + + /// + /// The url used for executing the (returned by the webhooks OAuth2 flow). + /// + [JsonPropertyName("url")] + public Optional Url { get; } + } +} diff --git a/src/Models/Webhooks/WebhookType.cs b/src/Models/Webhooks/WebhookType.cs new file mode 100644 index 000000000..eda59a88e --- /dev/null +++ b/src/Models/Webhooks/WebhookType.cs @@ -0,0 +1,28 @@ +namespace Discord.Net.Models +{ + /// + /// Declares an enum which represents the webhook type for a . + /// + /// + /// + /// + public enum WebhookType + { + /// + /// Incoming s can post s to + /// s with a generated token. + /// + Incoming = 1, + + /// + /// Channel Follower s are internal webhooks used with + /// Channel Following to post new s into s. + /// + ChannelFollower = 2, + + /// + /// s are webhooks used with Interactions. + /// + Application = 3, + } +} diff --git a/src/Rest/Discord.Net.Rest.csproj b/src/Rest/Discord.Net.Rest.csproj new file mode 100644 index 000000000..f69acc033 --- /dev/null +++ b/src/Rest/Discord.Net.Rest.csproj @@ -0,0 +1,16 @@ + + + + net5.0 + + + $(Description) + Rest components to enable sending requests to the discord rest api. + + + + + + + + diff --git a/src/Rest/DiscordRestClient.cs b/src/Rest/DiscordRestClient.cs new file mode 100644 index 000000000..ab5502cb6 --- /dev/null +++ b/src/Rest/DiscordRestClient.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Discord.Net.Models; +using Discord.Net.Rest; + +namespace Discord.Net +{ + /// + /// TBD + /// + public class DiscordRestClient : IDiscordRestApi + { + private readonly IDiscordRestApi _api; + + /// + /// TBD + /// + /// + internal DiscordRestClient(IDiscordRestApi api) + { + _api = api; + } + + #region Audit Log + + /// + public Task GetGuildAuditLogAsync(Snowflake guildId, GetGuildAuditLogParams? args = null, CancellationToken cancellationToken = default) + { + Preconditions.NotZero(guildId, nameof(guildId)); + if (args == null) + args = new(); + else + args.Validate(); + return _api.GetGuildAuditLogAsync(guildId, args, cancellationToken); + } + + #endregion + } +} diff --git a/src/Rest/Net/IDiscordRestApi.cs b/src/Rest/Net/IDiscordRestApi.cs new file mode 100644 index 000000000..dc631785f --- /dev/null +++ b/src/Rest/Net/IDiscordRestApi.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + internal interface IDiscordRestApi + { + #region Audit Log + + /// + /// Returns an audit log object for the guild. + /// + /// + /// Requires the permission. + /// + /// + /// The guild identifier. + /// + /// + /// Parameters to include in the request. + /// + /// + /// Cancellation token for the request. + /// + Task GetGuildAuditLogAsync(Snowflake guildId, GetGuildAuditLogParams? args = null, CancellationToken cancellationToken = default); + + #endregion + } +} diff --git a/src/Rest/Net/Requests/AuditLog/GetGuildAuditLogParams.cs b/src/Rest/Net/Requests/AuditLog/GetGuildAuditLogParams.cs new file mode 100644 index 000000000..b8a3e325d --- /dev/null +++ b/src/Rest/Net/Requests/AuditLog/GetGuildAuditLogParams.cs @@ -0,0 +1,43 @@ +using Discord.Net.Models; + +namespace Discord.Net.Rest +{ + /// + /// Parameters to add to the request. + /// + public record GetGuildAuditLogParams + { + /// + /// Filter the log for actions made by a user. + /// + public Optional UserId { get; set; } + + /// + /// Filter the log by type of audit log event. + /// + public Optional ActionType { get; set; } + + /// + /// Filter the log before a certain entry id. + /// + public Optional Before { get; set; } + + /// + /// How many entries are returned. + /// + /// + /// Default: 50. Acceptable range: 1-100, inclusive. + /// + public Optional Limit { get; set; } + + /// + /// Validates the data. + /// + public void Validate() + { + Preconditions.NotZero(UserId, nameof(UserId)); + Preconditions.AtLeast(Limit, AuditLog.MinimumGetEntryAmount, nameof(Limit)); + Preconditions.AtMost(Limit, AuditLog.MaximumGetEntryAmount, nameof(Limit)); + } + } +} diff --git a/src/Rest/Preconditions.cs b/src/Rest/Preconditions.cs new file mode 100644 index 000000000..b6267663d --- /dev/null +++ b/src/Rest/Preconditions.cs @@ -0,0 +1,562 @@ +using System; + +namespace Discord.Net.Rest +{ + internal static class Preconditions + { + // Objects + + public static void NotNull(T obj, string name, string? msg = null) where T : class { if (obj == null) throw CreateNotNullException(name, msg); } + public static void NotNull(Optional obj, string name, string? msg = null) where T : class { if (obj.IsSpecified && obj.Value == null) throw CreateNotNullException(name, msg); } + + private static ArgumentNullException CreateNotNullException(string name, string? msg) + { + if (msg == null) + return new ArgumentNullException(name); + else + return new ArgumentNullException(name, msg); + } + + // Optionals + + public static void Exclusive(Optional[] objs, string[] names, string? msg = null) + { + int count = 0; + for (int i = 0; i < objs.Length; i++) + { + if (objs[i].IsSpecified) + count++; + } + if (count > 1) + { + if (msg != null) + throw new ArgumentException(msg); + else + throw new ArgumentException($"[{string.Join(", ", names)}] are exclusive parameters and may not be used together"); + } + } + + // Strings + + public static void NotEmpty(string obj, string name, string? msg = null) { if (obj != null && obj.Length == 0) throw CreateNotEmptyException(name, msg); } + public static void NotEmpty(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value != null && obj.Value.Length == 0) throw CreateNotEmptyException(name, msg); } + public static void NotNullOrEmpty(string obj, string name, string? msg = null) + { + if (obj == null) + throw CreateNotNullException(name, msg); + if (obj.Length == 0) + throw CreateNotEmptyException(name, msg); + } + public static void NotNullOrEmpty(Optional obj, string name, string? msg = null) + { + if (obj.IsSpecified) + { + if (obj.Value == null) + throw CreateNotNullException(name, msg); + if (obj.Value.Length == 0) + throw CreateNotEmptyException(name, msg); + } + } + public static void NotNullOrWhitespace(string obj, string name, string? msg = null) + { + if (obj == null) + throw CreateNotNullException(name, msg); + if (obj.Trim().Length == 0) + throw CreateNotEmptyException(name, msg); + } + public static void NotNullOrWhitespace(Optional obj, string name, string? msg = null) + { + if (obj.IsSpecified) + { + if (obj.Value == null) + throw CreateNotNullException(name, msg); + if (obj.Value.Trim().Length == 0) + throw CreateNotEmptyException(name, msg); + } + } + + public static void LengthAtLeast(string obj, int value, string name, string? msg = null) + { + if (obj?.Length < value) + { + if (msg == null) + throw new ArgumentException($"Length must be at least {value}", name); + else + throw new ArgumentException(msg, name); + } + } + public static void LengthAtMost(string obj, int value, string name, string? msg = null) + { + if (obj?.Length > value) + { + if (msg == null) + throw new ArgumentException($"Length must be at most {value}", name); + else + throw new ArgumentException(msg, name); + } + } + public static void LengthGreaterThan(string obj, int value, string name, string? msg = null) + { + if (obj?.Length <= value) + { + if (msg == null) + throw new ArgumentException($"Length must be greater than {value}", name); + else + throw new ArgumentException(msg, name); + } + } + public static void LengthLessThan(string obj, int value, string name, string? msg = null) + { + if (obj?.Length >= value) + { + if (msg == null) + throw new ArgumentException($"Length must be less than {value}", name); + else + throw new ArgumentException(msg, name); + } + } + public static void LengthAtLeast(Optional obj, int value, string name, string? msg = null) + { + if (!obj.IsSpecified) + return; + LengthAtLeast(obj.Value, value, name, msg); + } + public static void LengthAtMost(Optional obj, int value, string name, string? msg = null) + { + if (!obj.IsSpecified) + return; + LengthAtMost(obj.Value, value, name, msg); + } + public static void LengthGreaterThan(Optional obj, int value, string name, string? msg = null) + { + if (!obj.IsSpecified) + return; + LengthGreaterThan(obj.Value, value, name, msg); + } + public static void LengthLessThan(Optional obj, int value, string name, string? msg = null) + { + if (!obj.IsSpecified) + return; + LengthLessThan(obj.Value, value, name, msg); + } + + private static ArgumentException CreateNotEmptyException(string name, string? msg) + { + if (msg == null) + return new ArgumentException("Argument cannot be blank", name); + else + return new ArgumentException(name, msg); + } + + // Numerics + + public static void NotZero(sbyte obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(byte obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(short obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(ushort obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(int obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(uint obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(long obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(ulong obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(sbyte? obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(byte? obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(short? obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(ushort? obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(int? obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(uint? obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(long? obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(ulong? obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + + private static ArgumentException CreateNotZeroException(string name, string? msg) + { + if (msg == null) + return new ArgumentException($"Value must be non-zero", name); + else + return new ArgumentException(msg, name); + } + + public static void Positive(sbyte obj, string name, string? msg = null) { if (obj <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(short obj, string name, string? msg = null) { if (obj <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(int obj, string name, string? msg = null) { if (obj <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(long obj, string name, string? msg = null) { if (obj <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(sbyte? obj, string name, string? msg = null) { if (obj <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(short? obj, string name, string? msg = null) { if (obj <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(int? obj, string name, string? msg = null) { if (obj <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(long? obj, string name, string? msg = null) { if (obj <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= 0) throw CreatePositiveException(name, msg); } + public static void Positive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= 0) throw CreatePositiveException(name, msg); } + + private static ArgumentException CreatePositiveException(string name, string? msg) + { + if (msg == null) + return new ArgumentException($"Value must be positive", name); + else + return new ArgumentException(msg, name); + } + + public static void Negative(sbyte obj, string name, string? msg = null) { if (obj >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(short obj, string name, string? msg = null) { if (obj >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(int obj, string name, string? msg = null) { if (obj >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(long obj, string name, string? msg = null) { if (obj >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(sbyte? obj, string name, string? msg = null) { if (obj >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(short? obj, string name, string? msg = null) { if (obj >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(int? obj, string name, string? msg = null) { if (obj >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(long? obj, string name, string? msg = null) { if (obj >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= 0) throw CreateNegativeException(name, msg); } + public static void Negative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= 0) throw CreateNegativeException(name, msg); } + + private static ArgumentException CreateNegativeException(string name, string? msg) + { + if (msg == null) + return new ArgumentException($"Value must be negative", name); + else + return new ArgumentException(msg, name); + } + + public static void NotNegative(sbyte obj, string name, string? msg = null) { if (obj < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(short obj, string name, string? msg = null) { if (obj < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(int obj, string name, string? msg = null) { if (obj < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(long obj, string name, string? msg = null) { if (obj < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(sbyte? obj, string name, string? msg = null) { if (obj < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(short? obj, string name, string? msg = null) { if (obj < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(int? obj, string name, string? msg = null) { if (obj < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(long? obj, string name, string? msg = null) { if (obj < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < 0) throw CreateNotNegativeException(name, msg); } + public static void NotNegative(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < 0) throw CreateNotNegativeException(name, msg); } + + private static ArgumentException CreateNotNegativeException(string name, string? msg) + { + if (msg == null) + return new ArgumentException($"Value must be non-negative", name); + else + return new ArgumentException(msg, name); + } + + public static void NotPositive(sbyte obj, string name, string? msg = null) { if (obj > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(short obj, string name, string? msg = null) { if (obj > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(int obj, string name, string? msg = null) { if (obj > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(long obj, string name, string? msg = null) { if (obj > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(sbyte? obj, string name, string? msg = null) { if (obj > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(short? obj, string name, string? msg = null) { if (obj > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(int? obj, string name, string? msg = null) { if (obj > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(long? obj, string name, string? msg = null) { if (obj > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > 0) throw CreateNotPositiveException(name, msg); } + public static void NotPositive(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > 0) throw CreateNotPositiveException(name, msg); } + + private static ArgumentException CreateNotPositiveException(string name, string? msg) + { + if (msg == null) + return new ArgumentException($"Value must be non-positive", name); + else + return new ArgumentException(msg, name); + } + + public static void NotEqual(sbyte obj, sbyte value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(byte obj, byte value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(short obj, short value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(ushort obj, ushort value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(int obj, int value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(uint obj, uint value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(long obj, long value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(ulong obj, ulong value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(sbyte? obj, sbyte value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(byte? obj, byte value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(short? obj, short value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(ushort? obj, ushort value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(int? obj, int value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(uint? obj, uint value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(long? obj, long value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(ulong? obj, ulong value, string name, string? msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + public static void NotEqual(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == value) throw CreateNotEqualException(name, msg, value); } + + private static ArgumentException CreateNotEqualException(string name, string? msg, T value) + { + if (msg == null) + return new ArgumentException($"Value may not be equal to {value}", name); + else + return new ArgumentException(msg, name); + } + + public static void AtLeast(sbyte obj, sbyte value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(byte obj, byte value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(short obj, short value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(ushort obj, ushort value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(int obj, int value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(uint obj, uint value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(long obj, long value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(ulong obj, ulong value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(sbyte? obj, sbyte value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(byte? obj, byte value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(short? obj, short value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(ushort? obj, ushort value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(int? obj, int value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(uint? obj, uint value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(long? obj, long value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(ulong? obj, ulong value, string name, string? msg = null) { if (obj < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + public static void AtLeast(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value < value) throw CreateAtLeastException(name, msg, value); } + + private static ArgumentException CreateAtLeastException(string name, string? msg, T value) + { + if (msg == null) + return new ArgumentException($"Value must be at least {value}", name); + else + return new ArgumentException(msg, name); + } + + public static void AtMost(sbyte obj, sbyte value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(byte obj, byte value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(short obj, short value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(ushort obj, ushort value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(int obj, int value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(uint obj, uint value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(long obj, long value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(ulong obj, ulong value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(sbyte? obj, sbyte value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(byte? obj, byte value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(short? obj, short value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(ushort? obj, ushort value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(int? obj, int value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(uint? obj, uint value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(long? obj, long value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(ulong? obj, ulong value, string name, string? msg = null) { if (obj > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + public static void AtMost(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value > value) throw CreateAtMostException(name, msg, value); } + + private static ArgumentException CreateAtMostException(string name, string? msg, T value) + { + if (msg == null) + return new ArgumentException($"Value must be at most {value}", name); + else + return new ArgumentException(msg, name); + } + + public static void GreaterThan(sbyte obj, sbyte value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(byte obj, byte value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(short obj, short value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(ushort obj, ushort value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(int obj, int value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(uint obj, uint value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(long obj, long value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(ulong obj, ulong value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(sbyte? obj, sbyte value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(byte? obj, byte value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(short? obj, short value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(ushort? obj, ushort value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(int? obj, int value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(uint? obj, uint value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(long? obj, long value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(ulong? obj, ulong value, string name, string? msg = null) { if (obj <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + public static void GreaterThan(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value <= value) throw CreateGreaterThanException(name, msg, value); } + + private static ArgumentException CreateGreaterThanException(string name, string? msg, T value) + { + if (msg == null) + return new ArgumentException($"Value must be greater than {value}", name); + else + return new ArgumentException(msg, name); + } + + public static void LessThan(sbyte obj, sbyte value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(byte obj, byte value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(short obj, short value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(ushort obj, ushort value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(int obj, int value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(uint obj, uint value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(long obj, long value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(ulong obj, ulong value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(sbyte? obj, sbyte value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(byte? obj, byte value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(short? obj, short value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(ushort? obj, ushort value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(int? obj, int value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(uint? obj, uint value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(long? obj, long value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(ulong? obj, ulong value, string name, string? msg = null) { if (obj >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, sbyte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, byte value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, short value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, ushort value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, int value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, uint value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, long value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + public static void LessThan(Optional obj, ulong value, string name, string? msg = null) { if (obj.IsSpecified && obj.Value >= value) throw CreateLessThanException(name, msg, value); } + + private static ArgumentException CreateLessThanException(string name, string? msg, T value) + { + if (msg == null) + return new ArgumentException($"Value must be less than {value}", name); + else + return new ArgumentException(msg, name); + } + + // Snowflakes + + public static void NotZero(Snowflake obj, string name, string? msg = null) { if (obj == 0) throw CreateNotZeroException(name, msg); } + public static void NotZero(Optional obj, string name, string? msg = null) { if (obj.IsSpecified && obj.Value == 0) throw CreateNotZeroException(name, msg); } + + public static void YoungerThan(Snowflake snowflake, TimeSpan maximumAge, string name, string? msg = null) + { + var minimumSnowflake = new Snowflake(DateTimeOffset.UtcNow.Subtract(maximumAge)); + YoungerThan(snowflake, minimumSnowflake, name, msg); + } + public static void YoungerThan(Snowflake? snowflake, TimeSpan maximumAge, string name, string? msg = null) + { + if (snowflake == null) + return; + var minimumSnowflake = new Snowflake(DateTimeOffset.UtcNow.Subtract(maximumAge)); + YoungerThan(snowflake.Value, minimumSnowflake, name, msg); + } + public static void YoungerThan(Snowflake[] snowflakes, TimeSpan maximumAge, string name, string? msg = null) + { + var minimumSnowflake = new Snowflake(DateTimeOffset.UtcNow.Subtract(maximumAge)); + for (int i = 0; i < snowflakes.Length; i++) + YoungerThan(snowflakes[i], minimumSnowflake, name, msg); + } + private static void YoungerThan(Snowflake snowflake, ulong minimumSnowflake, string name, string? msg = null) + { + if (snowflake < minimumSnowflake) + { + if (msg == null) + throw new ArgumentOutOfRangeException(name, "Entity is too old"); + else + throw new ArgumentOutOfRangeException(name, msg); + } + } + + public static void OlderThan(Snowflake snowflake, TimeSpan maximumAge, string name, string? msg = null) + { + var maximumSnowflake = new Snowflake(DateTimeOffset.UtcNow.Subtract(maximumAge)); + OlderThan(snowflake, maximumSnowflake, name, msg); + } + public static void OlderThan(Snowflake? snowflake, TimeSpan maximumAge, string name, string? msg = null) + { + if (snowflake == null) + return; + var maximumSnowflake = new Snowflake(DateTimeOffset.UtcNow.Subtract(maximumAge)); + OlderThan(snowflake.Value, maximumSnowflake, name, msg); + } + public static void OlderThan(Snowflake[] snowflakes, TimeSpan maximumAge, string name, string? msg = null) + { + var maximumSnowflake = new Snowflake(DateTimeOffset.UtcNow.Subtract(maximumAge)); + for (int i = 0; i < snowflakes.Length; i++) + OlderThan(snowflakes[i], maximumSnowflake, name, msg); + } + private static void OlderThan(Snowflake snowflake, ulong maximumSnowflake, string name, string? msg = null) + { + if (snowflake > maximumSnowflake) + { + if (msg == null) + throw new ArgumentOutOfRangeException(name, "Entity is too young"); + else + throw new ArgumentOutOfRangeException(name, msg); + } + } + } +}