예제 #1
0
        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());
        }
예제 #2
0
 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);
 }
예제 #3
0
파일: Client.cs 프로젝트: hujgup/DiscordApi
 public ServerTextChannel GetServerTextChannel(ulong channelId)
 {
     return(ServerTextChannel.Get(channelId, this));
 }
예제 #4
0
파일: Client.cs 프로젝트: hujgup/DiscordApi
 public async Task <ServerTextChannel> GetServerTextChannelAsync(ulong channelId)
 {
     return(await ServerTextChannel.GetAsync(channelId, this));
 }