Add missing IThreadUser interface (#2055)
* Implement * Add IMentionable to RestThreadUser * Rather move mentionable to interface for consistency. * Further consistency
This commit is contained in:
25
src/Discord.Net.Core/Entities/Users/IThreadUser.cs
Normal file
25
src/Discord.Net.Core/Entities/Users/IThreadUser.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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,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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user