Browse Source

implement `ThreadChannelProperties`

pull/2469/head
Misha133 2 years ago
parent
commit
9a26cf86e8
6 changed files with 50 additions and 17 deletions
  1. +11
    -0
      src/Discord.Net.Core/Entities/Channels/IThreadChannel.cs
  2. +0
    -15
      src/Discord.Net.Core/Entities/Channels/TextChannelProperties.cs
  3. +26
    -0
      src/Discord.Net.Core/Entities/Channels/ThreadChannelProperties.cs
  4. +7
    -0
      src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs
  5. +2
    -2
      src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs
  6. +4
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs

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

@@ -111,5 +111,16 @@ namespace Discord
/// A task that represents the asynchronous operation of removing a user from this thread. /// A task that represents the asynchronous operation of removing a user from this thread.
/// </returns> /// </returns>
Task RemoveUserAsync(IGuildUser user, RequestOptions options = null); Task RemoveUserAsync(IGuildUser user, RequestOptions options = null);

/// <summary>
/// Modifies this thread channel.
/// </summary>
/// <param name="func">The delegate containing the properties to modify the channel with.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous modification operation.
/// </returns>
/// <seealso cref="ThreadChannelProperties"/>
Task ModifyAsync(Action<ThreadChannelProperties> func, RequestOptions options = null);
} }
} }

+ 0
- 15
src/Discord.Net.Core/Entities/Channels/TextChannelProperties.cs View File

@@ -40,25 +40,10 @@ namespace Discord
/// <exception cref="ArgumentOutOfRangeException">Thrown if the value does not fall within [0, 21600].</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown if the value does not fall within [0, 21600].</exception>
public Optional<int> SlowModeInterval { get; set; } public Optional<int> SlowModeInterval { get; set; }


/// <summary>
/// Gets or sets whether or not the thread is archived.
/// </summary>
public Optional<bool> Archived { get; set; }

/// <summary>
/// Gets or sets whether or not the thread is locked.
/// </summary>
public Optional<bool> Locked { get; set; }

/// <summary> /// <summary>
/// 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; }

} }
} }

+ 26
- 0
src/Discord.Net.Core/Entities/Channels/ThreadChannelProperties.cs View File

@@ -0,0 +1,26 @@
using System.Collections.Generic;

namespace Discord;


/// <summary>
/// Provides properties that are used to modify an <see cref="IThreadChannel"/> with the specified changes.
/// </summary>
/// <seealso cref="IThreadChannel.ModifyAsync(System.Action{ThreadChannelProperties}, RequestOptions)"/>
public class ThreadChannelProperties : TextChannelProperties
{
/// <summary>
/// Gets or sets the tags applied to a forum thread
/// </summary>
public Optional<IEnumerable<ulong>> AppliedTags { get; set; }

/// <summary>
/// Gets or sets whether or not the thread is locked.
/// </summary>
public Optional<bool> Locked { get; set; }

/// <summary>
/// Gets or sets whether or not the thread is archived.
/// </summary>
public Optional<bool> Archived { get; set; }
}

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

@@ -114,6 +114,13 @@ namespace Discord.Rest
Update(model); Update(model);
} }


/// <inheritdoc/>
public async Task ModifyAsync(Action<ThreadChannelProperties> func, RequestOptions options = null)
{
var model = await ThreadHelper.ModifyAsync(this, Discord, func, options);
Update(model);
}

/// <inheritdoc/> /// <inheritdoc/>
/// <remarks> /// <remarks>
/// <b>This method is not supported in threads.</b> /// <b>This method is not supported in threads.</b>


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

@@ -46,10 +46,10 @@ namespace Discord.Rest
} }


public static async Task<Model> ModifyAsync(IThreadChannel channel, BaseDiscordClient client, public static async Task<Model> ModifyAsync(IThreadChannel channel, BaseDiscordClient client,
Action<TextChannelProperties> func,
Action<ThreadChannelProperties> func,
RequestOptions options) RequestOptions options)
{ {
var args = new TextChannelProperties();
var args = new ThreadChannelProperties();
func(args); func(args);
var apiArgs = new ModifyThreadParams var apiArgs = new ModifyThreadParams
{ {


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

@@ -342,6 +342,10 @@ namespace Discord.WebSocket
public override Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null) public override Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null)
=> ThreadHelper.ModifyAsync(this, Discord, func, options); => ThreadHelper.ModifyAsync(this, Discord, func, options);


/// <inheritdoc/>
public Task ModifyAsync(Action<ThreadChannelProperties> func, RequestOptions options = null)
=> ThreadHelper.ModifyAsync(this, Discord, func, options);

/// <inheritdoc/> /// <inheritdoc/>
/// <remarks> /// <remarks>
/// <b>This method is not supported in threads.</b> /// <b>This method is not supported in threads.</b>


Loading…
Cancel
Save