diff --git a/src/Models/Channel/Message/Message.cs b/src/Models/Channel/Message/Message.cs index 073f01e2c..84a45e9b6 100644 --- a/src/Models/Channel/Message/Message.cs +++ b/src/Models/Channel/Message/Message.cs @@ -42,7 +42,7 @@ namespace Discord.Net.Models /// 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) + 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; @@ -254,6 +254,6 @@ namespace Discord.Net.Models /// Sent if the message contains components like buttons, action rows, or other interactive components. /// [JsonPropertyName("components")] - public Optional Components { get; } + public Optional Components { get; } } } diff --git a/src/Models/Discord.Net.Models.csproj b/src/Models/Discord.Net.Models.csproj index 4b0e96a5a..b01c93952 100644 --- a/src/Models/Discord.Net.Models.csproj +++ b/src/Models/Discord.Net.Models.csproj @@ -12,17 +12,5 @@ - - - - - - - - - - - - diff --git a/src/Models/Guild/GuildNSFWLevel.cs b/src/Models/Guild/GuildNSFWLevel.cs index 4c8064971..d04740df1 100644 --- a/src/Models/Guild/GuildNSFWLevel.cs +++ b/src/Models/Guild/GuildNSFWLevel.cs @@ -5,25 +5,25 @@ namespace Discord.Net.Models /// /// Represents the guild NSFW level. /// - public enum GuildNSFWLevel + public enum GuildNsfwLevel { /// - /// Default level, don't scan any content. + /// Default level. /// Default = 0, /// - /// Scan content from members without roles. + /// Guild contains explicit content. /// Explicit = 1, /// - /// Scan content from all members. + /// Guild is safe for work. /// Safe = 2, /// - /// Server has an age restriction. + /// Guild has an age restriction. /// AgeRestricted = 3, } diff --git a/src/Models/Guild/MFALevel.cs b/src/Models/Guild/MFALevel.cs index 488d187dd..4b0a2628c 100644 --- a/src/Models/Guild/MFALevel.cs +++ b/src/Models/Guild/MFALevel.cs @@ -5,7 +5,7 @@ namespace Discord.Net.Models /// /// Represents the m f a level. /// - public enum MFALevel + public enum MfaLevel { /// /// Guild has no MFA/2FA requirement for moderation actions. diff --git a/src/Models/MessageComponents/ActionRowComponent.cs b/src/Models/MessageComponents/ActionRowComponent.cs new file mode 100644 index 000000000..aca1df2dd --- /dev/null +++ b/src/Models/MessageComponents/ActionRowComponent.cs @@ -0,0 +1,26 @@ +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 new file mode 100644 index 000000000..406f151f7 --- /dev/null +++ b/src/Models/MessageComponents/ButtonComponent.cs @@ -0,0 +1,68 @@ +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/ButtonStyle.cs b/src/Models/MessageComponents/ButtonStyle.cs new file mode 100644 index 000000000..38a808c77 --- /dev/null +++ b/src/Models/MessageComponents/ButtonStyle.cs @@ -0,0 +1,33 @@ +namespace Discord.Net.Models +{ + /// + /// Represents the button style type. + /// + public enum ButtonStyle + { + /// + /// Blurple. + /// + Primary = 1, + + /// + /// Grey. + /// + Secondary = 2, + + /// + /// Green. + /// + Success = 3, + + /// + /// Red. + /// + Danger = 4, + + /// + /// Grey, navigates to a URL. + /// + Link = 5, + } +} diff --git a/src/Models/MessageComponents/Component.cs b/src/Models/MessageComponents/Component.cs new file mode 100644 index 000000000..7fe2ed9bd --- /dev/null +++ b/src/Models/MessageComponents/Component.cs @@ -0,0 +1,26 @@ +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 new file mode 100644 index 000000000..76fcd0833 --- /dev/null +++ b/src/Models/MessageComponents/ComponentType.cs @@ -0,0 +1,20 @@ +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/SlashCommands/InteractionType.cs b/src/Models/SlashCommands/InteractionType.cs new file mode 100644 index 000000000..ec6a431af --- /dev/null +++ b/src/Models/SlashCommands/InteractionType.cs @@ -0,0 +1,23 @@ +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 new file mode 100644 index 000000000..c34127068 --- /dev/null +++ b/src/Models/SlashCommands/MessageInteraction.cs @@ -0,0 +1,50 @@ +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; } + } +}