- Removed unnecessary parameter in SocketVoiceServer - Moved SocketVoiceServer into Entities/Voice - Fixed a bug where trying to download the cached guild would throw - Fixed a potential bug where Discord might not give us a port when connecting to voice
This commit is contained in:
committed by
Christopher F
parent
7cfed7ff67
commit
bb4bb13846
@@ -1466,21 +1466,27 @@ namespace Discord.WebSocket
|
||||
|
||||
var data = (payload as JToken).ToObject<VoiceServerUpdateEvent>(_serializer);
|
||||
var guild = State.GetGuild(data.GuildId);
|
||||
var cacheable = new Cacheable<IGuild, ulong>(guild, data.GuildId, guild != null,
|
||||
async () => await ApiClient.GetGuildAsync(data.GuildId).ConfigureAwait(false) as IGuild);
|
||||
var isCached = guild != null;
|
||||
var cachedGuild = new Cacheable<IGuild, ulong>(guild, data.GuildId, isCached,
|
||||
() => Task.FromResult(State.GetGuild(data.GuildId) as IGuild));
|
||||
|
||||
var voiceServer = new SocketVoiceServer(cacheable, data.GuildId, data.Endpoint, data.Token);
|
||||
var voiceServer = new SocketVoiceServer(cachedGuild, data.Endpoint, data.Token);
|
||||
await TimedInvokeAsync(_voiceServerUpdatedEvent, nameof(UserVoiceStateUpdated), voiceServer).ConfigureAwait(false);
|
||||
|
||||
if (guild != null)
|
||||
if (isCached)
|
||||
{
|
||||
string endpoint = data.Endpoint.Substring(0, data.Endpoint.LastIndexOf(':'));
|
||||
var endpoint = data.Endpoint;
|
||||
|
||||
//Only strip out the port if the endpoint contains it
|
||||
var portBegin = endpoint.LastIndexOf(':');
|
||||
if (portBegin > 0)
|
||||
endpoint = endpoint.Substring(0, portBegin);
|
||||
|
||||
var _ = guild.FinishConnectAudio(endpoint, data.Token).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await UnknownGuildAsync(type, data.GuildId).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Discord.WebSocket
|
||||
public string Endpoint { get; private set; }
|
||||
public string Token { get; private set; }
|
||||
|
||||
internal SocketVoiceServer(Cacheable<IGuild, ulong> guild, ulong guildId, string endpoint, string token)
|
||||
internal SocketVoiceServer(Cacheable<IGuild, ulong> guild, string endpoint, string token)
|
||||
{
|
||||
Guild = guild;
|
||||
Endpoint = endpoint;
|
||||
Reference in New Issue
Block a user