Skip to content

Commit 8b92969

Browse files
authored
yippee (#3021)
1 parent dfe679c commit 8b92969

File tree

15 files changed

+36
-2
lines changed

15 files changed

+36
-2
lines changed

src/Discord.Net.Core/Entities/Channels/IChannel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ namespace Discord
88
/// </summary>
99
public interface IChannel : ISnowflakeEntity
1010
{
11+
/// <summary>
12+
/// Get the type of this channel.
13+
/// </summary>
14+
ChannelType ChannelType { get; }
15+
1116
/// <summary>
1217
/// Gets the name of this channel.
1318
/// </summary>

src/Discord.Net.Rest/Entities/Channels/RestChannel.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ namespace Discord.Rest
1212
public class RestChannel : RestEntity<ulong>, IChannel, IUpdateable
1313
{
1414
#region RestChannel
15+
16+
/// <inheritdoc />
17+
public ChannelType ChannelType { get; internal set; }
18+
1519
/// <inheritdoc />
1620
public virtual DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
1721

@@ -68,7 +72,11 @@ internal static IRestPrivateChannel CreatePrivate(BaseDiscordClient discord, Mod
6872
_ => throw new InvalidOperationException($"Unexpected channel type: {model.Type}"),
6973
};
7074
}
71-
internal virtual void Update(Model model) { }
75+
76+
internal virtual void Update(Model model)
77+
{
78+
ChannelType = model.Type;
79+
}
7280

7381
/// <inheritdoc />
7482
public virtual Task UpdateAsync(RequestOptions options = null) => Task.Delay(0);

src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ internal RestDMChannel(BaseDiscordClient discord, ulong id, ulong? recipientId)
4747
}
4848
internal override void Update(Model model)
4949
{
50+
base.Update(model);
51+
5052
if(model.Recipients.IsSpecified)
5153
Recipient?.Update(model.Recipients.Value[0]);
5254
}

src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ internal RestGroupChannel(BaseDiscordClient discord, ulong id)
4141
}
4242
internal override void Update(Model model)
4343
{
44+
base.Update(model);
4445
if (model.Name.IsSpecified)
4546
Name = model.Name.Value;
4647
if (model.Icon.IsSpecified)

src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ internal static RestGuildChannel Create(BaseDiscordClient discord, IGuild guild,
5353
}
5454
internal override void Update(Model model)
5555
{
56+
base.Update(model);
5657
Name = model.Name.Value;
5758

5859
if (model.Position.IsSpecified)

src/Discord.Net.WebSocket/Entities/Channels/SocketChannel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ namespace Discord.WebSocket
1414
public abstract class SocketChannel : SocketEntity<ulong>, IChannel
1515
{
1616
#region SocketChannel
17+
/// <inheritdoc />
18+
public ChannelType ChannelType { get; internal set; }
19+
1720
/// <summary>
1821
/// Gets when the channel is created.
1922
/// </summary>
@@ -38,7 +41,11 @@ internal static ISocketPrivateChannel CreatePrivate(DiscordSocketClient discord,
3841
_ => throw new InvalidOperationException($"Unexpected channel type: {model.Type}"),
3942
};
4043
}
41-
internal abstract void Update(ClientState state, Model model);
44+
45+
internal virtual void Update(ClientState state, Model model)
46+
{
47+
ChannelType = model.Type;
48+
}
4249
#endregion
4350

4451
#region User

src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ internal static SocketDMChannel Create(DiscordSocketClient discord, ClientState
4444
internal override void Update(ClientState state, Model model)
4545
{
4646
Recipient.Update(state, model.Recipients.Value[0]);
47+
base.Update(state, model);
4748
}
4849
internal static SocketDMChannel Create(DiscordSocketClient discord, ClientState state, ulong channelId, API.User recipient)
4950
{

src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ internal static SocketGroupChannel Create(DiscordSocketClient discord, ClientSta
6363
}
6464
internal override void Update(ClientState state, Model model)
6565
{
66+
base.Update(state, model);
6667
if (model.Name.IsSpecified)
6768
Name = model.Name.Value;
6869
if (model.Icon.IsSpecified)

src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ internal static SocketGuildChannel Create(SocketGuild guild, ClientState state,
7070
/// <inheritdoc />
7171
internal override void Update(ClientState state, Model model)
7272
{
73+
base.Update(state, model);
7374
Name = model.Name.Value;
7475
Position = model.Position.GetValueOrDefault(0);
7576

test/Discord.Net.Tests.Unit/MockedEntities/MockedCategoryChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Discord
77
{
88
internal sealed class MockedCategoryChannel : ICategoryChannel
99
{
10+
public ChannelType ChannelType => ChannelType.Category;
1011
public int Position => throw new NotImplementedException();
1112

1213
public IGuild Guild => throw new NotImplementedException();

0 commit comments

Comments
 (0)