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>
|
/// <summary>
|
||||||
/// Represents a thread user received over the REST api.
|
/// Represents a thread user received over the REST api.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RestThreadUser : RestEntity<ulong>
|
public class RestThreadUser : RestEntity<ulong>, IThreadUser
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// Gets the <see cref="RestThreadChannel"/> this user is in.
|
|
||||||
/// </summary>
|
|
||||||
public IThreadChannel Thread { get; }
|
public IThreadChannel Thread { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// Gets the timestamp for when this user joined this thread.
|
public DateTimeOffset ThreadJoinedAt { get; private set; }
|
||||||
/// </summary>
|
|
||||||
public DateTimeOffset JoinedAt { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// Gets the guild this user is in.
|
|
||||||
/// </summary>
|
|
||||||
public IGuild Guild { get; }
|
public IGuild Guild { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string Mention => MentionUtils.MentionUser(Id);
|
||||||
|
|
||||||
internal RestThreadUser(BaseDiscordClient discord, IGuild guild, IThreadChannel channel, ulong id)
|
internal RestThreadUser(BaseDiscordClient discord, IGuild guild, IThreadChannel channel, ulong id)
|
||||||
: base(discord, id)
|
: base(discord, id)
|
||||||
{
|
{
|
||||||
@@ -40,7 +37,7 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
internal void Update(Model model)
|
internal void Update(Model model)
|
||||||
{
|
{
|
||||||
JoinedAt = model.JoinTimestamp;
|
ThreadJoinedAt = model.JoinTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -10,16 +10,14 @@ namespace Discord.WebSocket
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a thread user received over the gateway.
|
/// Represents a thread user received over the gateway.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SocketThreadUser : SocketUser, IGuildUser
|
public class SocketThreadUser : SocketUser, IThreadUser, IGuildUser
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="SocketThreadChannel"/> this user is in.
|
/// Gets the <see cref="SocketThreadChannel"/> this user is in.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SocketThreadChannel Thread { get; private set; }
|
public SocketThreadChannel Thread { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// Gets the timestamp for when this user joined this thread.
|
|
||||||
/// </summary>
|
|
||||||
public DateTimeOffset ThreadJoinedAt { get; private set; }
|
public DateTimeOffset ThreadJoinedAt { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -180,8 +178,12 @@ namespace Discord.WebSocket
|
|||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Task RemoveTimeOutAsync(RequestOptions options = null) => GuildUser.RemoveTimeOutAsync(options);
|
public Task RemoveTimeOutAsync(RequestOptions options = null) => GuildUser.RemoveTimeOutAsync(options);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions;
|
IThreadChannel IThreadUser.Thread => Thread;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
IGuild IThreadUser.Guild => Guild;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
IGuild IGuildUser.Guild => Guild;
|
IGuild IGuildUser.Guild => Guild;
|
||||||
@@ -189,6 +191,9 @@ namespace Discord.WebSocket
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
ulong IGuildUser.GuildId => Guild.Id;
|
ulong IGuildUser.GuildId => Guild.Id;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
IReadOnlyCollection<ulong> IGuildUser.RoleIds => GuildUser.Roles.Select(x => x.Id).ToImmutableArray();
|
IReadOnlyCollection<ulong> IGuildUser.RoleIds => GuildUser.Roles.Select(x => x.Id).ToImmutableArray();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user