diff --git a/src/Discord.Net/DiscordClient.cs b/src/Discord.Net/DiscordClient.cs
index ecfa0f402..56dc9d9e5 100644
--- a/src/Discord.Net/DiscordClient.cs
+++ b/src/Discord.Net/DiscordClient.cs
@@ -758,7 +758,7 @@ namespace Discord
}*/
if (msg == null)
{
- msg = channel.AddMessage(data.Id, data.Author.Id, data.Timestamp.Value);
+ msg = channel.AddMessage(data.Id, user, data.Timestamp.Value);
//nonce = 0;
}
diff --git a/src/Discord.Net/Models/Channel.cs b/src/Discord.Net/Models/Channel.cs
index 011bb5bf8..699d84cc5 100644
--- a/src/Discord.Net/Models/Channel.cs
+++ b/src/Discord.Net/Models/Channel.cs
@@ -240,9 +240,9 @@ namespace Discord
#endregion
#region Messages
- internal Message AddMessage(ulong id, ulong userId, DateTime timestamp)
+ internal Message AddMessage(ulong id, User user, DateTime timestamp)
{
- Message message = new Message(id, this, userId);
+ Message message = new Message(id, this, user);
var cacheLength = Client.Config.MessageCacheSize;
if (cacheLength > 0)
{
@@ -298,13 +298,13 @@ namespace Discord
Message msg = null;
if (useCache)
{
- msg = AddMessage(x.Id, x.Author.Id, x.Timestamp.Value);
+ msg = AddMessage(x.Id, GetUser(x.Author.Id), x.Timestamp.Value);
var user = msg.User;
if (user != null)
user.UpdateActivity(msg.EditedTimestamp ?? msg.Timestamp);
}
else
- msg = new Message(x.Id, this, x.Author.Id);
+ msg = new Message(x.Id, this, GetUser(x.Author.Id));
msg.Update(x);
return msg;
})
@@ -352,7 +352,7 @@ namespace Discord
IsTTS = isTTS
};
var model = await Client.ClientAPI.Send(request).ConfigureAwait(false);
- msg = AddMessage(model.Id, model.Author.Id, model.Timestamp.Value);
+ msg = AddMessage(model.Id, IsPrivate ? Client.PrivateUser : Server.CurrentUser, model.Timestamp.Value);
msg.Update(model);
}
return msg;
@@ -372,7 +372,7 @@ namespace Discord
};
var model = await Client.ClientAPI.Send(request).ConfigureAwait(false);
- var msg = AddMessage(model.Id, model.Author.Id, model.Timestamp.Value);
+ var msg = AddMessage(model.Id, IsPrivate ? Client.PrivateUser : Server.CurrentUser, model.Timestamp.Value);
msg.Update(model);
return msg;
}
diff --git a/src/Discord.Net/Models/Message.cs b/src/Discord.Net/Models/Message.cs
index 43f5cb9d8..569feab0d 100644
--- a/src/Discord.Net/Models/Message.cs
+++ b/src/Discord.Net/Models/Message.cs
@@ -171,9 +171,11 @@ namespace Discord
public ulong Id { get; }
/// Returns the channel this message was sent to.
public Channel Channel { get; }
+ /// Returns the author of this message.
+ public User User { get; }
- /// Returns true if the message was sent as text-to-speech by someone with permissions to do so.
- public bool IsTTS { get; private set; }
+ /// Returns true if the message was sent as text-to-speech by someone with permissions to do so.
+ public bool IsTTS { get; private set; }
/// Returns the state of this message. Only useful if UseMessageQueue is true.
public MessageState State { get; internal set; }
/// Returns the raw content of this message as it was received from the server.
@@ -198,14 +200,12 @@ namespace Discord
/// Returns the server containing the channel this message was sent to.
public Server Server => Channel.Server;
- /// Returns the author of this message.
- public User User => Channel.GetUser(_userId);
- internal Message(ulong id, Channel channel, ulong userId)
+ internal Message(ulong id, Channel channel, User user)
{
Id = id;
Channel = channel;
- _userId = userId;
+ User = user;
Attachments = _initialAttachments;
Embeds = _initialEmbeds;