internal static RestGuildSnapshot Create(BaseDiscordClient discord, Model model) { RestGuildSnapshot entity = new RestGuildSnapshot { Name = model.Name, AFKTimeout = model.AFKTimeout, DefaultMessageNotifications = model.DefaultMessageNotifications, Description = model.Description, ExplicitContentFilter = model.ExplicitContentFilter, IconHash = model.IconHash, PreferredLocale = model.PreferredLocale, Region = model.Region, SystemChannelFlags = model.SystemChannelFlags, VerificationLevel = model.VerificationLevel }; if (model.AFKChannelId.HasValue) { entity.AFKChannelId = model.AFKChannelId.Value; } if (model.SystemChannelId.HasValue) { entity.SystemChannelId = model.SystemChannelId.Value; } ImmutableDictionary <int, RestGuildSnapshotRole> .Builder roles = ImmutableDictionary.CreateBuilder <int, RestGuildSnapshotRole>(); if (model.Roles != null) { for (int i = 0; i < model.Roles.Length; i++) { roles[model.Roles[i].Id] = RestGuildSnapshotRole.Create(model.Roles[i]); } } entity._roles = roles.ToImmutable(); ImmutableDictionary <int, RestGuildSnapshotChannel> .Builder channels = ImmutableDictionary.CreateBuilder <int, RestGuildSnapshotChannel>(); if (model.Channels != null) { for (int i = 0; i < model.Channels.Length; i++) { channels[model.Channels[i].Id] = RestGuildSnapshotChannel.Create(model.Channels[i]); } } entity._channels = channels.ToImmutable(); return(entity); }
internal void Update(BaseDiscordClient discord, Model model, bool withSnapshot) { Code = model.Code; Name = model.Name; Description = model.Description; UsageCount = model.UsageCount; CreatorId = model.CreatorId; Creator = RestUser.Create(discord, model.Creator); SourceGuildId = model.SourceGuildId; CreatedAt = model.CreatedAt; UpdatedAt = model.UpdatedAt; if (withSnapshot) { Snapshot = RestGuildSnapshot.Create(discord, (model as GuildTemplateSnapshotJson).Snapshot); } }