Skip to content

Commit 3475bd8

Browse files
authored
Add missing IThreadUser interface (#2055)
* Implement * Add IMentionable to RestThreadUser * Rather move mentionable to interface for consistency. * Further consistency
1 parent b14af1c commit 3475bd8

File tree

3 files changed

+44
-17
lines changed

3 files changed

+44
-17
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
3+
namespace Discord
4+
{
5+
/// <summary>
6+
/// Represents a Discord thread user.
7+
/// </summary>
8+
public interface IThreadUser : IMentionable
9+
{
10+
/// <summary>
11+
/// Gets the <see cref="IThreadChannel"/> this user is in.
12+
/// </summary>
13+
IThreadChannel Thread { get; }
14+
15+
/// <summary>
16+
/// Gets the timestamp for when this user joined this thread.
17+
/// </summary>
18+
DateTimeOffset ThreadJoinedAt { get; }
19+
20+
/// <summary>
21+
/// Gets the guild this thread was created in.
22+
/// </summary>
23+
IGuild Guild { get; }
24+
}
25+
}

src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,20 @@ namespace Discord.Rest
77
/// <summary>
88
/// Represents a thread user received over the REST api.
99
/// </summary>
10-
public class RestThreadUser : RestEntity<ulong>
10+
public class RestThreadUser : RestEntity<ulong>, IThreadUser
1111
{
12-
/// <summary>
13-
/// Gets the <see cref="RestThreadChannel"/> this user is in.
14-
/// </summary>
12+
/// <inheritdoc/>
1513
public IThreadChannel Thread { get; }
1614

17-
/// <summary>
18-
/// Gets the timestamp for when this user joined this thread.
19-
/// </summary>
20-
public DateTimeOffset JoinedAt { get; private set; }
15+
/// <inheritdoc/>
16+
public DateTimeOffset ThreadJoinedAt { get; private set; }
2117

22-
/// <summary>
23-
/// Gets the guild this user is in.
24-
/// </summary>
18+
/// <inheritdoc/>
2519
public IGuild Guild { get; }
2620

21+
/// <inheritdoc/>
22+
public string Mention => MentionUtils.MentionUser(Id);
23+
2724
internal RestThreadUser(BaseDiscordClient discord, IGuild guild, IThreadChannel channel, ulong id)
2825
: base(discord, id)
2926
{
@@ -40,7 +37,7 @@ internal static RestThreadUser Create(BaseDiscordClient client, IGuild guild, Mo
4037

4138
internal void Update(Model model)
4239
{
43-
JoinedAt = model.JoinTimestamp;
40+
ThreadJoinedAt = model.JoinTimestamp;
4441
}
4542

4643
/// <summary>

src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ namespace Discord.WebSocket
1010
/// <summary>
1111
/// Represents a thread user received over the gateway.
1212
/// </summary>
13-
public class SocketThreadUser : SocketUser, IGuildUser
13+
public class SocketThreadUser : SocketUser, IThreadUser, IGuildUser
1414
{
1515
/// <summary>
1616
/// Gets the <see cref="SocketThreadChannel"/> this user is in.
1717
/// </summary>
1818
public SocketThreadChannel Thread { get; private set; }
1919

20-
/// <summary>
21-
/// Gets the timestamp for when this user joined this thread.
22-
/// </summary>
20+
/// <inheritdoc/>
2321
public DateTimeOffset ThreadJoinedAt { get; private set; }
2422

2523
/// <summary>
@@ -180,15 +178,22 @@ internal void Update(Model model)
180178

181179
/// <inheritdoc/>
182180
public Task RemoveTimeOutAsync(RequestOptions options = null) => GuildUser.RemoveTimeOutAsync(options);
181+
183182
/// <inheritdoc/>
184-
GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions;
183+
IThreadChannel IThreadUser.Thread => Thread;
184+
185+
/// <inheritdoc/>
186+
IGuild IThreadUser.Guild => Guild;
185187

186188
/// <inheritdoc/>
187189
IGuild IGuildUser.Guild => Guild;
188190

189191
/// <inheritdoc/>
190192
ulong IGuildUser.GuildId => Guild.Id;
191193

194+
/// <inheritdoc/>
195+
GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions;
196+
192197
/// <inheritdoc/>
193198
IReadOnlyCollection<ulong> IGuildUser.RoleIds => GuildUser.Roles.Select(x => x.Id).ToImmutableArray();
194199

0 commit comments

Comments
 (0)