Browse Source

add role subscription system channel flags and message property

pull/2562/head
Misha133 2 years ago
parent
commit
067846c992
7 changed files with 101 additions and 4 deletions
  1. +14
    -4
      src/Discord.Net.Core/Entities/Guilds/SystemChannelMessageDeny.cs
  2. +8
    -0
      src/Discord.Net.Core/Entities/Messages/IMessage.cs
  3. +35
    -0
      src/Discord.Net.Core/Entities/Messages/MessageRoleSubscriptionData.cs
  4. +2
    -0
      src/Discord.Net.Rest/API/Common/Message.cs
  5. +18
    -0
      src/Discord.Net.Rest/API/Common/MessageRoleSubscriptionData.cs
  6. +12
    -0
      src/Discord.Net.Rest/Entities/Messages/RestMessage.cs
  7. +12
    -0
      src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs

+ 14
- 4
src/Discord.Net.Core/Entities/Guilds/SystemChannelMessageDeny.cs View File

@@ -13,18 +13,28 @@ namespace Discord
/// <summary> /// <summary>
/// Deny the messages that are sent when a user joins the guild. /// Deny the messages that are sent when a user joins the guild.
/// </summary> /// </summary>
WelcomeMessage = 0b1,
WelcomeMessage = 1 << 0,
/// <summary> /// <summary>
/// Deny the messages that are sent when a user boosts the guild. /// Deny the messages that are sent when a user boosts the guild.
/// </summary> /// </summary>
GuildBoost = 0b10,
GuildBoost = 1 << 1,
/// <summary> /// <summary>
/// Deny the messages that are related to guild setup. /// Deny the messages that are related to guild setup.
/// </summary> /// </summary>
GuildSetupTip = 0b100,
GuildSetupTip = 1 << 2,
/// <summary> /// <summary>
/// Deny the reply with sticker button on welcome messages. /// Deny the reply with sticker button on welcome messages.
/// </summary> /// </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
- 0
src/Discord.Net.Core/Entities/Messages/IMessage.cs View File

@@ -209,6 +209,14 @@ namespace Discord
/// </returns> /// </returns>
IMessageInteraction Interaction { get; } 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> /// <summary>
/// Adds a reaction to this message. /// Adds a reaction to this message.
/// </summary> /// </summary>


+ 35
- 0
src/Discord.Net.Core/Entities/Messages/MessageRoleSubscriptionData.cs View File

@@ -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;
}
}

+ 2
- 0
src/Discord.Net.Rest/API/Common/Message.cs View File

@@ -62,5 +62,7 @@ namespace Discord.API
public Optional<MessageInteraction> Interaction { get; set; } public Optional<MessageInteraction> Interaction { get; set; }
[JsonProperty("sticker_items")] [JsonProperty("sticker_items")]
public Optional<StickerItem[]> StickerItems { get; set; } public Optional<StickerItem[]> StickerItems { get; set; }
[JsonProperty("role_subscription_data")]
public Optional<MessageRoleSubscriptionData> RoleSubscriptionData { get; set; }
} }
} }

+ 18
- 0
src/Discord.Net.Rest/API/Common/MessageRoleSubscriptionData.cs View File

@@ -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
- 0
src/Discord.Net.Rest/Entities/Messages/RestMessage.cs View File

@@ -80,6 +80,9 @@ namespace Discord.Rest
/// <inheritdoc/> /// <inheritdoc/>
public MessageType Type { get; private set; } public MessageType Type { get; private set; }


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

/// <inheritdoc/> /// <inheritdoc/>
public IReadOnlyCollection<ActionRowComponent> Components { get; private set; } public IReadOnlyCollection<ActionRowComponent> Components { get; private set; }
/// <summary> /// <summary>
@@ -243,6 +246,15 @@ namespace Discord.Rest
_userMentions = newMentions.ToImmutable(); _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 /> /// <inheritdoc />
public async Task UpdateAsync(RequestOptions options = null) public async Task UpdateAsync(RequestOptions options = null)


+ 12
- 0
src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs View File

@@ -78,6 +78,9 @@ namespace Discord.WebSocket
/// <inheritdoc/> /// <inheritdoc/>
public MessageType Type { get; private set; } public MessageType Type { get; private set; }


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

/// <summary> /// <summary>
/// Returns all attachments included in this message. /// Returns all attachments included in this message.
/// </summary> /// </summary>
@@ -271,6 +274,15 @@ namespace Discord.WebSocket


if (model.Flags.IsSpecified) if (model.Flags.IsSpecified)
Flags = model.Flags.Value; 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 /> /// <inheritdoc />


Loading…
Cancel
Save