diff --git a/src/Discord.Net.Core/DiscordErrorCode.cs b/src/Discord.Net.Core/DiscordErrorCode.cs index 8301842d4..acdfbddc5 100644 --- a/src/Discord.Net.Core/DiscordErrorCode.cs +++ b/src/Discord.Net.Core/DiscordErrorCode.cs @@ -98,13 +98,14 @@ namespace Discord MaximumStickersReached = 30039, MaximumPruneRequestReached = 30040, MaximumGuildWidgetsReached = 30042, - #endregion - - #region General Request Errors (40XXX) BitrateIsTooHighForChannelOfThisType = 30052, MaximumNumberOfEditsReached = 30046, MaximumNumberOfPinnedThreadsInAForumChannelReached = 30047, MaximumNumberOfTagsInAForumChannelReached = 30048, + MaximumNumberOfWebhooksReached = 30058, + #endregion + + #region General Request Errors (40XXX) TokenUnauthorized = 40001, InvalidVerification = 40002, OpeningDMTooFast = 40003, @@ -118,10 +119,11 @@ namespace Discord ApplicationNameAlreadyExists = 40041, ApplicationInteractionFailedToSend = 40043, CannotSendAMessageInAForumChannel = 40058, - ThereAreNoTagsAvailableThatCanBeSetByNonModerators = 40066, - ATagIsRequiredToCreateAForumPostInThisChannel = 40067, InteractionHasAlreadyBeenAcknowledged = 40060, TagNamesMustBeUnique = 40061, + ServiceResourceIsBeingRateLimited = 40062, + ThereAreNoTagsAvailableThatCanBeSetByNonModerators = 40066, + ATagIsRequiredToCreateAForumPostInThisChannel = 40067, #endregion #region Action Preconditions/Checks (50XXX) @@ -160,6 +162,7 @@ namespace Discord InvalidFileUpload = 50046, CannotSelfRedeemGift = 50054, InvalidGuild = 50055, + InvalidRequestOrigin = 50067, InvalidMessageType = 50068, PaymentSourceRequiredForGift = 50070, CannotModifySystemWebhook = 50073, diff --git a/src/Discord.Net.Core/Entities/Guilds/SystemChannelMessageDeny.cs b/src/Discord.Net.Core/Entities/Guilds/SystemChannelMessageDeny.cs index 06de7b812..d50d680bf 100644 --- a/src/Discord.Net.Core/Entities/Guilds/SystemChannelMessageDeny.cs +++ b/src/Discord.Net.Core/Entities/Guilds/SystemChannelMessageDeny.cs @@ -13,18 +13,28 @@ namespace Discord /// /// Deny the messages that are sent when a user joins the guild. /// - WelcomeMessage = 0b1, + WelcomeMessage = 1 << 0, /// /// Deny the messages that are sent when a user boosts the guild. /// - GuildBoost = 0b10, + GuildBoost = 1 << 1, /// /// Deny the messages that are related to guild setup. /// - GuildSetupTip = 0b100, + GuildSetupTip = 1 << 2, /// /// Deny the reply with sticker button on welcome messages. /// - WelcomeMessageReply = 0b1000 + WelcomeMessageReply = 1 << 3, + + /// + /// Deny role subscription purchase and renewal notifications in the guild. + /// + RoleSubscriptionPurchase = 1 << 4, + + /// + /// Hide role subscription sticker reply buttons in the guild. + /// + RoleSubscriptionPurchaseReplies = 1 << 5, } } diff --git a/src/Discord.Net.Core/Entities/Messages/IMessage.cs b/src/Discord.Net.Core/Entities/Messages/IMessage.cs index 48db4fdf0..0437cd7d1 100644 --- a/src/Discord.Net.Core/Entities/Messages/IMessage.cs +++ b/src/Discord.Net.Core/Entities/Messages/IMessage.cs @@ -209,6 +209,14 @@ namespace Discord /// IMessageInteraction Interaction { get; } + /// + /// Gets the data of the role subscription purchase or renewal that prompted this message. + /// + /// + /// A if the message is a role subscription purchase message; otherwise . + /// + MessageRoleSubscriptionData RoleSubscriptionData { get; } + /// /// Adds a reaction to this message. /// diff --git a/src/Discord.Net.Core/Entities/Messages/MessageRoleSubscriptionData.cs b/src/Discord.Net.Core/Entities/Messages/MessageRoleSubscriptionData.cs new file mode 100644 index 000000000..2c1a33461 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Messages/MessageRoleSubscriptionData.cs @@ -0,0 +1,35 @@ +namespace Discord; + +/// +/// Represents a role subscription data in . +/// +public class MessageRoleSubscriptionData +{ + /// + /// Gets the id of the sku and listing that the user is subscribed to. + /// + public ulong Id { get; } + + /// + /// Gets the name of the tier that the user is subscribed to. + /// + public string TierName { get; } + + /// + /// Gets the cumulative number of months that the user has been subscribed for. + /// + public int MonthsSubscribed { get; } + + /// + /// Gets whether this notification is for a renewal rather than a new purchase. + /// + public bool IsRenewal { get; } + + internal MessageRoleSubscriptionData(ulong id, string tierName, int monthsSubscribed, bool isRenewal) + { + Id = id; + TierName = tierName; + MonthsSubscribed = monthsSubscribed; + IsRenewal = isRenewal; + } +} diff --git a/src/Discord.Net.Core/Entities/Messages/MessageType.cs b/src/Discord.Net.Core/Entities/Messages/MessageType.cs index b83f88434..be36d5967 100644 --- a/src/Discord.Net.Core/Entities/Messages/MessageType.cs +++ b/src/Discord.Net.Core/Entities/Messages/MessageType.cs @@ -99,12 +99,48 @@ namespace Discord /// ThreadStarterMessage = 21, /// - /// The message for a invite reminder. + /// The message for an invite reminder. /// GuildInviteReminder = 22, /// /// The message for a context menu command. /// ContextMenuCommand = 23, + /// + /// The message for an automod action. + /// + AutoModerationAction = 24, + /// + /// The message for a role subscription purchase. + /// + RoleSubscriptionPurchase = 25, + /// + /// The message for an interaction premium upsell. + /// + InteractionPremiumUpsell = 26, + /// + /// The message for a stage start. + /// + StageStart = 27, + /// + /// The message for a stage end. + /// + StageEnd = 28, + /// + /// The message for a stage speaker. + /// + StageSpeaker = 29, + /// + /// The message for a stage raise hand. + /// + StageRaiseHand = 30, + /// + /// The message for a stage raise hand. + /// + StageTopic = 31, + /// + /// The message for a guild application premium subscription. + /// + GuildApplicationPremiumSubscription = 32 } } diff --git a/src/Discord.Net.Rest/API/Common/Message.cs b/src/Discord.Net.Rest/API/Common/Message.cs index d33a03fe5..f42a23b65 100644 --- a/src/Discord.Net.Rest/API/Common/Message.cs +++ b/src/Discord.Net.Rest/API/Common/Message.cs @@ -62,5 +62,7 @@ namespace Discord.API public Optional Interaction { get; set; } [JsonProperty("sticker_items")] public Optional StickerItems { get; set; } + [JsonProperty("role_subscription_data")] + public Optional RoleSubscriptionData { get; set; } } } diff --git a/src/Discord.Net.Rest/API/Common/MessageRoleSubscriptionData.cs b/src/Discord.Net.Rest/API/Common/MessageRoleSubscriptionData.cs new file mode 100644 index 000000000..da97ec6b5 --- /dev/null +++ b/src/Discord.Net.Rest/API/Common/MessageRoleSubscriptionData.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Discord.API; + +internal class MessageRoleSubscriptionData +{ + [JsonProperty("role_subscription_listing_id")] + public ulong SubscriptionListingId { get; set; } + + [JsonProperty("tier_name")] + public string TierName { get; set; } + + [JsonProperty("total_months_subscribed")] + public int MonthsSubscribed { get; set; } + + [JsonProperty("is_renewal")] + public bool IsRenewal { get; set; } +} diff --git a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs index 8b6b44e39..dfc814678 100644 --- a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs +++ b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs @@ -80,6 +80,9 @@ namespace Discord.Rest /// public MessageType Type { get; private set; } + /// + public MessageRoleSubscriptionData RoleSubscriptionData { get; private set; } + /// public IReadOnlyCollection Components { get; private set; } /// @@ -243,6 +246,15 @@ namespace Discord.Rest _userMentions = newMentions.ToImmutable(); } } + + if (model.RoleSubscriptionData.IsSpecified) + { + RoleSubscriptionData = new( + model.RoleSubscriptionData.Value.SubscriptionListingId, + model.RoleSubscriptionData.Value.TierName, + model.RoleSubscriptionData.Value.MonthsSubscribed, + model.RoleSubscriptionData.Value.IsRenewal); + } } /// public async Task UpdateAsync(RequestOptions options = null) diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs index 40a645afb..df7d91bd0 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs @@ -78,6 +78,9 @@ namespace Discord.WebSocket /// public MessageType Type { get; private set; } + /// + public MessageRoleSubscriptionData RoleSubscriptionData { get; private set; } + /// /// Returns all attachments included in this message. /// @@ -271,6 +274,15 @@ namespace Discord.WebSocket if (model.Flags.IsSpecified) Flags = model.Flags.Value; + + if (model.RoleSubscriptionData.IsSpecified) + { + RoleSubscriptionData = new( + model.RoleSubscriptionData.Value.SubscriptionListingId, + model.RoleSubscriptionData.Value.TierName, + model.RoleSubscriptionData.Value.MonthsSubscribed, + model.RoleSubscriptionData.Value.IsRenewal); + } } ///