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:
Quin Lynch
2022-03-02 19:22:29 -04:00
committed by GitHub
parent 1dc473c7e4
commit 6bf5818e72
6 changed files with 51 additions and 9 deletions

View File

@@ -16,5 +16,11 @@ namespace Discord.API
[JsonProperty("locked")]
public Optional<bool> Locked { get; set; }
[JsonProperty("invitable")]
public Optional<bool> Invitable { get; set; }
[JsonProperty("create_timestamp")]
public Optional<DateTimeOffset> CreatedAt { get; set; }
}
}

View File

@@ -13,7 +13,7 @@ namespace Discord.Rest
{
#region RestChannel
/// <inheritdoc />
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
public virtual DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
internal RestChannel(BaseDiscordClient discord, ulong id)
: base(discord, id)

View File

@@ -34,17 +34,26 @@ namespace Discord.Rest
/// <inheritdoc/>
public int MessageCount { get; private set; }
/// <inheritdoc/>
public bool? IsInvitable { get; private set; }
/// <inheritdoc cref="IThreadChannel.CreatedAt"/>
public override DateTimeOffset CreatedAt { get; }
/// <summary>
/// Gets the parent text channel id.
/// </summary>
public ulong ParentChannelId { get; private set; }
internal RestThreadChannel(BaseDiscordClient discord, IGuild guild, ulong id)
: base(discord, guild, id) { }
internal RestThreadChannel(BaseDiscordClient discord, IGuild guild, ulong id, DateTimeOffset? createdAt)
: base(discord, guild, id)
{
CreatedAt = createdAt ?? new DateTimeOffset(2022, 1, 9, 0, 0, 0, TimeSpan.Zero);
}
internal new static RestThreadChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
{
var entity = new RestThreadChannel(discord, guild, model.Id);
var entity = new RestThreadChannel(discord, guild, model.Id, model.ThreadMetadata.GetValueOrDefault()?.CreatedAt.GetValueOrDefault());
entity.Update(model);
return entity;
}
@@ -57,6 +66,7 @@ namespace Discord.Rest
if (model.ThreadMetadata.IsSpecified)
{
IsInvitable = model.ThreadMetadata.Value.Invitable.ToNullable();
IsArchived = model.ThreadMetadata.Value.Archived;
AutoArchiveDuration = model.ThreadMetadata.Value.AutoArchiveDuration;
ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp;