Example #1
0
        public static SimpleGuild CreateGuild(SharedModels.Guild guild)
        {
            var sg = new SimpleGuild()
            {
                Id         = guild.Id,
                Name       = guild.Name,
                ImageURL   = "https://cdn.discordapp.com/icons/" + guild.Id + "/" + guild.Icon + ".png",
                IsDM       = false,
                IsMuted    = LocalState.GuildSettings.ContainsKey(guild.Id) ? LocalState.GuildSettings[guild.Id].raw.Muted : false,
                IsUnread   = false, //Will Change if true
                IsValid    = true,  //Will change if false
                IsSelected = false
            };

            foreach (var chn in LocalState.Guilds[guild.Id].channels.Values)
            {
                if (LocalState.RPC.ContainsKey(chn.raw.Id))
                {
                    ReadState readstate = LocalState.RPC[chn.raw.Id];
                    sg.NotificationCount += readstate.MentionCount;
                    var StorageChannel = LocalState.Guilds[sg.Id].channels[chn.raw.Id].raw;
                    if (readstate.LastMessageId != StorageChannel.LastMessageId && !sg.IsMuted)
                    {
                        sg.IsUnread = true;
                    }
                }
            }
            return(sg);
        }
Example #2
0
 /// <summary>
 /// Create LocalModel based on API model
 /// </summary>
 /// <param name="guild">API model</param>
 public Guild(SharedModels.Guild guild)
 {
     Raw      = guild;
     Position = 0;
 }
Example #3
0
 /// <summary>
 /// Create blank guild object
 /// </summary>
 public Guild()
 {
     Raw      = new SharedModels.Guild();
     Position = 0;
 }