Example #1
0
 public Role(ulong roleId, Discord.Rest.RoleEditInfo info)
 {
     RoleId      = roleId;
     Color       = info.Color?.ToString();
     Mentionable = info.Mentionable ?? false;
     IsHoisted   = info.Hoist ?? false;
     Name        = info.Name;
     PermsValue  = info.Permissions?.RawValue ?? 0;
 }
        internal static RoleUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            API.AuditLogChangeJson[] changes = entry.Changes;

            API.AuditLogChangeJson colorModel       = changes.FirstOrDefault(x => x.ChangedProperty == "color");
            API.AuditLogChangeJson mentionableModel = changes.FirstOrDefault(x => x.ChangedProperty == "mentionable");
            API.AuditLogChangeJson hoistModel       = changes.FirstOrDefault(x => x.ChangedProperty == "hoist");
            API.AuditLogChangeJson nameModel        = changes.FirstOrDefault(x => x.ChangedProperty == "name");
            API.AuditLogChangeJson permissionsModel = changes.FirstOrDefault(x => x.ChangedProperty == "permissions");

            uint?oldColorRaw        = colorModel?.OldValue?.ToObject <uint>(discord.ApiClient.Serializer),
                newColorRaw         = colorModel?.NewValue?.ToObject <uint>(discord.ApiClient.Serializer);
            bool?oldMentionable     = mentionableModel?.OldValue?.ToObject <bool>(discord.ApiClient.Serializer),
                newMentionable      = mentionableModel?.NewValue?.ToObject <bool>(discord.ApiClient.Serializer);
            bool?oldHoist           = hoistModel?.OldValue?.ToObject <bool>(discord.ApiClient.Serializer),
                newHoist            = hoistModel?.NewValue?.ToObject <bool>(discord.ApiClient.Serializer);
            string oldName          = nameModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer),
                   newName          = nameModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            ulong?oldPermissionsRaw = permissionsModel?.OldValue?.ToObject <ulong>(discord.ApiClient.Serializer),
                 newPermissionsRaw  = permissionsModel?.NewValue?.ToObject <ulong>(discord.ApiClient.Serializer);

            Color?oldColor = null,
                 newColor  = null;
            GuildPermissions?oldPermissions = null,
                            newPermissions  = null;

            if (oldColorRaw.HasValue)
            {
                oldColor = new Color(oldColorRaw.Value);
            }
            if (newColorRaw.HasValue)
            {
                newColor = new Color(newColorRaw.Value);
            }
            if (oldPermissionsRaw.HasValue)
            {
                oldPermissions = new GuildPermissions(oldPermissionsRaw.Value);
            }
            if (newPermissionsRaw.HasValue)
            {
                newPermissions = new GuildPermissions(newPermissionsRaw.Value);
            }

            RoleEditInfo oldProps = new RoleEditInfo(oldColor, oldMentionable, oldHoist, oldName, oldPermissions);
            RoleEditInfo newProps = new RoleEditInfo(newColor, newMentionable, newHoist, newName, newPermissions);

            return(new RoleUpdateAuditLogData(entry.TargetId.Value, oldProps, newProps));
        }
 private RoleUpdateAuditLogData(ulong id, RoleEditInfo oldProps, RoleEditInfo newProps)
 {
     RoleId = id;
     Before = oldProps;
     After  = newProps;
 }
Example #4
0
 private RoleCreateAuditLogData(ulong id, RoleEditInfo props)
 {
     RoleId     = id;
     Properties = props;
 }