Browse Source

Add `DefaultSlowModeInterval` and `DefaultSlowModeInterval` properties to forum channels

pull/2469/head
Misha133 3 years ago
parent
commit
cad0412190
4 changed files with 45 additions and 0 deletions
  1. +18
    -0
      src/Discord.Net.Core/Entities/Channels/IForumChannel.cs
  2. +3
    -0
      src/Discord.Net.Rest/API/Common/Channel.cs
  3. +12
    -0
      src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs
  4. +12
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketForumChannel.cs

+ 18
- 0
src/Discord.Net.Core/Entities/Channels/IForumChannel.cs View File

@@ -35,6 +35,24 @@ namespace Discord
/// </summary>
IReadOnlyCollection<ForumTag> Tags { get; }

/// <summary>
/// Gets the current rate limit on creating posts in this forum channel.
/// </summary>
/// <returns>
/// An <see cref="int"/> representing the time in seconds required before the user can send another
/// message; <c>0</c> if disabled.
/// </returns>
int ThreadCreationInterval { get; }

/// <summary>
/// Gets the current default slow-mode delay for threads in this forum channel.
/// </summary>
/// <returns>
/// An <see cref="int"/> representing the time in seconds required before the user can send another
/// message; <c>0</c> if disabled.
/// </returns>
int DefaultSlowModeInterval { get; }

/// <summary>
/// Creates a new post (thread) within the forum.
/// </summary>


+ 3
- 0
src/Discord.Net.Rest/API/Common/Channel.cs View File

@@ -76,5 +76,8 @@ namespace Discord.API

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

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

+ 12
- 0
src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs View File

@@ -26,6 +26,12 @@ namespace Discord.Rest
/// <inheritdoc/>
public IReadOnlyCollection<ForumTag> Tags { get; private set; }

/// <inheritdoc/>
public int ThreadCreationInterval { get; private set; }

/// <inheritdoc/>
public int DefaultSlowModeInterval { get; private set; }

/// <inheritdoc/>
public string Mention => MentionUtils.MentionChannel(Id);

@@ -49,6 +55,12 @@ namespace Discord.Rest
Topic = model.Topic.GetValueOrDefault();
DefaultAutoArchiveDuration = model.AutoArchiveDuration.GetValueOrDefault(ThreadArchiveDuration.OneDay);

if (model.ThreadRateLimitPerUser.IsSpecified)
DefaultSlowModeInterval = model.ThreadRateLimitPerUser.Value;

if(model.SlowMode.IsSpecified)
ThreadCreationInterval = model.SlowMode.Value;

Tags = model.ForumTags.GetValueOrDefault(Array.Empty<API.ForumTags>()).Select(
x => new ForumTag(x.Id, x.Name, x.EmojiId.GetValueOrDefault(null), x.EmojiName.GetValueOrDefault())
).ToImmutableArray();


+ 12
- 0
src/Discord.Net.WebSocket/Entities/Channels/SocketForumChannel.cs View File

@@ -27,6 +27,12 @@ namespace Discord.WebSocket
/// <inheritdoc/>
public IReadOnlyCollection<ForumTag> Tags { get; private set; }

/// <inheritdoc/>
public int ThreadCreationInterval { get; private set; }

/// <inheritdoc/>
public int DefaultSlowModeInterval { get; private set; }

/// <inheritdoc/>
public string Mention => MentionUtils.MentionChannel(Id);

@@ -46,6 +52,12 @@ namespace Discord.WebSocket
Topic = model.Topic.GetValueOrDefault();
DefaultAutoArchiveDuration = model.AutoArchiveDuration.GetValueOrDefault(ThreadArchiveDuration.OneDay);

if (model.ThreadRateLimitPerUser.IsSpecified)
DefaultSlowModeInterval = model.ThreadRateLimitPerUser.Value;

if (model.SlowMode.IsSpecified)
ThreadCreationInterval = model.SlowMode.Value;

Tags = model.ForumTags.GetValueOrDefault(Array.Empty<API.ForumTags>()).Select(
x => new ForumTag(x.Id, x.Name, x.EmojiId.GetValueOrDefault(null), x.EmojiName.GetValueOrDefault())
).ToImmutableArray();


Loading…
Cancel
Save