From 3475bd8d6f8521d23efb4978fc902496cb5fa658 Mon Sep 17 00:00:00 2001
From: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
Date: Thu, 27 Jan 2022 14:51:30 +0100
Subject: [PATCH] Add missing IThreadUser interface (#2055)
* Implement
* Add IMentionable to RestThreadUser
* Rather move mentionable to interface for consistency.
* Further consistency
---
.../Entities/Users/IThreadUser.cs | 25 +++++++++++++++++++
.../Entities/Users/RestThreadUser.cs | 21 +++++++---------
.../Entities/Users/SocketThreadUser.cs | 15 +++++++----
3 files changed, 44 insertions(+), 17 deletions(-)
create mode 100644 src/Discord.Net.Core/Entities/Users/IThreadUser.cs
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();