* Add new message types & error codes * add role subscription system channel flags and message propertypull/2572/head
@@ -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, | |||
@@ -13,18 +13,28 @@ namespace Discord | |||
/// <summary> | |||
/// Deny the messages that are sent when a user joins the guild. | |||
/// </summary> | |||
WelcomeMessage = 0b1, | |||
WelcomeMessage = 1 << 0, | |||
/// <summary> | |||
/// Deny the messages that are sent when a user boosts the guild. | |||
/// </summary> | |||
GuildBoost = 0b10, | |||
GuildBoost = 1 << 1, | |||
/// <summary> | |||
/// Deny the messages that are related to guild setup. | |||
/// </summary> | |||
GuildSetupTip = 0b100, | |||
GuildSetupTip = 1 << 2, | |||
/// <summary> | |||
/// Deny the reply with sticker button on welcome messages. | |||
/// </summary> | |||
WelcomeMessageReply = 0b1000 | |||
WelcomeMessageReply = 1 << 3, | |||
/// <summary> | |||
/// Deny role subscription purchase and renewal notifications in the guild. | |||
/// </summary> | |||
RoleSubscriptionPurchase = 1 << 4, | |||
/// <summary> | |||
/// Hide role subscription sticker reply buttons in the guild. | |||
/// </summary> | |||
RoleSubscriptionPurchaseReplies = 1 << 5, | |||
} | |||
} |
@@ -210,6 +210,14 @@ namespace Discord | |||
IMessageInteraction Interaction { get; } | |||
/// <summary> | |||
/// Gets the data of the role subscription purchase or renewal that prompted this <see cref="MessageType.RoleSubscriptionPurchase"/> message. | |||
/// </summary> | |||
/// <returns> | |||
/// A <see cref="MessageRoleSubscriptionData"/> if the message is a role subscription purchase message; otherwise <see langword="null"/>. | |||
/// </returns> | |||
MessageRoleSubscriptionData RoleSubscriptionData { get; } | |||
/// <summary> | |||
/// Adds a reaction to this message. | |||
/// </summary> | |||
/// <example> | |||
@@ -0,0 +1,35 @@ | |||
namespace Discord; | |||
/// <summary> | |||
/// Represents a role subscription data in <see cref="IMessage"/>. | |||
/// </summary> | |||
public class MessageRoleSubscriptionData | |||
{ | |||
/// <summary> | |||
/// Gets the id of the sku and listing that the user is subscribed to. | |||
/// </summary> | |||
public ulong Id { get; } | |||
/// <summary> | |||
/// Gets the name of the tier that the user is subscribed to. | |||
/// </summary> | |||
public string TierName { get; } | |||
/// <summary> | |||
/// Gets the cumulative number of months that the user has been subscribed for. | |||
/// </summary> | |||
public int MonthsSubscribed { get; } | |||
/// <summary> | |||
/// Gets whether this notification is for a renewal rather than a new purchase. | |||
/// </summary> | |||
public bool IsRenewal { get; } | |||
internal MessageRoleSubscriptionData(ulong id, string tierName, int monthsSubscribed, bool isRenewal) | |||
{ | |||
Id = id; | |||
TierName = tierName; | |||
MonthsSubscribed = monthsSubscribed; | |||
IsRenewal = isRenewal; | |||
} | |||
} |
@@ -99,12 +99,48 @@ namespace Discord | |||
/// </remarks> | |||
ThreadStarterMessage = 21, | |||
/// <summary> | |||
/// The message for a invite reminder. | |||
/// The message for an invite reminder. | |||
/// </summary> | |||
GuildInviteReminder = 22, | |||
/// <summary> | |||
/// The message for a context menu command. | |||
/// </summary> | |||
ContextMenuCommand = 23, | |||
/// <summary> | |||
/// The message for an automod action. | |||
/// </summary> | |||
AutoModerationAction = 24, | |||
/// <summary> | |||
/// The message for a role subscription purchase. | |||
/// </summary> | |||
RoleSubscriptionPurchase = 25, | |||
/// <summary> | |||
/// The message for an interaction premium upsell. | |||
/// </summary> | |||
InteractionPremiumUpsell = 26, | |||
/// <summary> | |||
/// The message for a stage start. | |||
/// </summary> | |||
StageStart = 27, | |||
/// <summary> | |||
/// The message for a stage end. | |||
/// </summary> | |||
StageEnd = 28, | |||
/// <summary> | |||
/// The message for a stage speaker. | |||
/// </summary> | |||
StageSpeaker = 29, | |||
/// <summary> | |||
/// The message for a stage raise hand. | |||
/// </summary> | |||
StageRaiseHand = 30, | |||
/// <summary> | |||
/// The message for a stage raise hand. | |||
/// </summary> | |||
StageTopic = 31, | |||
/// <summary> | |||
/// The message for a guild application premium subscription. | |||
/// </summary> | |||
GuildApplicationPremiumSubscription = 32 | |||
} | |||
} |
@@ -62,5 +62,7 @@ namespace Discord.API | |||
public Optional<MessageInteraction> Interaction { get; set; } | |||
[JsonProperty("sticker_items")] | |||
public Optional<StickerItem[]> StickerItems { get; set; } | |||
[JsonProperty("role_subscription_data")] | |||
public Optional<MessageRoleSubscriptionData> RoleSubscriptionData { get; set; } | |||
} | |||
} |
@@ -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; } | |||
} |
@@ -80,6 +80,9 @@ namespace Discord.Rest | |||
/// <inheritdoc/> | |||
public MessageType Type { get; private set; } | |||
/// <inheritdoc /> | |||
public MessageRoleSubscriptionData RoleSubscriptionData { get; private set; } | |||
/// <inheritdoc/> | |||
public IReadOnlyCollection<ActionRowComponent> Components { get; private set; } | |||
/// <summary> | |||
@@ -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); | |||
} | |||
} | |||
/// <inheritdoc /> | |||
public async Task UpdateAsync(RequestOptions options = null) | |||
@@ -78,6 +78,9 @@ namespace Discord.WebSocket | |||
/// <inheritdoc/> | |||
public MessageType Type { get; private set; } | |||
/// <inheritdoc /> | |||
public MessageRoleSubscriptionData RoleSubscriptionData { get; private set; } | |||
/// <summary> | |||
/// Returns all attachments included in this message. | |||
/// </summary> | |||
@@ -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); | |||
} | |||
} | |||
/// <inheritdoc /> | |||