Esempio n. 1
0
        internal RestMemberRolesUpdatedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry)
        {
            for (var i = 0; i < entry.Changes.Length; i++)
            {
                var change = entry.Changes[i];
                switch (change.Key)
                {
                case "$add":
                {
                    RolesAdded = AuditLogChange <IReadOnlyList <Role> > .Convert <RoleModel[]>(change, x => x.ToReadOnlyList(y => new Role(y))).NewValue;

                    break;
                }

                case "$remove":
                {
                    RolesRemoved = AuditLogChange <IReadOnlyList <Role> > .Convert <RoleModel[]>(change, x => x.ToReadOnlyList(y => new Role(y))).NewValue;

                    break;
                }

                default:
                {
                    client.Log(LogSeverity.Error, $"Unknown change key for {nameof(RestMemberRolesUpdatedAuditLog)}: '{change.Key}'.");
                    break;
                }
                }
            }
        }
Esempio n. 2
0
        internal RoleChanges(RestDiscordClient client, AuditLogEntryModel model)
        {
            for (var i = 0; i < model.Changes.Length; i++)
            {
                var change = model.Changes[i];
                switch (change.Key)
                {
                case "name":
                {
                    Name = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "permissions":
                {
                    Permissions = AuditLogChange <GuildPermissions> .Convert <ulong>(change, x => x);

                    break;
                }

                case "color":
                {
                    Color = AuditLogChange <Color?> .Convert <int>(change, x => x == 0
                                                                   ?(int?)null
                                                                   : x);

                    break;
                }

                case "hoist":
                {
                    IsHoisted = AuditLogChange <bool> .Convert(change);

                    break;
                }

                case "mentionable":
                {
                    IsMentionable = AuditLogChange <bool> .Convert(change);

                    break;
                }

                default:
                {
                    client.Log(LogSeverity.Error, $"Unknown change key for {nameof(RoleChanges)}: '{change.Key}'.");
                    break;
                }
                }
            }
        }
Esempio n. 3
0
        internal OverwriteChanges(RestDiscordClient client, AuditLogEntryModel model)
        {
            for (var i = 0; i < model.Changes.Length; i++)
            {
                var change = model.Changes[i];
                switch (change.Key)
                {
                case "id":
                {
                    TargetId = AuditLogChange <Snowflake> .Convert(change);

                    break;
                }

                case "allow":
                {
                    Allowed = AuditLogChange <ChannelPermissions> .Convert <ulong>(change, x => x);

                    break;
                }

                case "deny":
                {
                    Denied = AuditLogChange <ChannelPermissions> .Convert <ulong>(change, x => x);

                    break;
                }

                case "type":
                {
                    TargetType = AuditLogChange <OverwriteTargetType> .Convert(change);

                    break;
                }

                default:
                {
                    client.Log(LogSeverity.Error, $"Unknown change key for {nameof(OverwriteChanges)}: '{change.Key}'.");
                    break;
                }
                }
            }
        }
Esempio n. 4
0
        internal WebhookChanges(RestDiscordClient client, AuditLogEntryModel model)
        {
            for (var i = 0; i < model.Changes.Length; i++)
            {
                var change = model.Changes[i];
                switch (change.Key)
                {
                case "name":
                {
                    Name = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "type":
                {
                    Type = AuditLogChange <WebhookType> .Convert(change);

                    break;
                }

                case "avatar_hash":
                {
                    AvatarHash = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "channel_id":
                {
                    ChannelId = AuditLogChange <Snowflake> .Convert(change);

                    break;
                }

                default:
                {
                    client.Log(LogSeverity.Error, $"Unknown change key for {nameof(WebhookChanges)}: '{change.Key}'.");
                    break;
                }
                }
            }
        }
Esempio n. 5
0
        internal EmojiChanges(RestDiscordClient client, AuditLogEntryModel model)
        {
            for (var i = 0; i < model.Changes.Length; i++)
            {
                var change = model.Changes[i];
                switch (change.Key)
                {
                case "name":
                {
                    Name = AuditLogChange <string> .Convert(change);

                    break;
                }

                default:
                {
                    client.Log(LogSeverity.Error, $"Unknown change key for {nameof(WebhookChanges)}: '{change.Key}'.");
                    break;
                }
                }
            }
        }
Esempio n. 6
0
        internal MemberChanges(RestDiscordClient client, AuditLogEntryModel model)
        {
            for (var i = 0; i < model.Changes.Length; i++)
            {
                var change = model.Changes[i];
                switch (change.Key)
                {
                case "nick":
                {
                    Nick = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "deaf":
                {
                    IsDeafened = AuditLogChange <bool> .Convert(change);

                    break;
                }

                case "mute":
                {
                    IsMuted = AuditLogChange <bool> .Convert(change);

                    break;
                }

                default:
                {
                    client.Log(LogSeverity.Error, $"Unknown change key for {nameof(MemberChanges)}: '{change.Key}'.");
                    break;
                }
                }
            }
        }
Esempio n. 7
0
        internal ChannelChanges(RestDiscordClient client, AuditLogEntryModel model)
        {
            for (var i = 0; i < model.Changes.Length; i++)
            {
                var change = model.Changes[i];
                switch (change.Key)
                {
                case "name":
                {
                    Name = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "topic":
                {
                    Topic = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "bitrate":
                {
                    Bitrate = AuditLogChange <int> .Convert(change);

                    break;
                }

                case "permission_overwrites":
                {
                    var overwritesBefore = Optional <IReadOnlyList <RestOverwrite> > .Empty;
                    if (change.OldValue.HasValue)
                    {
                        var models = change.OldValue.Value.ToType <OverwriteModel[]>();
                        overwritesBefore = new Optional <IReadOnlyList <RestOverwrite> >(
                            models.ToReadOnlyList((client, model), (x, tuple) =>
                            {
                                var(client, model) = tuple;
                                return(new RestOverwrite(client, model.TargetId.Value, x));
                            }));
                    }

                    var overwritesAfter = Optional <IReadOnlyList <RestOverwrite> > .Empty;
                    if (change.NewValue.HasValue)
                    {
                        var models = change.NewValue.Value.ToType <OverwriteModel[]>();
                        overwritesAfter = new Optional <IReadOnlyList <RestOverwrite> >(
                            models.ToReadOnlyList((client, model), (x, tuple) =>
                            {
                                var(client, model) = tuple;
                                return(new RestOverwrite(client, model.TargetId.Value, x));
                            }));
                    }

                    Overwrites = new AuditLogChange <IReadOnlyList <RestOverwrite> >(overwritesBefore, overwritesAfter);
                    break;
                }

                case "nsfw":
                {
                    IsNsfw = AuditLogChange <bool> .Convert(change);

                    break;
                }

                case "rate_limit_per_user":
                {
                    Slowmode = AuditLogChange <int> .Convert(change);

                    break;
                }

                case "type":
                {
                    Type = AuditLogChange <AuditLogChannelType> .Convert(change);

                    break;
                }

                default:
                {
                    client.Log(LogSeverity.Error, $"Unknown change key for {nameof(ChannelChanges)}: '{change.Key}'.");
                    break;
                }
                }
            }
        }
Esempio n. 8
0
        internal GuildChanges(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry)
        {
            for (var i = 0; i < entry.Changes.Length; i++)
            {
                var change = entry.Changes[i];
                switch (change.Key)
                {
                case "name":
                {
                    Name = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "icon_hash":
                {
                    IconHash = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "splash_hash":
                {
                    SplashHash = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "owner_id":
                {
                    OwnerId = AuditLogChange <Snowflake> .Convert(change);

                    Owner = new AuditLogChange <SnowflakeOptional <RestUser> >(
                        new SnowflakeOptional <RestUser>(new RestUser(client, Array.Find(log.Users, x => x.Id == OwnerId.OldValue.Value)), OwnerId.OldValue.Value),
                        new SnowflakeOptional <RestUser>(new RestUser(client, Array.Find(log.Users, x => x.Id == OwnerId.NewValue.Value)), OwnerId.NewValue.Value));
                    break;
                }

                case "region":
                {
                    VoiceRegionId = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "afk_channel_id":
                {
                    AfkChannelId = AuditLogChange <Snowflake?> .Convert(change);

                    break;
                }

                case "afk_timeout":
                {
                    AfkTimeout = AuditLogChange <int> .Convert(change);

                    break;
                }

                case "mfa_level":
                {
                    MfaLevel = AuditLogChange <MfaLevel> .Convert(change);

                    break;
                }

                case "verification_level":
                {
                    VerificationLevel = AuditLogChange <VerificationLevel> .Convert(change);

                    break;
                }

                case "explicit_content_filter":
                {
                    ContentFilterLevel = AuditLogChange <ContentFilterLevel> .Convert(change);

                    break;
                }

                case "default_message_notifications":
                {
                    DefaultNotificationLevel = AuditLogChange <DefaultNotificationLevel> .Convert(change);

                    break;
                }

                case "vanity_url_code":
                {
                    VanityUrlCode = AuditLogChange <string> .Convert(change);

                    break;
                }

                case "widget_enabled":
                {
                    IsWidgetEnabled = AuditLogChange <bool> .Convert(change);

                    break;
                }

                case "widget_channel_id":
                {
                    WidgetChannelId = AuditLogChange <Snowflake?> .Convert(change);

                    break;
                }

                case "system_channel_id":
                {
                    SystemChannelId = AuditLogChange <Snowflake?> .Convert(change);

                    break;
                }

                default:
                {
                    client.Log(LogSeverity.Error, $"Unknown change key for {nameof(GuildChanges)}: '{change.Key}'.");
                    break;
                }
                }
            }
        }