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