private void StoreMessage(MessageCreateEvent mce) { lock (Sync) { MemoryMessageChannel channel = Channels.FirstOrDefault(c => mce.ChannelId.Equals(mce.ChannelId)); if (channel == null) { return; // This is basically an invalid state } Messages.Add(new MemoryMessage(channel, mce)); } }
private void DeleteChannel(ChannelDeleteEvent cde) { lock (Sync) { MemoryMessageChannel channel = Channels.FirstOrDefault(c => cde.ChannelId.Equals(c.ChannelId)); if (channel == null) { return; } Channels.Remove(channel); Messages.RemoveAll(m => m.Channel.Equals(channel)); } }
public MemoryMessage(MemoryMessageChannel channel, MessageCreateEvent mce) { if (mce == null) { throw new ArgumentNullException(nameof(mce)); } MessageId = mce.MessageId; Channel = channel ?? throw new ArgumentNullException(nameof(channel)); Sender = new MemoryMessageUser(mce); Text = mce.Text; IsAction = mce.IsAction; Created = mce.DateTime; }