Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/Discord.Net.Core/DiscordErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ public enum DiscordErrorCode
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,
Expand All @@ -118,10 +119,11 @@ public enum DiscordErrorCode
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)
Expand Down Expand Up @@ -160,6 +162,7 @@ public enum DiscordErrorCode
InvalidFileUpload = 50046,
CannotSelfRedeemGift = 50054,
InvalidGuild = 50055,
InvalidRequestOrigin = 50067,
InvalidMessageType = 50068,
PaymentSourceRequiredForGift = 50070,
CannotModifySystemWebhook = 50073,
Expand Down
18 changes: 14 additions & 4 deletions src/Discord.Net.Core/Entities/Guilds/SystemChannelMessageDeny.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,28 @@ public enum SystemChannelMessageDeny
/// <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,
}
}
8 changes: 8 additions & 0 deletions src/Discord.Net.Core/Entities/Messages/IMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ public interface IMessage : ISnowflakeEntity, IDeletable
/// </returns>
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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
38 changes: 37 additions & 1 deletion src/Discord.Net.Core/Entities/Messages/MessageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,48 @@ public enum MessageType
/// </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
}
}
2 changes: 2 additions & 0 deletions src/Discord.Net.Rest/API/Common/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ internal class Message
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; }
}
}
18 changes: 18 additions & 0 deletions src/Discord.Net.Rest/API/Common/MessageRoleSubscriptionData.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
12 changes: 12 additions & 0 deletions src/Discord.Net.Rest/Entities/Messages/RestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public abstract class RestMessage : RestEntity<ulong>, IMessage, IUpdateable
/// <inheritdoc/>
public MessageType Type { get; private set; }

/// <inheritdoc />
public MessageRoleSubscriptionData RoleSubscriptionData { get; private set; }

/// <inheritdoc/>
public IReadOnlyCollection<ActionRowComponent> Components { get; private set; }
/// <summary>
Expand Down Expand Up @@ -243,6 +246,15 @@ internal virtual void Update(Model model)
_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)
Expand Down
12 changes: 12 additions & 0 deletions src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public abstract class SocketMessage : SocketEntity<ulong>, IMessage
/// <inheritdoc/>
public MessageType Type { get; private set; }

/// <inheritdoc />
public MessageRoleSubscriptionData RoleSubscriptionData { get; private set; }

/// <summary>
/// Returns all attachments included in this message.
/// </summary>
Expand Down Expand Up @@ -271,6 +274,15 @@ internal virtual void Update(ClientState state, Model model)

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 />
Expand Down