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); } }
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.Client = this; tempChannel.Name = message["d"]["name"].ToString(); tempChannel.Type = message["d"]["type"].ToObject<ChannelType>(); if (tempChannel.Type == ChannelType.Voice && !message["d"]["bitrate"].IsNullOrEmpty()) tempChannel.Bitrate = message["d"]["bitrate"].ToObject<int>(); tempChannel.ID = message["d"]["id"].ToString(); tempChannel.Parent = foundServer; 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.Client = this; tempPrivate.ID = message["d"]["id"].ToString(); DiscordMember recipient = ServersList.Find(x => x.GetMemberByKey(message["d"]["recipient"]["id"].ToString()) != null).GetMemberByKey(message["d"]["recipient"]["id"].ToString()); tempPrivate.Recipient = recipient; 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"].ToObject<ChannelType>(); tempChannel.ID = message["d"]["id"].ToString(); tempChannel.parent = foundServer; 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(); DiscordMember recipient = ServersList.Find(x => x.members.Find(y => y.ID == message["d"]["recipient"]["id"].ToString()) != null).members.Find(x => x.ID == message["d"]["recipient"]["id"].ToString()); tempPrivate.recipient = recipient; PrivateChannels.Add(tempPrivate); DiscordPrivateChannelEventArgs fak = new DiscordPrivateChannelEventArgs { ChannelType = DiscordChannelCreateType.PRIVATE, ChannelCreated = tempPrivate }; if (PrivateChannelCreated != null) PrivateChannelCreated(this, fak); } }