Exemple #1
0
 private void ChannelCreateEvents(JObject message)
 {
     if (message["d"]["is_private"].ToString().ToLower() == "false")
     {
         var foundServer = ServersList.Find(x => x.id == message["d"]["guild_id"].ToString());
         if (foundServer != null)
         {
             DiscordChannel tempChannel = new DiscordChannel();
             tempChannel.name = message["d"]["name"].ToString();
             tempChannel.type = message["d"]["type"].ToString();
             tempChannel.id   = message["d"]["id"].ToString();
             foundServer.channels.Add(tempChannel);
             DiscordChannelCreateEventArgs fae = new DiscordChannelCreateEventArgs();
             fae.ChannelCreated = tempChannel;
             fae.ChannelType    = DiscordChannelCreateType.CHANNEL;
             if (ChannelCreated != null)
             {
                 ChannelCreated(this, fae);
             }
         }
     }
     else
     {
         DiscordPrivateChannel tempPrivate = new DiscordPrivateChannel();
         tempPrivate.id = message["d"]["id"].ToString();
         DiscordRecipient tempRec = new DiscordRecipient();
         tempRec.id            = message["d"]["recipient"]["id"].ToString();
         tempRec.username      = message["d"]["recipient"]["username"].ToString();
         tempPrivate.recipient = tempRec;
         PrivateChannels.Add(tempPrivate);
         DiscordPrivateChannelEventArgs fak = new DiscordPrivateChannelEventArgs {
             ChannelType = DiscordChannelCreateType.PRIVATE, ChannelCreated = tempPrivate
         };
         if (PrivateChannelCreated != null)
         {
             PrivateChannelCreated(this, fak);
         }
     }
 }
 private void ChannelCreateEvents (JObject message)
 {
     if (message["d"]["is_private"].ToString().ToLower() == "false")
     {
         var foundServer = ServersList.Find(x => x.id == message["d"]["guild_id"].ToString());
         if (foundServer != null)
         {
             DiscordChannel tempChannel = new DiscordChannel();
             tempChannel.name = message["d"]["name"].ToString();
             tempChannel.type = message["d"]["type"].ToString();
             tempChannel.id = message["d"]["id"].ToString();
             foundServer.channels.Add(tempChannel);
             DiscordChannelCreateEventArgs fae = new DiscordChannelCreateEventArgs();
             fae.ChannelCreated = tempChannel;
             fae.ChannelType = DiscordChannelCreateType.CHANNEL;
             if (ChannelCreated != null)
                 ChannelCreated(this, fae);
         }
     }
     else
     {
         DiscordPrivateChannel tempPrivate = new DiscordPrivateChannel();
         tempPrivate.id = message["d"]["id"].ToString();
         DiscordRecipient tempRec = new DiscordRecipient();
         tempRec.id = message["d"]["recipient"]["id"].ToString();
         tempRec.username = message["d"]["recipient"]["username"].ToString();
         tempPrivate.recipient = tempRec;
         PrivateChannels.Add(tempPrivate);
         DiscordPrivateChannelEventArgs fak = new DiscordPrivateChannelEventArgs { ChannelType = DiscordChannelCreateType.PRIVATE, ChannelCreated = tempPrivate };
         if (PrivateChannelCreated != null)
             PrivateChannelCreated(this, fak);
     }
 }