diff --git a/src/Discord.Net/Common/Entities/Channels/IChannel.cs b/src/Discord.Net/Common/Entities/Channels/IChannel.cs
index 9540f4d26..74ab4a2f2 100644
--- a/src/Discord.Net/Common/Entities/Channels/IChannel.cs
+++ b/src/Discord.Net/Common/Entities/Channels/IChannel.cs
@@ -7,6 +7,8 @@ namespace Discord
{
/// Gets a collection of all users in this channel.
Task> GetUsers();
+ /// Gets a paginated collection of all users in this channel.
+ Task> GetUsers(int limit, int offset = 0);
/// Gets a user in this channel with the provided id.
Task GetUser(ulong id);
}
diff --git a/src/Discord.Net/Discord.Net.csproj b/src/Discord.Net/Discord.Net.csproj
index 6a3f65685..7a34de007 100644
--- a/src/Discord.Net/Discord.Net.csproj
+++ b/src/Discord.Net/Discord.Net.csproj
@@ -26,7 +26,7 @@
pdbonly
true
bin\Release\
- TRACE
+ TRACE;__DEMO__,__DEMO_EXPERIMENTAL__
prompt
4
diff --git a/src/Discord.Net/Rest/Entities/Channels/DMChannel.cs b/src/Discord.Net/Rest/Entities/Channels/DMChannel.cs
index e7e25150b..8d8c5897b 100644
--- a/src/Discord.Net/Rest/Entities/Channels/DMChannel.cs
+++ b/src/Discord.Net/Rest/Entities/Channels/DMChannel.cs
@@ -131,6 +131,8 @@ namespace Discord.Rest
async Task> IChannel.GetUsers()
=> await GetUsers().ConfigureAwait(false);
+ async Task> IChannel.GetUsers(int limit, int offset)
+ => (await GetUsers().ConfigureAwait(false)).Skip(offset).Take(limit);
async Task IChannel.GetUser(ulong id)
=> await GetUser(id).ConfigureAwait(false);
Task IMessageChannel.GetCachedMessage(ulong id)
diff --git a/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs b/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs
index 6373bccc7..1c3f64310 100644
--- a/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs
+++ b/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs
@@ -58,12 +58,7 @@ namespace Discord.Rest
var model = await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false);
Update(model);
}
-
- /// Gets a user in this channel with the given id.
- public abstract Task GetUser(ulong id);
- /// Gets all users in this channel.
- public abstract Task> GetUsers();
-
+
///
public OverwritePermissions? GetPermissionOverwrite(IUser user)
{
@@ -151,18 +146,24 @@ namespace Discord.Rest
///
public override string ToString() => Name;
+ protected abstract Task GetUserInternal(ulong id);
+ protected abstract Task> GetUsersInternal();
+ protected abstract Task> GetUsersInternal(int limit, int offset);
+
IGuild IGuildChannel.Guild => Guild;
async Task IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
=> await CreateInvite(maxAge, maxUses, isTemporary, withXkcd).ConfigureAwait(false);
async Task> IGuildChannel.GetInvites()
=> await GetInvites().ConfigureAwait(false);
async Task> IGuildChannel.GetUsers()
- => await GetUsers().ConfigureAwait(false);
- async Task IGuildChannel.GetUser(ulong id)
- => await GetUser(id).ConfigureAwait(false);
+ => await GetUsersInternal().ConfigureAwait(false);
async Task> IChannel.GetUsers()
- => await GetUsers().ConfigureAwait(false);
+ => await GetUsersInternal().ConfigureAwait(false);
+ async Task> IChannel.GetUsers(int limit, int offset)
+ => await GetUsersInternal(limit, offset).ConfigureAwait(false);
+ async Task IGuildChannel.GetUser(ulong id)
+ => await GetUserInternal(id).ConfigureAwait(false);
async Task IChannel.GetUser(ulong id)
- => await GetUser(id).ConfigureAwait(false);
+ => await GetUserInternal(id).ConfigureAwait(false);
}
}
diff --git a/src/Discord.Net/Rest/Entities/Channels/TextChannel.cs b/src/Discord.Net/Rest/Entities/Channels/TextChannel.cs
index 9ab247c9a..9fef515f2 100644
--- a/src/Discord.Net/Rest/Entities/Channels/TextChannel.cs
+++ b/src/Discord.Net/Rest/Entities/Channels/TextChannel.cs
@@ -39,19 +39,27 @@ namespace Discord.Rest
Update(model);
}
- public override async Task GetUser(ulong id)
+ /// Gets a user in this channel with the given id.
+ public async Task GetUser(ulong id)
{
var user = await Guild.GetUser(id).ConfigureAwait(false);
if (user != null && Permissions.GetValue(Permissions.ResolveChannel(user, this, user.GuildPermissions.RawValue), ChannelPermission.ReadMessages))
return user;
return null;
}
- public override async Task> GetUsers()
+ /// Gets all users in this channel.
+ public async Task> GetUsers()
{
var users = await Guild.GetUsers().ConfigureAwait(false);
return users.Where(x => Permissions.GetValue(Permissions.ResolveChannel(x, this, x.GuildPermissions.RawValue), ChannelPermission.ReadMessages));
}
-
+ /// Gets a paginated collection of users in this channel.
+ public async Task> GetUsers(int limit, int offset)
+ {
+ var users = await Guild.GetUsers(limit, offset).ConfigureAwait(false);
+ return users.Where(x => Permissions.GetValue(Permissions.ResolveChannel(x, this, x.GuildPermissions.RawValue), ChannelPermission.ReadMessages));
+ }
+
///
public async Task> GetMessages(int limit = DiscordConfig.MaxMessagesPerBatch)
{
@@ -107,6 +115,11 @@ namespace Discord.Rest
private string DebuggerDisplay => $"{Name} ({Id}, Text)";
+
+ protected override Task GetUserInternal(ulong id) => GetUser(id);
+ protected override Task> GetUsersInternal() => GetUsers();
+ protected override Task> GetUsersInternal(int limit, int offset) => GetUsers(limit, offset);
+
IEnumerable IMessageChannel.CachedMessages => Array.Empty();
Task IMessageChannel.GetCachedMessage(ulong id)
diff --git a/src/Discord.Net/Rest/Entities/Channels/VoiceChannel.cs b/src/Discord.Net/Rest/Entities/Channels/VoiceChannel.cs
index 032e5eea1..eeab53ebf 100644
--- a/src/Discord.Net/Rest/Entities/Channels/VoiceChannel.cs
+++ b/src/Discord.Net/Rest/Entities/Channels/VoiceChannel.cs
@@ -34,8 +34,9 @@ namespace Discord.Rest
Update(model);
}
- public override Task GetUser(ulong id) { throw new NotSupportedException(); }
- public override Task> GetUsers() { throw new NotSupportedException(); }
+ protected override Task GetUserInternal(ulong id) { throw new NotSupportedException(); }
+ protected override Task> GetUsersInternal() { throw new NotSupportedException(); }
+ protected override Task> GetUsersInternal(int limit, int offset) { throw new NotSupportedException(); }
private string DebuggerDisplay => $"{Name} ({Id}, Voice)";
}
diff --git a/src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs b/src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs
index 142295310..89c2f9047 100644
--- a/src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs
+++ b/src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs
@@ -124,6 +124,8 @@ namespace Discord.WebSocket
Task> IChannel.GetUsers()
=> Task.FromResult(Users);
+ Task> IChannel.GetUsers(int limit, int offset)
+ => Task.FromResult(Users.Skip(offset).Take(limit));
Task IChannel.GetUser(ulong id)
=> Task.FromResult(GetUser(id));
Task IMessageChannel.GetCachedMessage(ulong id)
diff --git a/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs b/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs
index afd0b17d9..6b3427a8c 100644
--- a/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs
+++ b/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs
@@ -147,6 +147,8 @@ namespace Discord.WebSocket
=> Task.FromResult(GetUser(id));
Task> IChannel.GetUsers()
=> Task.FromResult>(Users);
+ Task> IChannel.GetUsers(int limit, int offset)
+ => Task.FromResult>(Users.Skip(offset).Take(limit));
Task IChannel.GetUser(ulong id)
=> Task.FromResult(GetUser(id));
Task IUpdateable.Update()