Browse Source

add `AppliedTags` property

pull/2469/head
Misha133 2 years ago
parent
commit
c7a946c6eb
7 changed files with 36 additions and 3 deletions
  1. +9
    -0
      src/Discord.Net.Core/Entities/Channels/IThreadChannel.cs
  2. +7
    -1
      src/Discord.Net.Core/Entities/Channels/TextChannelProperties.cs
  3. +4
    -1
      src/Discord.Net.Rest/API/Common/Channel.cs
  4. +4
    -0
      src/Discord.Net.Rest/API/Rest/ModifyThreadParams.cs
  5. +5
    -0
      src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs
  6. +2
    -1
      src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs
  7. +5
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs

+ 9
- 0
src/Discord.Net.Core/Entities/Channels/IThreadChannel.cs View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;


namespace Discord namespace Discord
@@ -56,6 +57,14 @@ namespace Discord
/// </remarks> /// </remarks>
bool? IsInvitable { get; } bool? IsInvitable { get; }


/// <summary>
/// Gets ids of tags applied to a forum thread
/// </summary>
/// <remarks>
/// This property is only available on forum threads.
/// </remarks>
IReadOnlyCollection<ulong> AppliedTags { get; }

/// <summary> /// <summary>
/// Gets when the thread was created. /// Gets when the thread was created.
/// </summary> /// </summary>


+ 7
- 1
src/Discord.Net.Core/Entities/Channels/TextChannelProperties.cs View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;


namespace Discord namespace Discord
{ {
@@ -53,6 +54,11 @@ namespace Discord
/// Gets or sets the auto archive duration. /// Gets or sets the auto archive duration.
/// </summary> /// </summary>
public Optional<ThreadArchiveDuration> AutoArchiveDuration { get; set; } public Optional<ThreadArchiveDuration> AutoArchiveDuration { get; set; }

/// <summary>
/// Gets or sets the tags applied to a forum thread
/// </summary>
public Optional<IEnumerable<ulong>> AppliedTags { get; set; }

} }
} }

+ 4
- 1
src/Discord.Net.Rest/API/Common/Channel.cs View File

@@ -70,7 +70,10 @@ namespace Discord.API
//ForumChannel //ForumChannel
[JsonProperty("available_tags")] [JsonProperty("available_tags")]
public Optional<ForumTags[]> ForumTags { get; set; } public Optional<ForumTags[]> ForumTags { get; set; }

[JsonProperty("applied_tags")]
public Optional<ulong[]> AppliedTags { get; set; }

[JsonProperty("default_auto_archive_duration")] [JsonProperty("default_auto_archive_duration")]
public Optional<ThreadArchiveDuration> AutoArchiveDuration { get; set; } public Optional<ThreadArchiveDuration> AutoArchiveDuration { get; set; }
} }


+ 4
- 0
src/Discord.Net.Rest/API/Rest/ModifyThreadParams.cs View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections.Generic;


namespace Discord.API.Rest namespace Discord.API.Rest
{ {
@@ -18,5 +19,8 @@ namespace Discord.API.Rest


[JsonProperty("rate_limit_per_user")] [JsonProperty("rate_limit_per_user")]
public Optional<int> Slowmode { get; set; } public Optional<int> Slowmode { get; set; }

[JsonProperty("applied_tags")]
public Optional<IEnumerable<ulong>> AppliedTags { get; set; }
} }
} }

+ 5
- 0
src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs View File

@@ -37,6 +37,9 @@ namespace Discord.Rest
/// <inheritdoc/> /// <inheritdoc/>
public bool? IsInvitable { get; private set; } public bool? IsInvitable { get; private set; }


/// <inheritdoc/>
public IReadOnlyCollection<ulong> AppliedTags { get; private set; }

/// <inheritdoc cref="IThreadChannel.CreatedAt"/> /// <inheritdoc cref="IThreadChannel.CreatedAt"/>
public override DateTimeOffset CreatedAt { get; } public override DateTimeOffset CreatedAt { get; }


@@ -77,6 +80,8 @@ namespace Discord.Rest
MessageCount = model.MessageCount.GetValueOrDefault(0); MessageCount = model.MessageCount.GetValueOrDefault(0);
Type = (ThreadType)model.Type; Type = (ThreadType)model.Type;
ParentChannelId = model.CategoryId.Value; ParentChannelId = model.CategoryId.Value;

AppliedTags = model.AppliedTags.GetValueOrDefault(Array.Empty<ulong>());
} }


/// <summary> /// <summary>


+ 2
- 1
src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs View File

@@ -57,7 +57,8 @@ namespace Discord.Rest
Archived = args.Archived, Archived = args.Archived,
AutoArchiveDuration = args.AutoArchiveDuration, AutoArchiveDuration = args.AutoArchiveDuration,
Locked = args.Locked, Locked = args.Locked,
Slowmode = args.SlowModeInterval
Slowmode = args.SlowModeInterval,
AppliedTags = args.AppliedTags
}; };
return await client.ApiClient.ModifyThreadAsync(channel.Id, apiArgs, options).ConfigureAwait(false); return await client.ApiClient.ModifyThreadAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
} }


+ 5
- 0
src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs View File

@@ -89,6 +89,9 @@ namespace Discord.WebSocket
/// <inheritdoc/> /// <inheritdoc/>
public bool? IsInvitable { get; private set; } public bool? IsInvitable { get; private set; }


/// <inheritdoc/>
public IReadOnlyCollection<ulong> AppliedTags { get; private set; }

/// <inheritdoc cref="IThreadChannel.CreatedAt"/> /// <inheritdoc cref="IThreadChannel.CreatedAt"/>
public override DateTimeOffset CreatedAt { get; } public override DateTimeOffset CreatedAt { get; }


@@ -149,6 +152,8 @@ namespace Discord.WebSocket
} }


HasJoined = model.ThreadMember.IsSpecified; HasJoined = model.ThreadMember.IsSpecified;

AppliedTags = model.AppliedTags.GetValueOrDefault(Array.Empty<ulong>());
} }


internal IReadOnlyCollection<SocketThreadUser> RemoveUsers(ulong[] users) internal IReadOnlyCollection<SocketThreadUser> RemoveUsers(ulong[] users)


Loading…
Cancel
Save