| @@ -42,7 +42,7 @@ namespace Discord.Net.Models | |||
| /// <param name="thread">The thread that was started from this message, includes thread member object.</param> | |||
| /// <param name="components">Sent if the message contains components like buttons, action rows, or other interactive components.</param> | |||
| [JsonConstructor] | |||
| public Message(Snowflake id, Snowflake channelId, Optional<Snowflake> guildId, User author, Optional<GuildMember> member, string content, DateTimeOffset timestamp, DateTimeOffset? editedTimestamp, bool tts, bool mentionEveryone, UserMention[] mentions, Snowflake[] mentionRoles, Optional<ChannelMention[]> mentionChannels, Attachment[] attachments, Embed[] embeds, Optional<Reaction[]> reactions, Optional<string> nonce, bool pinned, Optional<Snowflake> webhookId, int type, Optional<MessageActivity> activity, Optional<Application> application, Optional<Snowflake> applicationId, Optional<MessageReference> messageReference, Optional<MessageFlags> flags, Optional<Sticker[]> stickers, Optional<Message?> referencedMessage, Optional<MessageInteraction> interaction, Optional<Channel> thread, Optional<Component> components) | |||
| public Message(Snowflake id, Snowflake channelId, Optional<Snowflake> guildId, User author, Optional<GuildMember> member, string content, DateTimeOffset timestamp, DateTimeOffset? editedTimestamp, bool tts, bool mentionEveryone, UserMention[] mentions, Snowflake[] mentionRoles, Optional<ChannelMention[]> mentionChannels, Attachment[] attachments, Embed[] embeds, Optional<Reaction[]> reactions, Optional<string> nonce, bool pinned, Optional<Snowflake> webhookId, int type, Optional<MessageActivity> activity, Optional<Application> application, Optional<Snowflake> applicationId, Optional<MessageReference> messageReference, Optional<MessageFlags> flags, Optional<Sticker[]> stickers, Optional<Message?> referencedMessage, Optional<MessageInteraction> interaction, Optional<Channel> thread, Optional<ActionRowComponent[]> 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. | |||
| /// </summary> | |||
| [JsonPropertyName("components")] | |||
| public Optional<Component> Components { get; } | |||
| public Optional<ActionRowComponent[]> Components { get; } | |||
| } | |||
| } | |||
| @@ -12,17 +12,5 @@ | |||
| <ItemGroup> | |||
| <PackageReference Include="System.Text.Json" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <Folder Include="Emoji\" /> | |||
| <Folder Include="Guild\" /> | |||
| <Folder Include="GuildTemplate\" /> | |||
| <Folder Include="Invite\" /> | |||
| <Folder Include="Teams\" /> | |||
| <Folder Include="Webhook\" /> | |||
| <Folder Include="Voice\" /> | |||
| <Folder Include="User\" /> | |||
| <Folder Include="StageInstance\" /> | |||
| </ItemGroup> | |||
| </Project> | |||
| @@ -5,25 +5,25 @@ namespace Discord.Net.Models | |||
| /// <summary> | |||
| /// Represents the guild NSFW level. | |||
| /// </summary> | |||
| public enum GuildNSFWLevel | |||
| public enum GuildNsfwLevel | |||
| { | |||
| /// <summary> | |||
| /// Default level, don't scan any content. | |||
| /// Default level. | |||
| /// </summary> | |||
| Default = 0, | |||
| /// <summary> | |||
| /// Scan content from members without roles. | |||
| /// Guild contains explicit content. | |||
| /// </summary> | |||
| Explicit = 1, | |||
| /// <summary> | |||
| /// Scan content from all members. | |||
| /// Guild is safe for work. | |||
| /// </summary> | |||
| Safe = 2, | |||
| /// <summary> | |||
| /// Server has an age restriction. | |||
| /// Guild has an age restriction. | |||
| /// </summary> | |||
| AgeRestricted = 3, | |||
| } | |||
| @@ -5,7 +5,7 @@ namespace Discord.Net.Models | |||
| /// <summary> | |||
| /// Represents the m f a level. | |||
| /// </summary> | |||
| public enum MFALevel | |||
| public enum MfaLevel | |||
| { | |||
| /// <summary> | |||
| /// Guild has no MFA/2FA requirement for moderation actions. | |||
| @@ -0,0 +1,26 @@ | |||
| using System.Text.Json.Serialization; | |||
| namespace Discord.Net.Models | |||
| { | |||
| /// <summary> | |||
| /// Represents a component object. | |||
| /// </summary> | |||
| public record ActionRowComponent : Component | |||
| { | |||
| /// <summary> | |||
| /// Creates an <see cref="ActionRowComponent"/> with the provided parameters. | |||
| /// </summary> | |||
| /// <param name="type">Component type.</param> | |||
| [JsonConstructor] | |||
| public ActionRowComponent(ComponentType type) | |||
| : base(type) | |||
| { | |||
| } | |||
| /// <summary> | |||
| /// Components inside this action row, like buttons or other interactive components. | |||
| /// </summary> | |||
| [JsonPropertyName("components")] | |||
| public Optional<Component[]> Components { get; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| using System.Text.Json.Serialization; | |||
| namespace Discord.Net.Models | |||
| { | |||
| /// <summary> | |||
| /// Represents a button component object. | |||
| /// </summary> | |||
| public record ButtonComponent : Component | |||
| { | |||
| /// <summary> | |||
| /// Creates a <see cref="ButtonComponent"/> with the provided parameters. | |||
| /// </summary> | |||
| /// <param name="type">Component type.</param> | |||
| /// <param name="style">One of button styles.</param> | |||
| /// <param name="label">Text that appears on the button, max 80 characters.</param> | |||
| /// <param name="emoji">Name, id, and animated.</param> | |||
| /// <param name="customId">A developer-defined identifier for the button, max 100 characters.</param> | |||
| /// <param name="url">A url for link-style buttons.</param> | |||
| /// <param name="disabled">Whether the button is disabled, default false.</param> | |||
| [JsonConstructor] | |||
| public ButtonComponent(ComponentType type, Optional<ButtonStyle> style, Optional<string> label, Optional<Emoji> emoji, Optional<string> customId, Optional<string> url, Optional<bool> disabled) | |||
| : base(type) | |||
| { | |||
| Style = style; | |||
| Label = label; | |||
| Emoji = emoji; | |||
| CustomId = customId; | |||
| Url = url; | |||
| Disabled = disabled; | |||
| } | |||
| /// <summary> | |||
| /// One of button styles. | |||
| /// </summary> | |||
| [JsonPropertyName("style")] | |||
| public Optional<ButtonStyle> Style { get; } | |||
| /// <summary> | |||
| /// Text that appears on the button, max 80 characters. | |||
| /// </summary> | |||
| [JsonPropertyName("label")] | |||
| public Optional<string> Label { get; } | |||
| /// <summary> | |||
| /// Name, id, and animated. | |||
| /// </summary> | |||
| [JsonPropertyName("emoji")] | |||
| public Optional<Emoji> Emoji { get; } | |||
| /// <summary> | |||
| /// A developer-defined identifier for the button, max 100 characters. | |||
| /// </summary> | |||
| [JsonPropertyName("custom_id")] | |||
| public Optional<string> CustomId { get; } | |||
| /// <summary> | |||
| /// A url for link-style buttons. | |||
| /// </summary> | |||
| [JsonPropertyName("url")] | |||
| public Optional<string> Url { get; } | |||
| /// <summary> | |||
| /// Whether the button is disabled, default false. | |||
| /// </summary> | |||
| [JsonPropertyName("disabled")] | |||
| public Optional<bool> Disabled { get; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,33 @@ | |||
| namespace Discord.Net.Models | |||
| { | |||
| /// <summary> | |||
| /// Represents the button style type. | |||
| /// </summary> | |||
| public enum ButtonStyle | |||
| { | |||
| /// <summary> | |||
| /// Blurple. | |||
| /// </summary> | |||
| Primary = 1, | |||
| /// <summary> | |||
| /// Grey. | |||
| /// </summary> | |||
| Secondary = 2, | |||
| /// <summary> | |||
| /// Green. | |||
| /// </summary> | |||
| Success = 3, | |||
| /// <summary> | |||
| /// Red. | |||
| /// </summary> | |||
| Danger = 4, | |||
| /// <summary> | |||
| /// Grey, navigates to a URL. | |||
| /// </summary> | |||
| Link = 5, | |||
| } | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| using System.Text.Json.Serialization; | |||
| namespace Discord.Net.Models | |||
| { | |||
| /// <summary> | |||
| /// Represents a component object. | |||
| /// </summary> | |||
| public record Component | |||
| { | |||
| /// <summary> | |||
| /// Creates a <see cref="Component"/> with the provided parameters. | |||
| /// </summary> | |||
| /// <param name="type">Component type.</param> | |||
| [JsonConstructor] | |||
| public Component(ComponentType type) | |||
| { | |||
| Type = type; | |||
| } | |||
| /// <summary> | |||
| /// Component type. | |||
| /// </summary> | |||
| [JsonPropertyName("type")] | |||
| public ComponentType Type { get; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| using System; | |||
| namespace Discord.Net.Models | |||
| { | |||
| /// <summary> | |||
| /// Represents the component type. | |||
| /// </summary> | |||
| public enum ComponentType | |||
| { | |||
| /// <summary> | |||
| /// A container for other components. | |||
| /// </summary> | |||
| ActionRow = 1, | |||
| /// <summary> | |||
| /// A clickable button. | |||
| /// </summary> | |||
| Button = 2, | |||
| } | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| namespace Discord.Net.Models | |||
| { | |||
| /// <summary> | |||
| /// Represents the interaction type. | |||
| /// </summary> | |||
| public enum InteractionType | |||
| { | |||
| /// <summary> | |||
| /// Received when registering an interaction, replied with a pong. | |||
| /// </summary> | |||
| Ping = 1, | |||
| /// <summary> | |||
| /// This interaction is from a slash command. | |||
| /// </summary> | |||
| ApplicationCommand = 2, | |||
| /// <summary> | |||
| /// This interaction is from a component. | |||
| /// </summary> | |||
| MessageComponent = 3, | |||
| } | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| using System.Text.Json.Serialization; | |||
| namespace Discord.Net.Models | |||
| { | |||
| /// <summary> | |||
| /// Represents a message interaction object. | |||
| /// </summary> | |||
| public record MessageInteraction | |||
| { | |||
| /// <summary> | |||
| /// Creates a <see cref="MessageInteraction"/> with the provided parameters. | |||
| /// </summary> | |||
| /// <param name="id">Id of the interaction.</param> | |||
| /// <param name="type">The type of interaction.</param> | |||
| /// <param name="name">The name of the ApplicationCommand.</param> | |||
| /// <param name="user">The user who invoked the interaction.</param> | |||
| [JsonConstructor] | |||
| public MessageInteraction(Snowflake id, InteractionType type, string name, User user) | |||
| { | |||
| Id = id; | |||
| Type = type; | |||
| Name = name; | |||
| User = user; | |||
| } | |||
| /// <summary> | |||
| /// Id of the interaction. | |||
| /// </summary> | |||
| [JsonPropertyName("id")] | |||
| public Snowflake Id { get; } | |||
| /// <summary> | |||
| /// The type of interaction. | |||
| /// </summary> | |||
| [JsonPropertyName("type")] | |||
| public InteractionType Type { get; } | |||
| /// <summary> | |||
| /// The name of the ApplicationCommand. | |||
| /// </summary> | |||
| [JsonPropertyName("name")] | |||
| public string Name { get; } | |||
| /// <summary> | |||
| /// The user who invoked the interaction. | |||
| /// </summary> | |||
| [JsonPropertyName("user")] | |||
| public User User { get; } | |||
| } | |||
| } | |||