public jGuild(SocketGuild guild, bool index) { Id = guild.Id; Name = guild.Name; Channels = new List <jChannel>(); if (index) { List <Thread> threads = new List <Thread>(); foreach (ISocketMessageChannel channel in guild.TextChannels) { //await Program.Log(channel.Name + " Start"); try { var TTh = new Thread(async delegate() { jChannel c = new jChannel() { Id = channel.Id, Name = channel.Name, Users = new List <jUser>() }; MessageCollector.indexChannel(channel, c); Channels.Add(c); }); threads.Add(TTh); TTh.Start(); } catch (Exception ex) { continue; } //await Program.Log(channel.Name + " End"); } while (threads.Exists(item => item.IsAlive)) { Thread.Sleep(5); } } else { foreach (SocketTextChannel channel in guild.TextChannels) { jChannel c = new jChannel() { Id = channel.Id, Name = channel.Name, Users = new List <jUser>() }; Channels.Add(c); } } }
public static string ToJson(this jChannel self) => JsonConvert.SerializeObject(self, MsgCountPlusNET.json.jChannel_Converter.Settings);