Fixed null RestMessage.Author

This commit is contained in:
RogueException
2016-10-06 05:43:01 -03:00
parent 9e982ccd4a
commit b600763071
3 changed files with 10 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ namespace Discord.Rest
private long _timestampTicks;
public ulong ChannelId { get; }
public IUser Author { get; }
public RestUser Author { get; }
public string Content { get; private set; }
@@ -28,10 +28,11 @@ namespace Discord.Rest
public DateTimeOffset Timestamp => DateTimeUtils.FromTicks(_timestampTicks);
internal RestMessage(BaseDiscordClient discord, ulong id, ulong channelId)
internal RestMessage(BaseDiscordClient discord, ulong id, ulong channelId, RestUser author)
: base(discord, id)
{
ChannelId = channelId;
Author = author;
}
internal static RestMessage Create(BaseDiscordClient discord, Model model)
{
@@ -58,6 +59,7 @@ namespace Discord.Rest
public override string ToString() => Content;
MessageType IMessage.Type => MessageType.Default;
IUser IMessage.Author => Author;
IReadOnlyCollection<IAttachment> IMessage.Attachments => Attachments;
IReadOnlyCollection<IEmbed> IMessage.Embeds => Embeds;
IReadOnlyCollection<IRole> IMessage.MentionedRoles => MentionedRoles;

View File

@@ -8,13 +8,13 @@ namespace Discord.Rest
{
public MessageType Type { get; private set; }
internal RestSystemMessage(BaseDiscordClient discord, ulong id, ulong channelId)
: base(discord, id, channelId)
internal RestSystemMessage(BaseDiscordClient discord, ulong id, ulong channelId, RestUser author)
: base(discord, id, channelId, author)
{
}
internal new static RestSystemMessage Create(BaseDiscordClient discord, Model model)
{
var entity = new RestSystemMessage(discord, model.Id, model.ChannelId);
var entity = new RestSystemMessage(discord, model.Id, model.ChannelId, RestUser.Create(discord, model.Author.Value));
entity.Update(model);
return entity;
}

View File

@@ -33,13 +33,13 @@ namespace Discord.Rest
public override IReadOnlyCollection<RestRole> MentionedRoles => _mentionedRoles;
public override IReadOnlyCollection<RestUser> MentionedUsers => _mentionedUsers;
internal RestUserMessage(BaseDiscordClient discord, ulong id, ulong channelId)
: base(discord, id, channelId)
internal RestUserMessage(BaseDiscordClient discord, ulong id, ulong channelId, RestUser author)
: base(discord, id, channelId, author)
{
}
internal new static RestUserMessage Create(BaseDiscordClient discord, Model model)
{
var entity = new RestUserMessage(discord, model.Id, model.ChannelId);
var entity = new RestUserMessage(discord, model.Id, model.ChannelId, RestUser.Create(discord, model.Author.Value));
entity.Update(model);
return entity;
}