internal static RestGuildSnapshotChannel Create(GuildSnapshotChannelJson model)
        {
            RestGuildSnapshotChannel entity = new RestGuildSnapshotChannel
            {
                Bitrate   = model.Bitrate,
                Id        = int.Parse(model.Id.ToString()),
                Name      = model.Name,
                Nsfw      = model.Nsfw,
                Position  = model.Position,
                SlowMode  = model.SlowMode,
                Topic     = model.Topic,
                Type      = model.Type,
                UserLimit = model.UserLimit
            };

            if (model.CategoryId.HasValue)
            {
                entity.CategoryId = model.CategoryId.Value;
            }
            if (model.PermissionOverwrites.IsSpecified)
            {
                entity.PermissionOverwrites = model.PermissionOverwrites.Value.Select(x => RestGuildSnapshotOverwrite.Create(x)).ToArray();
            }

            return(entity);
        }
Пример #2
0
        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);
        }