[Feature] Add purchase notification (#2942)
This commit is contained in:
12
src/Discord.Net.Rest/API/Common/GuildProductPurchase.cs
Normal file
12
src/Discord.Net.Rest/API/Common/GuildProductPurchase.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API;
|
||||
|
||||
internal class GuildProductPurchase
|
||||
{
|
||||
[JsonProperty("listing_id")]
|
||||
public ulong ListingId { get; set; }
|
||||
|
||||
[JsonProperty("product_name")]
|
||||
public string ProductName { get; set; }
|
||||
}
|
||||
@@ -105,6 +105,9 @@ internal class Message
|
||||
[JsonProperty("poll")]
|
||||
public Optional<Poll> Poll { get; set; }
|
||||
|
||||
[JsonProperty("purchase_notification")]
|
||||
public Optional<MessagePurchaseNotification> PurchaseNotification { get; set; }
|
||||
|
||||
[JsonProperty("call")]
|
||||
public Optional<MessageCallData> Call { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API;
|
||||
|
||||
internal class MessagePurchaseNotification
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public PurchaseType Type { get; set; }
|
||||
|
||||
[JsonProperty("guild_product_purchase")]
|
||||
public Optional<GuildProductPurchase> ProductPurchase { get; set; }
|
||||
}
|
||||
@@ -93,6 +93,9 @@ namespace Discord.Rest
|
||||
/// <inheritdoc />
|
||||
public MessageRoleSubscriptionData RoleSubscriptionData { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public PurchaseNotification PurchaseNotification { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public MessageCallData? CallData { get; private set; }
|
||||
|
||||
@@ -276,9 +279,18 @@ namespace Discord.Rest
|
||||
if (model.Thread.IsSpecified)
|
||||
Thread = RestThreadChannel.Create(Discord, new RestGuild(Discord, model.Thread.Value.GuildId.Value), model.Thread.Value);
|
||||
|
||||
if (model.PurchaseNotification.IsSpecified)
|
||||
{
|
||||
PurchaseNotification = new PurchaseNotification(model.PurchaseNotification.Value.Type,
|
||||
model.PurchaseNotification.Value.ProductPurchase.IsSpecified
|
||||
? new GuildProductPurchase(model.PurchaseNotification.Value.ProductPurchase.Value.ListingId, model.PurchaseNotification.Value.ProductPurchase.Value.ProductName)
|
||||
: null);
|
||||
}
|
||||
|
||||
if (model.Call.IsSpecified)
|
||||
CallData = new MessageCallData(model.Call.Value.Participants, model.Call.Value.EndedTimestamp.ToNullable());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task UpdateAsync(RequestOptions options = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user