diff --git a/src/Discord.Net.Core/Entities/Users/IThreadUser.cs b/src/Discord.Net.Core/Entities/Users/IThreadUser.cs new file mode 100644 index 000000000..f94ca8bb6 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Users/IThreadUser.cs @@ -0,0 +1,25 @@ +using System; + +namespace Discord +{ + /// + /// Represents a Discord thread user. + /// + public interface IThreadUser : IMentionable + { + /// + /// Gets the this user is in. + /// + IThreadChannel Thread { get; } + + /// + /// Gets the timestamp for when this user joined this thread. + /// + DateTimeOffset ThreadJoinedAt { get; } + + /// + /// Gets the guild this thread was created in. + /// + IGuild Guild { get; } + } +} diff --git a/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs b/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs index 82830dafd..fe362e16e 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs @@ -7,23 +7,20 @@ namespace Discord.Rest /// /// Represents a thread user received over the REST api. /// - public class RestThreadUser : RestEntity + public class RestThreadUser : RestEntity, IThreadUser { - /// - /// Gets the this user is in. - /// + /// public IThreadChannel Thread { get; } - /// - /// Gets the timestamp for when this user joined this thread. - /// - public DateTimeOffset JoinedAt { get; private set; } + /// + public DateTimeOffset ThreadJoinedAt { get; private set; } - /// - /// Gets the guild this user is in. - /// + /// public IGuild Guild { get; } + /// + 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; } /// diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs index f7ed2e5f5..ec4270c3e 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs @@ -10,16 +10,14 @@ namespace Discord.WebSocket /// /// Represents a thread user received over the gateway. /// - public class SocketThreadUser : SocketUser, IGuildUser + public class SocketThreadUser : SocketUser, IThreadUser, IGuildUser { /// /// Gets the this user is in. /// public SocketThreadChannel Thread { get; private set; } - /// - /// Gets the timestamp for when this user joined this thread. - /// + /// public DateTimeOffset ThreadJoinedAt { get; private set; } /// @@ -180,8 +178,12 @@ namespace Discord.WebSocket /// public Task RemoveTimeOutAsync(RequestOptions options = null) => GuildUser.RemoveTimeOutAsync(options); + /// - GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions; + IThreadChannel IThreadUser.Thread => Thread; + + /// + IGuild IThreadUser.Guild => Guild; /// IGuild IGuildUser.Guild => Guild; @@ -189,6 +191,9 @@ namespace Discord.WebSocket /// ulong IGuildUser.GuildId => Guild.Id; + /// + GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions; + /// IReadOnlyCollection IGuildUser.RoleIds => GuildUser.Roles.Select(x => x.Id).ToImmutableArray();