Browse Source

Add missing IThreadUser interface (#2055)

* Implement

* Add IMentionable to RestThreadUser

* Rather move mentionable to interface for consistency.

* Further consistency
tags/3.2.1
Armano den Boef GitHub 3 years ago
parent
commit
3475bd8d6f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 17 deletions
  1. +25
    -0
      src/Discord.Net.Core/Entities/Users/IThreadUser.cs
  2. +9
    -12
      src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs
  3. +10
    -5
      src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs

+ 25
- 0
src/Discord.Net.Core/Entities/Users/IThreadUser.cs View File

@@ -0,0 +1,25 @@
using System;

namespace Discord
{
/// <summary>
/// Represents a Discord thread user.
/// </summary>
public interface IThreadUser : IMentionable
{
/// <summary>
/// Gets the <see cref="IThreadChannel"/> this user is in.
/// </summary>
IThreadChannel Thread { get; }

/// <summary>
/// Gets the timestamp for when this user joined this thread.
/// </summary>
DateTimeOffset ThreadJoinedAt { get; }

/// <summary>
/// Gets the guild this thread was created in.
/// </summary>
IGuild Guild { get; }
}
}

+ 9
- 12
src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs View File

@@ -7,23 +7,20 @@ namespace Discord.Rest
/// <summary>
/// Represents a thread user received over the REST api.
/// </summary>
public class RestThreadUser : RestEntity<ulong>
public class RestThreadUser : RestEntity<ulong>, IThreadUser
{
/// <summary>
/// Gets the <see cref="RestThreadChannel"/> this user is in.
/// </summary>
/// <inheritdoc/>
public IThreadChannel Thread { get; }

/// <summary>
/// Gets the timestamp for when this user joined this thread.
/// </summary>
public DateTimeOffset JoinedAt { get; private set; }
/// <inheritdoc/>
public DateTimeOffset ThreadJoinedAt { get; private set; }

/// <summary>
/// Gets the guild this user is in.
/// </summary>
/// <inheritdoc/>
public IGuild Guild { get; }

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

internal RestThreadUser(BaseDiscordClient discord, IGuild guild, IThreadChannel channel, ulong id)
: base(discord, id)
{
@@ -40,7 +37,7 @@ namespace Discord.Rest

internal void Update(Model model)
{
JoinedAt = model.JoinTimestamp;
ThreadJoinedAt = model.JoinTimestamp;
}

/// <summary>


+ 10
- 5
src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs View File

@@ -10,16 +10,14 @@ namespace Discord.WebSocket
/// <summary>
/// Represents a thread user received over the gateway.
/// </summary>
public class SocketThreadUser : SocketUser, IGuildUser
public class SocketThreadUser : SocketUser, IThreadUser, IGuildUser
{
/// <summary>
/// Gets the <see cref="SocketThreadChannel"/> this user is in.
/// </summary>
public SocketThreadChannel Thread { get; private set; }

/// <summary>
/// Gets the timestamp for when this user joined this thread.
/// </summary>
/// <inheritdoc/>
public DateTimeOffset ThreadJoinedAt { get; private set; }

/// <summary>
@@ -180,8 +178,12 @@ namespace Discord.WebSocket

/// <inheritdoc/>
public Task RemoveTimeOutAsync(RequestOptions options = null) => GuildUser.RemoveTimeOutAsync(options);

/// <inheritdoc/>
GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions;
IThreadChannel IThreadUser.Thread => Thread;

/// <inheritdoc/>
IGuild IThreadUser.Guild => Guild;

/// <inheritdoc/>
IGuild IGuildUser.Guild => Guild;
@@ -189,6 +191,9 @@ namespace Discord.WebSocket
/// <inheritdoc/>
ulong IGuildUser.GuildId => Guild.Id;

/// <inheritdoc/>
GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions;

/// <inheritdoc/>
IReadOnlyCollection<ulong> IGuildUser.RoleIds => GuildUser.Roles.Select(x => x.Id).ToImmutableArray();



Loading…
Cancel
Save