Add IsInvitable and CreatedAt to threads (#2153)
* Add IsInvitable and CreatedAt to threads * Update src/Discord.Net.Core/Entities/Channels/IThreadChannel.cs Co-Authored-By: Jared L <48422312+lhjt@users.noreply.github.com> Co-authored-by: Jared L <48422312+lhjt@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Discord.WebSocket
|
||||
/// <summary>
|
||||
/// Gets when the channel is created.
|
||||
/// </summary>
|
||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||
public virtual DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||
/// <summary>
|
||||
/// Gets a collection of users from the WebSocket cache.
|
||||
/// </summary>
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Discord.WebSocket
|
||||
/// <summary>
|
||||
/// Gets the parent channel this thread resides in.
|
||||
/// </summary>
|
||||
public SocketTextChannel ParentChannel { get; private set; }
|
||||
public SocketGuildChannel ParentChannel { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int MessageCount { get; private set; }
|
||||
@@ -64,6 +64,12 @@ namespace Discord.WebSocket
|
||||
/// <inheritdoc/>
|
||||
public bool IsLocked { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool? IsInvitable { get; private set; }
|
||||
|
||||
/// <inheritdoc cref="IThreadChannel.CreatedAt"/>
|
||||
public override DateTimeOffset CreatedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of cached users within this thread.
|
||||
/// </summary>
|
||||
@@ -78,17 +84,19 @@ namespace Discord.WebSocket
|
||||
|
||||
private readonly object _downloadLock = new object();
|
||||
|
||||
internal SocketThreadChannel(DiscordSocketClient discord, SocketGuild guild, ulong id, SocketTextChannel parent)
|
||||
internal SocketThreadChannel(DiscordSocketClient discord, SocketGuild guild, ulong id, SocketGuildChannel parent,
|
||||
DateTimeOffset? createdAt)
|
||||
: base(discord, id, guild)
|
||||
{
|
||||
ParentChannel = parent;
|
||||
_members = new ConcurrentDictionary<ulong, SocketThreadUser>();
|
||||
CreatedAt = createdAt ?? new DateTimeOffset(2022, 1, 9, 0, 0, 0, TimeSpan.Zero);
|
||||
}
|
||||
|
||||
internal new static SocketThreadChannel Create(SocketGuild guild, ClientState state, Model model)
|
||||
{
|
||||
var parent = (SocketTextChannel)guild.GetChannel(model.CategoryId.Value);
|
||||
var entity = new SocketThreadChannel(guild.Discord, guild, model.Id, parent);
|
||||
var parent = guild.GetChannel(model.CategoryId.Value);
|
||||
var entity = new SocketThreadChannel(guild.Discord, guild, model.Id, parent, model.ThreadMetadata.GetValueOrDefault()?.CreatedAt.ToNullable());
|
||||
entity.Update(state, model);
|
||||
return entity;
|
||||
}
|
||||
@@ -103,6 +111,7 @@ namespace Discord.WebSocket
|
||||
|
||||
if (model.ThreadMetadata.IsSpecified)
|
||||
{
|
||||
IsInvitable = model.ThreadMetadata.Value.Invitable.ToNullable();
|
||||
IsArchived = model.ThreadMetadata.Value.Archived;
|
||||
ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp;
|
||||
AutoArchiveDuration = model.ThreadMetadata.Value.AutoArchiveDuration;
|
||||
|
||||
Reference in New Issue
Block a user