Browse Source

Fixed a few reference bugs with private messages

tags/docs-0.9
RogueException 9 years ago
parent
commit
b6d48ca116
3 changed files with 15 additions and 4 deletions
  1. +1
    -1
      src/Discord.Net/Helpers/Reference.cs
  2. +1
    -1
      src/Discord.Net/Models/Channel.cs
  3. +13
    -2
      src/Discord.Net/Models/Message.cs

+ 1
- 1
src/Discord.Net/Helpers/Reference.cs View File

@@ -32,7 +32,7 @@ namespace Discord
if (v == null && _id != null) if (v == null && _id != null)
{ {
v = _getItem(_id); v = _getItem(_id);
if (v != null)
if (v != null && _onCache != null)
_onCache(v); _onCache(v);
_value = v; _value = v;
} }


+ 1
- 1
src/Discord.Net/Models/Channel.cs View File

@@ -79,7 +79,7 @@ namespace Discord
x => x.AddChannel(this), x => x.AddChannel(this),
x => x.RemoveChannel(this)); x => x.RemoveChannel(this));
_recipient = new Reference<User>(recipientId, _recipient = new Reference<User>(recipientId,
x => _client.Users[x, _server.Id],
x => _client.Users.GetOrAdd(x, _server.Id),
x => x =>
{ {
Name = "@" + x.Name; Name = "@" + x.Name;


+ 13
- 2
src/Discord.Net/Models/Message.cs View File

@@ -145,8 +145,19 @@ namespace Discord
internal Message(DiscordClient client, string id, string channelId, string userId) internal Message(DiscordClient client, string id, string channelId, string userId)
: base(client, id) : base(client, id)
{ {
_channel = new Reference<Channel>(channelId, x => _client.Channels[x], x => x.AddMessage(this), x => x.RemoveMessage(this));
_user = new Reference<User>(userId, x => _client.Users[x]);
_channel = new Reference<Channel>(channelId,
x => _client.Channels[x],
x => x.AddMessage(this),
x => x.RemoveMessage(this));
_user = new Reference<User>(userId,
x =>
{
var channel = Channel;
if (!channel.IsPrivate)
return _client.Users[x, channel.Server.Id];
else
return _client.Users[x, null];
});
Attachments = _initialAttachments; Attachments = _initialAttachments;
Embeds = _initialEmbeds; Embeds = _initialEmbeds;
} }


Loading…
Cancel
Save