Request offline users on connect
This commit is contained in:
@@ -10,8 +10,8 @@ namespace Discord.API.Client.GatewaySocket
|
||||
object IWebSocketMessage.Payload => this;
|
||||
bool IWebSocketMessage.IsPrivate => false;
|
||||
|
||||
[JsonProperty("guild_id"), JsonConverter(typeof(LongStringConverter))]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("guild_id"), JsonConverter(typeof(LongStringArrayConverter))]
|
||||
public ulong[] GuildId { get; set; }
|
||||
[JsonProperty("query")]
|
||||
public string Query { get; set; }
|
||||
[JsonProperty("limit")]
|
||||
|
||||
@@ -479,12 +479,16 @@ namespace Discord
|
||||
PrivateUser.Update(data.User);
|
||||
CurrentUser = new Profile(this, data.User.Id);
|
||||
CurrentUser.Update(data.User);
|
||||
|
||||
List<ulong> largeServers = new List<ulong>();
|
||||
foreach (var model in data.Guilds)
|
||||
{
|
||||
if (model.Unavailable != true)
|
||||
{
|
||||
var server = AddServer(model.Id);
|
||||
server.Update(model);
|
||||
if (model.IsLarge)
|
||||
largeServers.Add(server.Id);
|
||||
}
|
||||
}
|
||||
foreach (var model in data.PrivateChannels)
|
||||
@@ -492,6 +496,7 @@ namespace Discord
|
||||
var channel = AddPrivateChannel(model.Id, model.Recipient.Id);
|
||||
channel.Update(model);
|
||||
}
|
||||
GatewaySocket.SendRequestMembers(largeServers, "", 0);
|
||||
if (Config.LogLevel >= LogSeverity.Verbose)
|
||||
{
|
||||
stopwatch.Stop();
|
||||
|
||||
@@ -501,10 +501,6 @@ namespace Discord
|
||||
var response = await Client.ClientAPI.Send(request).ConfigureAwait(false);
|
||||
return response.Pruned;
|
||||
}
|
||||
|
||||
/// <summary>When Config.UseLargeThreshold is enabled, running this command will request the Discord server to provide you with all offline users for this server.</summary>
|
||||
public void RequestOfflineUsers()
|
||||
=> Client.GatewaySocket.SendRequestMembers(Id, "", 0);
|
||||
#endregion
|
||||
|
||||
internal Server Clone()
|
||||
|
||||
@@ -8,6 +8,7 @@ using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -179,8 +180,8 @@ namespace Discord.Net.WebSockets
|
||||
});
|
||||
public void SendUpdateVoice(ulong? serverId, ulong? channelId, bool isSelfMuted, bool isSelfDeafened)
|
||||
=> QueueMessage(new UpdateVoiceCommand { GuildId = serverId, ChannelId = channelId, IsSelfMuted = isSelfMuted, IsSelfDeafened = isSelfDeafened });
|
||||
public void SendRequestMembers(ulong serverId, string query, int limit)
|
||||
=> QueueMessage(new RequestMembersCommand { GuildId = serverId, Query = query, Limit = limit });
|
||||
public void SendRequestMembers(IEnumerable<ulong> serverId, string query, int limit)
|
||||
=> QueueMessage(new RequestMembersCommand { GuildId = serverId.ToArray(), Query = query, Limit = limit });
|
||||
|
||||
//Cancel if either DiscordClient.Disconnect is called, data socket errors or timeout is reached
|
||||
public override void WaitForConnection(CancellationToken cancelToken)
|
||||
|
||||
Reference in New Issue
Block a user