Browse Source

Exposed SocketMessage.Channel

tags/1.0-rc
RogueException 8 years ago
parent
commit
d443ccca13
3 changed files with 17 additions and 15 deletions
  1. +9
    -7
      src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs
  2. +4
    -4
      src/Discord.Net.WebSocket/Entities/Messages/SocketSystemMessage.cs
  3. +4
    -4
      src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs

+ 9
- 7
src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs View File

@@ -10,9 +10,9 @@ namespace Discord.WebSocket
public abstract class SocketMessage : SocketEntity<ulong>, IMessage
{
private long _timestampTicks;

public ulong ChannelId { get; }
public SocketUser Author { get; }
public ISocketMessageChannel Channel { get; }

public string Content { get; private set; }

@@ -28,18 +28,18 @@ namespace Discord.WebSocket

public DateTimeOffset Timestamp => DateTimeUtils.FromTicks(_timestampTicks);

internal SocketMessage(DiscordSocketClient discord, ulong id, ulong channelId, SocketUser author)
internal SocketMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author)
: base(discord, id)
{
ChannelId = channelId;
Channel = channel;
Author = author;
}
internal static SocketMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, Model model)
internal static SocketMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, ISocketMessageChannel channel, Model model)
{
if (model.Type == MessageType.Default)
return SocketUserMessage.Create(discord, state, author, model);
return SocketUserMessage.Create(discord, state, author, channel, model);
else
return SocketSystemMessage.Create(discord, state, author, model);
return SocketSystemMessage.Create(discord, state, author, channel, model);
}
internal virtual void Update(ClientState state, Model model)
{
@@ -55,5 +55,7 @@ namespace Discord.WebSocket
//IMessage
IUser IMessage.Author => Author;
MessageType IMessage.Type => MessageType.Default;

ulong IMessage.ChannelId => Channel.Id;
}
}

+ 4
- 4
src/Discord.Net.WebSocket/Entities/Messages/SocketSystemMessage.cs View File

@@ -6,13 +6,13 @@ namespace Discord.WebSocket
{
public MessageType Type { get; private set; }

internal SocketSystemMessage(DiscordSocketClient discord, ulong id, ulong channelId, SocketUser author)
: base(discord, id, channelId, author)
internal SocketSystemMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author)
: base(discord, id, channel, author)
{
}
internal new static SocketSystemMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, Model model)
internal new static SocketSystemMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, ISocketMessageChannel channel, Model model)
{
var entity = new SocketSystemMessage(discord, model.Id, model.ChannelId, author);
var entity = new SocketSystemMessage(discord, model.Id, channel, author);
entity.Update(state, model);
return entity;
}


+ 4
- 4
src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs View File

@@ -28,13 +28,13 @@ namespace Discord.WebSocket
public override IReadOnlyCollection<IRole> MentionedRoles => _mentionedRoles;
public override IReadOnlyCollection<IUser> MentionedUsers => _mentionedUsers;

internal SocketUserMessage(DiscordSocketClient discord, ulong id, ulong channelId, SocketUser author)
: base(discord, id, channelId, author)
internal SocketUserMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author)
: base(discord, id, channel, author)
{
}
internal new static SocketUserMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, Model model)
internal new static SocketUserMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, ISocketMessageChannel channel, Model model)
{
var entity = new SocketUserMessage(discord, model.Id, model.ChannelId, author);
var entity = new SocketUserMessage(discord, model.Id, channel, author);
entity.Update(state, model);
return entity;
}


Loading…
Cancel
Save