Fixed a few reference bugs with private messages

This commit is contained in:
RogueException
2015-10-25 04:17:20 -03:00
parent 674c585bee
commit b6d48ca116
3 changed files with 15 additions and 4 deletions

View File

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

View File

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

View File

@@ -145,8 +145,19 @@ namespace Discord
internal Message(DiscordClient client, string id, string channelId, string userId)
: 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;
Embeds = _initialEmbeds;
}