internal static List <PinnedMessageData> Create(ulong channelId, [CanBeNull] Client client) { // get message and channel ServerTextChannel c = ServerTextChannel.Get(channelId, client); PinnedMessageData d = c.GetPinnedMessages(client); return(d.Split()); }
private void SetUpMessagePinEvents() { _listener.Listen(data => { var d = (GatewayEvent.ChannelPinsUpdate)data.Data; List <PinnedMessageData> args = PinEventArgs.Create(d.ChannelId, _client); foreach (PinnedMessageData d2 in args) { var b = new EventBubbler <PinEventArgs>(); ServerTextChannel channel; Message msg; Server server; if (d2.Added.Count > 0) { msg = d2.Added[0]; b.Append(msg.OnPin); channel = ServerTextChannel.GetCached(d.ChannelId); if (channel != null) { b.Append(channel.OnMessagePin); server = channel.Server.GetCachedValue(); if (server != null) { b.Append(server.OnMessagePin); } } b.Append(Message.OnPinAny); } else { msg = d2.Removed[0]; b.Append(msg.OnUnpin); channel = ServerTextChannel.GetCached(d.ChannelId); if (channel != null) { b.Append(channel.OnMessageUnpin); server = channel.Server.GetCachedValue(); if (server != null) { b.Append(server.OnMessageUnpin); } } b.Append(Message.OnUnpinAny); } b.Invoke(_client, new PinEventArgs(d2)); } }, ResponseListener.Unbounded, GatewayOpCode.Dispatch, GatewayEvent.ChannelPinsUpdate.Id); }
public ServerTextChannel GetServerTextChannel(ulong channelId) { return(ServerTextChannel.Get(channelId, this)); }
public async Task <ServerTextChannel> GetServerTextChannelAsync(ulong channelId) { return(await ServerTextChannel.GetAsync(channelId, this)); }