Browse Source

Merge branch 'dev' into docs/faq-n-patches-offline

pull/1161/head
Still Hsu 7 years ago
parent
commit
d74c52873f
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
4 changed files with 23 additions and 5 deletions
  1. +7
    -1
      src/Discord.Net.Rest/API/Common/Message.cs
  2. +4
    -1
      src/Discord.Net.Rest/API/Common/VoiceState.cs
  3. +5
    -1
      src/Discord.Net.WebSocket/API/Gateway/TypingStartEvent.cs
  4. +7
    -2
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 7
- 1
src/Discord.Net.Rest/API/Common/Message.cs View File

@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;


@@ -12,10 +12,16 @@ namespace Discord.API
public MessageType Type { get; set; } public MessageType Type { get; set; }
[JsonProperty("channel_id")] [JsonProperty("channel_id")]
public ulong ChannelId { get; set; } public ulong ChannelId { get; set; }
// ALWAYS sent on WebSocket messages
[JsonProperty("guild_id")]
public Optional<ulong> GuildId { get; set; }
[JsonProperty("webhook_id")] [JsonProperty("webhook_id")]
public Optional<ulong> WebhookId { get; set; } public Optional<ulong> WebhookId { get; set; }
[JsonProperty("author")] [JsonProperty("author")]
public Optional<User> Author { get; set; } public Optional<User> Author { get; set; }
// ALWAYS sent on WebSocket messages
[JsonProperty("member")]
public Optional<GuildMember> Member { get; set; }
[JsonProperty("content")] [JsonProperty("content")]
public Optional<string> Content { get; set; } public Optional<string> Content { get; set; }
[JsonProperty("timestamp")] [JsonProperty("timestamp")]


+ 4
- 1
src/Discord.Net.Rest/API/Common/VoiceState.cs View File

@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Newtonsoft.Json; using Newtonsoft.Json;


namespace Discord.API namespace Discord.API
@@ -11,6 +11,9 @@ namespace Discord.API
public ulong? ChannelId { get; set; } public ulong? ChannelId { get; set; }
[JsonProperty("user_id")] [JsonProperty("user_id")]
public ulong UserId { get; set; } public ulong UserId { get; set; }
// ALWAYS sent over WebSocket, never on REST
[JsonProperty("member")]
public Optional<GuildMember> Member { get; set; }
[JsonProperty("session_id")] [JsonProperty("session_id")]
public string SessionId { get; set; } public string SessionId { get; set; }
[JsonProperty("deaf")] [JsonProperty("deaf")]


+ 5
- 1
src/Discord.Net.WebSocket/API/Gateway/TypingStartEvent.cs View File

@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Newtonsoft.Json; using Newtonsoft.Json;


namespace Discord.API.Gateway namespace Discord.API.Gateway
@@ -9,6 +9,10 @@ namespace Discord.API.Gateway
public ulong UserId { get; set; } public ulong UserId { get; set; }
[JsonProperty("channel_id")] [JsonProperty("channel_id")]
public ulong ChannelId { get; set; } public ulong ChannelId { get; set; }
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
[JsonProperty("member")]
public GuildMember Member { get; set; }
[JsonProperty("timestamp")] [JsonProperty("timestamp")]
public int Timestamp { get; set; } public int Timestamp { get; set; }
} }


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

@@ -1104,7 +1104,7 @@ namespace Discord.WebSocket
if (author == null) if (author == null)
{ {
if (guild != null) if (guild != null)
author = guild.AddOrUpdateUser(data.Author.Value); //User has no guild-specific data
author = guild.AddOrUpdateUser(data.Member.Value); //per g250k, we can create an entire member now
else if (channel is SocketGroupChannel) else if (channel is SocketGroupChannel)
author = (channel as SocketGroupChannel).GetOrAddUser(data.Author.Value); author = (channel as SocketGroupChannel).GetOrAddUser(data.Author.Value);
else else
@@ -1374,6 +1374,11 @@ namespace Discord.WebSocket
} }


var user = (channel as SocketChannel).GetUser(data.UserId); var user = (channel as SocketChannel).GetUser(data.UserId);
if (user == null)
{
if (guild != null)
user = guild.AddOrUpdateUser(data.Member);
}
if (user != null) if (user != null)
await TimedInvokeAsync(_userIsTypingEvent, nameof(UserIsTyping), user, channel).ConfigureAwait(false); await TimedInvokeAsync(_userIsTypingEvent, nameof(UserIsTyping), user, channel).ConfigureAwait(false);
} }
@@ -1437,7 +1442,7 @@ namespace Discord.WebSocket
after = SocketVoiceState.Create(null, data); after = SocketVoiceState.Create(null, data);
} }


user = guild.GetUser(data.UserId);
user = guild.GetUser(data.UserId) ?? guild.AddOrUpdateUser(data.Member.Value); //per g250k, this is always sent
if (user == null) if (user == null)
{ {
await UnknownGuildUserAsync(type, data.UserId, guild.Id).ConfigureAwait(false); await UnknownGuildUserAsync(type, data.UserId, guild.Id).ConfigureAwait(false);


Loading…
Cancel
Save