Browse Source

Renamed RelationshipAdd event to RelationshipAdded and made null check create none relationship if an existing relationship didn't exist

pull/745/head
ObsidianMinor 8 years ago
parent
commit
9e5e20563c
3 changed files with 5 additions and 3 deletions
  1. +1
    -1
      src/Discord.Net.WebSocket/DiscordSocketClient.Events.cs
  2. +1
    -1
      src/Discord.Net.WebSocket/DiscordSocketClient.cs
  3. +3
    -1
      src/Discord.Net.WebSocket/Entities/Users/SocketRelationship.cs

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

@@ -217,7 +217,7 @@ namespace Discord.WebSocket
private readonly AsyncEvent<Func<SocketGroupUser, Task>> _recipientRemovedEvent = new AsyncEvent<Func<SocketGroupUser, Task>>(); private readonly AsyncEvent<Func<SocketGroupUser, Task>> _recipientRemovedEvent = new AsyncEvent<Func<SocketGroupUser, Task>>();
// relationships // relationships
public event Func<SocketRelationship, SocketRelationship, Task> RelationshipAdd
public event Func<SocketRelationship, SocketRelationship, Task> RelationshipAdded
{ {
add { _relationshipAddedEvent.Add(value); } add { _relationshipAddedEvent.Add(value); }
remove { _relationshipAddedEvent.Remove(value); } remove { _relationshipAddedEvent.Remove(value); }


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

@@ -1509,7 +1509,7 @@ namespace Discord.WebSocket
await _gatewayLogger.DebugAsync("Received Dispatch (RELATIONSHIP_ADD)").ConfigureAwait(false); await _gatewayLogger.DebugAsync("Received Dispatch (RELATIONSHIP_ADD)").ConfigureAwait(false);


var addedModel = (payload as JToken).ToObject<Relationship>(_serializer); var addedModel = (payload as JToken).ToObject<Relationship>(_serializer);
var before = State.GetRelationship(addedModel.Id);
var before = State.GetRelationship(addedModel.Id) ?? SocketRelationship.Create(this, State, new Relationship { Id = addedModel.Id, Type = RelationshipType.None, User = addedModel.User });
var after = AddRelationship(addedModel, State); var after = AddRelationship(addedModel, State);


await _relationshipAddedEvent.InvokeAsync(before, after); await _relationshipAddedEvent.InvokeAsync(before, after);


+ 3
- 1
src/Discord.Net.WebSocket/Entities/Users/SocketRelationship.cs View File

@@ -1,7 +1,9 @@
using Model = Discord.API.Relationship;
using System.Diagnostics;
using Model = Discord.API.Relationship;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
[DebuggerDisplay("{Type} - {User}")]
public class SocketRelationship : IRelationship public class SocketRelationship : IRelationship
{ {
public RelationshipType Type { get; internal set; } public RelationshipType Type { get; internal set; }


Loading…
Cancel
Save