@@ -180,5 +180,17 @@ namespace Discord | |||
/// A sticker was deleted. | |||
/// </summary> | |||
StickerDeleted = 92, | |||
/// <summary> | |||
/// A thread was created. | |||
/// </summary> | |||
ThreadCreate = 110, | |||
/// <summary> | |||
/// A thread was updated. | |||
/// </summary> | |||
ThreadUpdate = 111, | |||
/// <summary> | |||
/// A thread was deleted. | |||
/// </summary> | |||
ThreadDelete = 112 | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
using Newtonsoft.Json; | |||
using Newtonsoft.Json; | |||
namespace Discord.API | |||
{ | |||
@@ -7,6 +7,12 @@ namespace Discord.API | |||
[JsonProperty("webhooks")] | |||
public Webhook[] Webhooks { get; set; } | |||
[JsonProperty("threads")] | |||
public Channel[] Threads { get; set; } | |||
[JsonProperty("integrations")] | |||
public Integration[] Integrations { get; set; } | |||
[JsonProperty("users")] | |||
public User[] Users { get; set; } | |||
@@ -1,4 +1,4 @@ | |||
using Newtonsoft.Json; | |||
using Newtonsoft.Json; | |||
namespace Discord.API | |||
{ | |||
@@ -1,4 +1,4 @@ | |||
using System; | |||
using System; | |||
using System.Collections.Generic; | |||
using Model = Discord.API.AuditLog; | |||
@@ -51,6 +51,7 @@ namespace Discord.Rest | |||
[ActionType.MessageBulkDeleted] = MessageBulkDeleteAuditLogData.Create, | |||
[ActionType.MessagePinned] = MessagePinAuditLogData.Create, | |||
[ActionType.MessageUnpinned] = MessageUnpinAuditLogData.Create, | |||
}; | |||
public static IAuditLogData CreateData(BaseDiscordClient discord, Model log, EntryModel entry) | |||
@@ -0,0 +1,36 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Represents information for a stage. | |||
/// </summary> | |||
public class StageInfo | |||
{ | |||
/// <summary> | |||
/// Gets the topic of the stage channel. | |||
/// </summary> | |||
public string Topic { get; } | |||
/// <summary> | |||
/// Gets the privacy level of the stage channel. | |||
/// </summary> | |||
public StagePrivacyLevel? PrivacyLevel { get; } | |||
/// <summary> | |||
/// Gets the user who started the stage channel. | |||
/// </summary> | |||
public IUser User { get; } | |||
internal StageInfo(IUser user, StagePrivacyLevel? level, string topic) | |||
{ | |||
this.Topic = topic; | |||
this.PrivacyLevel = level; | |||
this.User = user; | |||
} | |||
} | |||
} |
@@ -0,0 +1,55 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Model = Discord.API.AuditLog; | |||
using EntryModel = Discord.API.AuditLogEntry; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Contains a piece of audit log data related to a stage going live. | |||
/// </summary> | |||
public class StageInstanceCreateAuditLogData : IAuditLogData | |||
{ | |||
/// <summary> | |||
/// Gets the topic of the stage channel. | |||
/// </summary> | |||
public string Topic { get; } | |||
/// <summary> | |||
/// Gets the privacy level of the stage channel. | |||
/// </summary> | |||
public StagePrivacyLevel PrivacyLevel { get; } | |||
/// <summary> | |||
/// Gets the user who started the stage channel. | |||
/// </summary> | |||
public IUser User { get; } | |||
/// <summary> | |||
/// Gets the Id of the stage channel. | |||
/// </summary> | |||
public ulong StageChannelId { get; } | |||
internal StageInstanceCreateAuditLogData(string topic, StagePrivacyLevel privacyLevel, IUser user, ulong channelId) | |||
{ | |||
Topic = topic; | |||
PrivacyLevel = privacyLevel; | |||
User = user; | |||
StageChannelId = channelId; | |||
} | |||
internal static StageInstanceCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) | |||
{ | |||
var topic = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "topic").NewValue.ToObject<string>(discord.ApiClient.Serializer); | |||
var privacyLevel = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy_level").NewValue.ToObject<StagePrivacyLevel>(discord.ApiClient.Serializer); | |||
var user = log.Users.FirstOrDefault(x => x.Id == entry.UserId); | |||
var channelId = entry.Options.ChannelId; | |||
return new StageInstanceCreateAuditLogData(topic, privacyLevel, RestUser.Create(discord, user), channelId ?? 0); | |||
} | |||
} | |||
} |
@@ -0,0 +1,55 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Model = Discord.API.AuditLog; | |||
using EntryModel = Discord.API.AuditLogEntry; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Contains a piece of audit log data related to a stage instance deleted. | |||
/// </summary> | |||
public class StageInstanceDeleteAuditLogData | |||
{ | |||
/// <summary> | |||
/// Gets the topic of the stage channel. | |||
/// </summary> | |||
public string Topic { get; } | |||
/// <summary> | |||
/// Gets the privacy level of the stage channel. | |||
/// </summary> | |||
public StagePrivacyLevel PrivacyLevel { get; } | |||
/// <summary> | |||
/// Gets the user who started the stage channel. | |||
/// </summary> | |||
public IUser User { get; } | |||
/// <summary> | |||
/// Gets the Id of the stage channel. | |||
/// </summary> | |||
public ulong StageChannelId { get; } | |||
internal StageInstanceDeleteAuditLogData(string topic, StagePrivacyLevel privacyLevel, IUser user, ulong channelId) | |||
{ | |||
Topic = topic; | |||
PrivacyLevel = privacyLevel; | |||
User = user; | |||
StageChannelId = channelId; | |||
} | |||
internal static StageInstanceDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) | |||
{ | |||
var topic = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "topic").OldValue.ToObject<string>(discord.ApiClient.Serializer); | |||
var privacyLevel = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy_level").OldValue.ToObject<StagePrivacyLevel>(discord.ApiClient.Serializer); | |||
var user = log.Users.FirstOrDefault(x => x.Id == entry.UserId); | |||
var channelId = entry.Options.ChannelId; | |||
return new StageInstanceDeleteAuditLogData(topic, privacyLevel, RestUser.Create(discord, user), channelId ?? 0); | |||
} | |||
} | |||
} |
@@ -0,0 +1,55 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Model = Discord.API.AuditLog; | |||
using EntryModel = Discord.API.AuditLogEntry; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Contains a piece of audit log data related to a stage instance update. | |||
/// </summary> | |||
public class StageInstanceUpdatedAuditLogData | |||
{ | |||
/// <summary> | |||
/// Gets the Id of the stage channel. | |||
/// </summary> | |||
public ulong StageChannelId { get; } | |||
/// <summary> | |||
/// Gets the stage information before the changes. | |||
/// </summary> | |||
public StageInfo Before { get; } | |||
/// <summary> | |||
/// Gets the stage information after the changes. | |||
/// </summary> | |||
public StageInfo After { get; } | |||
internal StageInstanceUpdatedAuditLogData(ulong channelId, StageInfo before, StageInfo after) | |||
{ | |||
StageChannelId = channelId; | |||
Before = before; | |||
After = after; | |||
} | |||
internal static StageInstanceUpdatedAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) | |||
{ | |||
var channelId = entry.Options.ChannelId.Value; | |||
var topic = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "topic"); | |||
var privacy = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy"); | |||
var user = RestUser.Create(discord, log.Users.FirstOrDefault(x => x.Id == entry.UserId)); | |||
var oldTopic = topic?.OldValue.ToObject<string>(); | |||
var newTopic = topic?.NewValue.ToObject<string>(); | |||
var oldPrivacy = privacy?.OldValue.ToObject<StagePrivacyLevel>(); | |||
var newPrivacy = privacy?.NewValue.ToObject<StagePrivacyLevel>(); | |||
return new StageInstanceUpdatedAuditLogData(channelId, new StageInfo(user, oldPrivacy, oldTopic), new StageInfo(user, newPrivacy, newTopic)); | |||
} | |||
} | |||
} |