Browse Source

Merge branch 'docs/faq-n-patches-offline' of https://github.com/Still34/Discord.Net into docs/faq-n-patches-offline

pull/1161/head
Still Hsu 7 years ago
parent
commit
aea067884c
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
6 changed files with 38 additions and 3 deletions
  1. +1
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs
  2. +1
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedField.cs
  3. +7
    -0
      src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
  4. +1
    -1
      src/Discord.Net.WebSocket/DiscordShardedClient.cs
  5. +7
    -0
      src/Discord.Net.WebSocket/DiscordSocketClient.cs
  6. +21
    -0
      src/Discord.Net.WebSocket/SocketVoiceServer.cs

+ 1
- 1
src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs View File

@@ -3,7 +3,7 @@ using System.Diagnostics;
namespace Discord
{
/// <summary>
/// Represents a author field of an <see cref="Embed" />.
/// A author field of an <see cref="Embed" />.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public struct EmbedAuthor


+ 1
- 1
src/Discord.Net.Core/Entities/Messages/EmbedField.cs View File

@@ -3,7 +3,7 @@ using System.Diagnostics;
namespace Discord
{
/// <summary>
/// Represents a field for an <see cref="Embed" />.
/// A field for an <see cref="Embed" />.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public struct EmbedField


+ 7
- 0
src/Discord.Net.WebSocket/BaseSocketClient.Events.cs View File

@@ -165,6 +165,13 @@ namespace Discord.WebSocket
remove { _userVoiceStateUpdatedEvent.Remove(value); }
}
internal readonly AsyncEvent<Func<SocketUser, SocketVoiceState, SocketVoiceState, Task>> _userVoiceStateUpdatedEvent = new AsyncEvent<Func<SocketUser, SocketVoiceState, SocketVoiceState, Task>>();
/// <summary> Fired when the bot connects to a Discord voice server. </summary>
public event Func<SocketVoiceServer, Task> VoiceServerUpdated
{
add { _voiceServerUpdatedEvent.Add(value); }
remove { _voiceServerUpdatedEvent.Remove(value); }
}
internal readonly AsyncEvent<Func<SocketVoiceServer, Task>> _voiceServerUpdatedEvent = new AsyncEvent<Func<SocketVoiceServer, Task>>();
/// <summary> Fired when the connected account is updated. </summary>
public event Func<SocketSelfUser, SocketSelfUser, Task> CurrentUserUpdated {
add { _selfUpdatedEvent.Add(value); }


+ 1
- 1
src/Discord.Net.WebSocket/DiscordShardedClient.cs View File

@@ -134,7 +134,7 @@ namespace Discord.WebSocket
private int GetShardIdFor(ulong guildId)
=> (int)((guildId >> 22) % (uint)_totalShards);
public int GetShardIdFor(IGuild guild)
=> GetShardIdFor(guild.Id);
=> GetShardIdFor(guild?.Id ?? 0);
private DiscordSocketClient GetShardFor(ulong guildId)
=> GetShard(GetShardIdFor(guildId));
public DiscordSocketClient GetShardFor(IGuild guild)


+ 7
- 0
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -1479,6 +1479,12 @@ 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 voiceServer = new SocketVoiceServer(cacheable, data.GuildId, data.Endpoint, data.Token);
await TimedInvokeAsync(_voiceServerUpdatedEvent, nameof(UserVoiceStateUpdated), voiceServer).ConfigureAwait(false);

if (guild != null)
{
string endpoint = data.Endpoint.Substring(0, data.Endpoint.LastIndexOf(':'));
@@ -1489,6 +1495,7 @@ namespace Discord.WebSocket
await UnknownGuildAsync(type, data.GuildId).ConfigureAwait(false);
return;
}

}
break;



+ 21
- 0
src/Discord.Net.WebSocket/SocketVoiceServer.cs View File

@@ -0,0 +1,21 @@
using System.Diagnostics;

namespace Discord.WebSocket
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketVoiceServer
{
public Cacheable<IGuild, ulong> Guild { get; private set; }
public string Endpoint { get; private set; }
public string Token { get; private set; }

internal SocketVoiceServer(Cacheable<IGuild, ulong> guild, ulong guildId, string endpoint, string token)
{
Guild = guild;
Endpoint = endpoint;
Token = token;
}

private string DebuggerDisplay => $"SocketVoiceServer ({Guild.Id})";
}
}

Loading…
Cancel
Save