Exemplo n.º 1
0
        internal static MemberUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            var changes = entry.Changes;

            var nickModel = changes.FirstOrDefault(x => x.ChangedProperty == "nick");
            var deafModel = changes.FirstOrDefault(x => x.ChangedProperty == "deaf");
            var muteModel = changes.FirstOrDefault(x => x.ChangedProperty == "mute");

            string oldNick = nickModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer),
                   newNick = nickModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            bool?oldDeaf   = deafModel?.OldValue?.ToObject <bool>(discord.ApiClient.Serializer),
                newDeaf    = deafModel?.NewValue?.ToObject <bool>(discord.ApiClient.Serializer);
            bool?oldMute   = muteModel?.OldValue?.ToObject <bool>(discord.ApiClient.Serializer),
                newMute    = muteModel?.NewValue?.ToObject <bool>(discord.ApiClient.Serializer);

            var targetInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
            var user       = RestUser.Create(discord, targetInfo);

            var before = new MemberInfo(oldNick, oldDeaf, oldMute);
            var after  = new MemberInfo(newNick, newDeaf, newMute);

            return(new MemberUpdateAuditLogData(user, before, after));
        }
Exemplo n.º 2
0
 internal void Update(Model model)
 {
     if (ChannelId != model.ChannelId)
     {
         ChannelId = model.ChannelId;
     }
     if (model.Avatar.IsSpecified)
     {
         AvatarId = model.Avatar.Value;
     }
     if (model.Creator.IsSpecified)
     {
         Creator = RestUser.Create(Discord, model.Creator.Value);
     }
     if (model.GuildId.IsSpecified)
     {
         GuildId = model.GuildId.Value;
     }
     if (model.Name.IsSpecified)
     {
         Name = model.Name.Value;
     }
 }
Exemplo n.º 3
0
        public static IAsyncEnumerable <IReadOnlyCollection <IUser> > GetReactionUsersAsync(IMessage msg, IEmote emote,
                                                                                            int?limit, BaseDiscordClient client, RequestOptions options)
        {
            Preconditions.NotNull(emote, nameof(emote));
            var emoji = (emote is Emote e ? $"{e.Name}:{e.Id}" : emote.Name);

            return(new PagedAsyncEnumerable <IUser>(
                       DiscordConfig.MaxUserReactionsPerBatch,
                       async(info, ct) =>
            {
                var args = new GetReactionUsersParams
                {
                    Limit = info.PageSize
                };

                if (info.Position != null)
                {
                    args.AfterUserId = info.Position.Value;
                }

                var models = await client.ApiClient.GetReactionUsersAsync(msg.Channel.Id, msg.Id, emoji, args, options).ConfigureAwait(false);
                return models.Select(x => RestUser.Create(client, x)).ToImmutableArray();
            },
                       nextPage: (info, lastPage) =>
            {
                if (lastPage.Count != DiscordConfig.MaxUsersPerBatch)
                {
                    return false;
                }

                info.Position = lastPage.Max(x => x.Id);
                return true;
            },
                       count: limit
                       ));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Converts an existing <see cref="RestUser"/> to an abstracted <see cref="IRestUser"/> value.
 /// </summary>
 /// <param name="restUser">The existing <see cref="RestUser"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restUser"/>.</exception>
 /// <returns>An <see cref="IRestUser"/> that abstracts <paramref name="restUser"/>.</returns>
 public static IRestUser Abstract(this RestUser restUser)
 => restUser switch
 {
     null
     => throw new ArgumentNullException(nameof(restUser)),
Exemplo n.º 5
0
 internal RestDMChannel(BaseDiscordClient discord, ulong id, ulong recipientId)
     : base(discord, id)
 {
     Recipient   = new RestUser(Discord, recipientId);
     CurrentUser = new RestUser(Discord, discord.CurrentUser.Id);
 }
Exemplo n.º 6
0
        internal static BotAddAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);

            return(new BotAddAuditLogData((userInfo != null) ? RestUser.Create(discord, userInfo) : null));
        }
Exemplo n.º 7
0
        internal static KickAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);

            return(new KickAuditLogData(RestUser.Create(discord, userInfo)));
        }
        internal static RestFollowupMessage Create(BaseDiscordClient discord, Model model, string token, IMessageChannel channel)
        {
            var entity = new RestFollowupMessage(discord, model.Id, model.Author.IsSpecified ? RestUser.Create(discord, model.Author.Value) : discord.CurrentUser, token, channel);

            entity.Update(model);
            return(entity);
        }
Exemplo n.º 9
0
 /// <inheritdoc />
 public Task UpdateAsync(RequestOptions options = null)
 => RestUser.UpdateAsync(options);
Exemplo n.º 10
0
 /// <inheritdoc />
 public string GetDefaultAvatarUrl()
 => RestUser.GetDefaultAvatarUrl();
Exemplo n.º 11
0
 internal RestBan(RestUser user, string reason)
 {
     User   = user;
     Reason = reason;
 }
Exemplo n.º 12
0
        public static async Task <IReadOnlyCollection <IUser> > GetReactionUsersAsync(IMessage msg, string emoji,
                                                                                      Action <GetReactionUsersParams> func, BaseDiscordClient client, RequestOptions options)
        {
            var args = new GetReactionUsersParams();

            func(args);
            return((await client.ApiClient.GetReactionUsersAsync(msg.Channel.Id, msg.Id, emoji, args, options).ConfigureAwait(false)).Select(u => RestUser.Create(client, u)).ToImmutableArray());
        }
        internal virtual void Update(Model model)
        {
            Type = model.Type;

            if (model.Timestamp.IsSpecified)
            {
                _timestampTicks = model.Timestamp.Value.UtcTicks;
            }

            if (model.Content.IsSpecified)
            {
                Content = model.Content.Value;
            }

            if (model.Application.IsSpecified)
            {
                // create a new Application from the API model
                Application = new MessageApplication()
                {
                    Id          = model.Application.Value.Id,
                    CoverImage  = model.Application.Value.CoverImage,
                    Description = model.Application.Value.Description,
                    Icon        = model.Application.Value.Icon,
                    Name        = model.Application.Value.Name
                };
            }

            if (model.Activity.IsSpecified)
            {
                // create a new Activity from the API model
                Activity = new MessageActivity()
                {
                    Type    = model.Activity.Value.Type.Value,
                    PartyId = model.Activity.Value.PartyId.GetValueOrDefault()
                };
            }

            if (model.Reference.IsSpecified)
            {
                // Creates a new Reference from the API model
                Reference = new MessageReference
                {
                    GuildId           = model.Reference.Value.GuildId,
                    InternalChannelId = model.Reference.Value.ChannelId,
                    MessageId         = model.Reference.Value.MessageId
                };
            }

            if (model.Components.IsSpecified)
            {
                Components = model.Components.Value.Select(x => new ActionRowComponent(x.Components.Select <IMessageComponent, IMessageComponent>(y =>
                {
                    switch (y.Type)
                    {
                    case ComponentType.Button:
                        {
                            var parsed = (API.ButtonComponent)y;
                            return(new Discord.ButtonComponent(
                                       parsed.Style,
                                       parsed.Label.GetValueOrDefault(),
                                       parsed.Emote.IsSpecified
                                        ? parsed.Emote.Value.Id.HasValue
                                            ? new Emote(parsed.Emote.Value.Id.Value, parsed.Emote.Value.Name, parsed.Emote.Value.Animated.GetValueOrDefault())
                                            : new Emoji(parsed.Emote.Value.Name)
                                        : null,
                                       parsed.CustomId.GetValueOrDefault(),
                                       parsed.Url.GetValueOrDefault(),
                                       parsed.Disabled.GetValueOrDefault()));
                        }

                    case ComponentType.SelectMenu:
                        {
                            var parsed = (API.SelectMenuComponent)y;
                            return(new SelectMenuComponent(
                                       parsed.CustomId,
                                       parsed.Options.Select(z => new SelectMenuOption(
                                                                 z.Label,
                                                                 z.Value,
                                                                 z.Description.GetValueOrDefault(),
                                                                 z.Emoji.IsSpecified
                                        ? z.Emoji.Value.Id.HasValue
                                            ? new Emote(z.Emoji.Value.Id.Value, z.Emoji.Value.Name, z.Emoji.Value.Animated.GetValueOrDefault())
                                            : new Emoji(z.Emoji.Value.Name)
                                        : null,
                                                                 z.Default.ToNullable())).ToList(),
                                       parsed.Placeholder.GetValueOrDefault(),
                                       parsed.MinValues,
                                       parsed.MaxValues,
                                       parsed.Disabled
                                       ));
                        }

                    default:
                        return(null);
                    }
                }).ToList())).ToImmutableArray();
            }
            else
            {
                Components = new List <ActionRowComponent>();
            }

            if (model.Flags.IsSpecified)
            {
                Flags = model.Flags.Value;
            }

            if (model.Reactions.IsSpecified)
            {
                var value = model.Reactions.Value;
                if (value.Length > 0)
                {
                    var reactions = ImmutableArray.CreateBuilder <RestReaction>(value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        reactions.Add(RestReaction.Create(value[i]));
                    }
                    _reactions = reactions.ToImmutable();
                }
                else
                {
                    _reactions = ImmutableArray.Create <RestReaction>();
                }
            }
            else
            {
                _reactions = ImmutableArray.Create <RestReaction>();
            }

            if (model.Interaction.IsSpecified)
            {
                Interaction = new MessageInteraction <RestUser>(model.Interaction.Value.Id,
                                                                model.Interaction.Value.Type,
                                                                model.Interaction.Value.Name,
                                                                RestUser.Create(Discord, model.Interaction.Value.User));
            }

            if (model.UserMentions.IsSpecified)
            {
                var value = model.UserMentions.Value;
                if (value.Length > 0)
                {
                    var newMentions = ImmutableArray.CreateBuilder <RestUser>(value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        var val = value[i];
                        if (val != null)
                        {
                            newMentions.Add(RestUser.Create(Discord, val));
                        }
                    }
                    _userMentions = newMentions.ToImmutable();
                }
            }
        }
Exemplo n.º 14
0
        public static async Task <RestUserMessage> ModifyMessageAsync(IMessageChannel channel, ulong messageId, Action <MessageProperties> func,
                                                                      BaseDiscordClient client, RequestOptions options)
        {
            var msgModel = await MessageHelper.ModifyAsync(channel.Id, messageId, client, func, options).ConfigureAwait(false);

            return(RestUserMessage.Create(client, channel, msgModel.Author.IsSpecified ? RestUser.Create(client, msgModel.Author.Value) : client.CurrentUser, msgModel));
        }
Exemplo n.º 15
0
 /// <summary>
 /// Constructs a new <see cref="RestUserAbstraction"/> around an existing <see cref="Rest.RestUser"/>.
 /// </summary>
 /// <param name="restUser">The value to use for <see cref="Rest.RestUser"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restUser"/>.</exception>
 public RestUserAbstraction(RestUser restUser)
 {
     RestUser = restUser ?? throw new ArgumentNullException(nameof(restUser));
 }
Exemplo n.º 16
0
 /// <inheritdoc />
 public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128)
 => RestUser.GetAvatarUrl(format, size);
Exemplo n.º 17
0
 internal static RestBan Create(BaseDiscordClient client, Model model)
 {
     return(new RestBan(RestUser.Create(client, model.User), model.Reason));
 }
Exemplo n.º 18
0
 /// <inheritdoc />
 public async Task <IRestDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null)
 => (await RestUser.GetOrCreateDMChannelAsync(options))
 .Abstract();
Exemplo n.º 19
0
        internal static GuildUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            var changes = entry.Changes;

            var afkTimeoutModel = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var defaultMessageNotificationsModel = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var afkChannelModel        = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var nameModel              = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var regionIdModel          = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var iconHashModel          = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var verificationLevelModel = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var ownerIdModel           = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var mfaLevelModel          = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var contentFilterModel     = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");

            int?oldAfkTimeout = afkTimeoutModel?.OldValue?.ToObject <int>(discord.ApiClient.Serializer),
               newAfkTimeout  = afkTimeoutModel?.NewValue?.ToObject <int>(discord.ApiClient.Serializer);
            DefaultMessageNotifications?oldDefaultMessageNotifications = defaultMessageNotificationsModel?.OldValue?.ToObject <DefaultMessageNotifications>(discord.ApiClient.Serializer),
                                       newDefaultMessageNotifications  = defaultMessageNotificationsModel?.NewValue?.ToObject <DefaultMessageNotifications>(discord.ApiClient.Serializer);
            ulong?oldAfkChannelId = afkChannelModel?.OldValue?.ToObject <ulong>(discord.ApiClient.Serializer),
                 newAfkChannelId  = afkChannelModel?.NewValue?.ToObject <ulong>(discord.ApiClient.Serializer);
            string oldName        = nameModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer),
                   newName        = nameModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            string oldRegionId    = regionIdModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer),
                   newRegionId    = regionIdModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            string oldIconHash    = iconHashModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer),
                   newIconHash    = iconHashModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            VerificationLevel?oldVerificationLevel = verificationLevelModel?.OldValue?.ToObject <VerificationLevel>(discord.ApiClient.Serializer),
                             newVerificationLevel  = verificationLevelModel?.NewValue?.ToObject <VerificationLevel>(discord.ApiClient.Serializer);
            ulong?oldOwnerId     = ownerIdModel?.OldValue?.ToObject <ulong>(discord.ApiClient.Serializer),
                 newOwnerId      = ownerIdModel?.NewValue?.ToObject <ulong>(discord.ApiClient.Serializer);
            MfaLevel?oldMfaLevel = mfaLevelModel?.OldValue?.ToObject <MfaLevel>(discord.ApiClient.Serializer),
                    newMfaLevel  = mfaLevelModel?.NewValue?.ToObject <MfaLevel>(discord.ApiClient.Serializer);
            int?oldContentFilter = contentFilterModel?.OldValue?.ToObject <int>(discord.ApiClient.Serializer),
               newContentFilter  = contentFilterModel?.NewValue?.ToObject <int>(discord.ApiClient.Serializer);

            IUser oldOwner = null;

            if (oldOwnerId != null)
            {
                var oldOwnerInfo = log.Users.FirstOrDefault(x => x.Id == oldOwnerId.Value);
                oldOwner = RestUser.Create(discord, oldOwnerInfo);
            }

            IUser newOwner = null;

            if (newOwnerId != null)
            {
                var newOwnerInfo = log.Users.FirstOrDefault(x => x.Id == newOwnerId.Value);
                newOwner = RestUser.Create(discord, newOwnerInfo);
            }

            var before = new GuildInfo(oldAfkTimeout, oldDefaultMessageNotifications,
                                       oldAfkChannelId, oldName, oldRegionId, oldIconHash, oldVerificationLevel, oldOwner,
                                       oldMfaLevel, oldContentFilter);
            var after = new GuildInfo(newAfkTimeout, newDefaultMessageNotifications,
                                      newAfkChannelId, newName, newRegionId, newIconHash, newVerificationLevel, newOwner,
                                      newMfaLevel, newContentFilter);

            return(new GuildUpdateAuditLogData(before, after));
        }
Exemplo n.º 20
0
 /// <inheritdoc cref="RestUser.ToString"/>
 public override string ToString()
 => RestUser.ToString();
        internal async Task PopulateAsync(DiscordRestClient discord, RestGuild guild, IRestMessageChannel channel, T model)
        {
            var resolved = model.Resolved.Value;

            if (resolved.Users.IsSpecified)
            {
                foreach (var user in resolved.Users.Value)
                {
                    var restUser = RestUser.Create(discord, user.Value);

                    Users.Add(ulong.Parse(user.Key), restUser);
                }
            }

            if (resolved.Channels.IsSpecified)
            {
                var channels = await guild.GetChannelsAsync().ConfigureAwait(false);

                foreach (var channelModel in resolved.Channels.Value)
                {
                    var restChannel = channels.FirstOrDefault(x => x.Id == channelModel.Value.Id);

                    restChannel.Update(channelModel.Value);

                    Channels.Add(ulong.Parse(channelModel.Key), restChannel);
                }
            }

            if (resolved.Members.IsSpecified)
            {
                foreach (var member in resolved.Members.Value)
                {
                    // pull the adjacent user model
                    member.Value.User = resolved.Users.Value.FirstOrDefault(x => x.Key == member.Key).Value;
                    var restMember = RestGuildUser.Create(discord, guild, member.Value);

                    GuildMembers.Add(ulong.Parse(member.Key), restMember);
                }
            }

            if (resolved.Roles.IsSpecified)
            {
                foreach (var role in resolved.Roles.Value)
                {
                    var restRole = RestRole.Create(discord, guild, role.Value);

                    Roles.Add(ulong.Parse(role.Key), restRole);
                }
            }

            if (resolved.Messages.IsSpecified)
            {
                foreach (var msg in resolved.Messages.Value)
                {
                    channel ??= (IRestMessageChannel)(Channels.FirstOrDefault(x => x.Key == msg.Value.ChannelId).Value ?? await discord.GetChannelAsync(msg.Value.ChannelId).ConfigureAwait(false));

                    RestUser author;

                    if (msg.Value.Author.IsSpecified)
                    {
                        author = RestUser.Create(discord, msg.Value.Author.Value);
                    }
                    else
                    {
                        author = RestGuildUser.Create(discord, guild, msg.Value.Member.Value);
                    }

                    var message = RestMessage.Create(discord, channel, author, msg.Value);

                    Messages.Add(message.Id, message);
                }
            }

            if (resolved.Attachments.IsSpecified)
            {
                foreach (var attachment in resolved.Attachments.Value)
                {
                    var discordAttachment = Attachment.Create(attachment.Value);

                    Attachments.Add(ulong.Parse(attachment.Key), discordAttachment);
                }
            }
        }
Exemplo n.º 22
0
 private KickAuditLogData(RestUser user)
 {
     Target = user;
 }
Exemplo n.º 23
0
        internal override void Update(Model model)
        {
            base.Update(model);

            if (model.IsTextToSpeech.IsSpecified)
            {
                _isTTS = model.IsTextToSpeech.Value;
            }
            if (model.Pinned.IsSpecified)
            {
                _isPinned = model.Pinned.Value;
            }
            if (model.EditedTimestamp.IsSpecified)
            {
                _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks;
            }
            if (model.MentionEveryone.IsSpecified)
            {
                _isMentioningEveryone = model.MentionEveryone.Value;
            }
            if (model.Flags.IsSpecified)
            {
                _isSuppressed = model.Flags.Value.HasFlag(API.MessageFlags.Suppressed);
            }
            if (model.RoleMentions.IsSpecified)
            {
                _roleMentionIds = model.RoleMentions.Value.ToImmutableArray();
            }

            if (model.Attachments.IsSpecified)
            {
                var value = model.Attachments.Value;
                if (value.Length > 0)
                {
                    var attachments = ImmutableArray.CreateBuilder <Attachment>(value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        attachments.Add(Attachment.Create(value[i]));
                    }
                    _attachments = attachments.ToImmutable();
                }
                else
                {
                    _attachments = ImmutableArray.Create <Attachment>();
                }
            }

            if (model.Embeds.IsSpecified)
            {
                var value = model.Embeds.Value;
                if (value.Length > 0)
                {
                    var embeds = ImmutableArray.CreateBuilder <Embed>(value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        embeds.Add(value[i].ToEntity());
                    }
                    _embeds = embeds.ToImmutable();
                }
                else
                {
                    _embeds = ImmutableArray.Create <Embed>();
                }
            }

            if (model.UserMentions.IsSpecified)
            {
                var value = model.UserMentions.Value;
                if (value.Length > 0)
                {
                    var newMentions = ImmutableArray.CreateBuilder <RestUser>(value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        var val = value[i];
                        if (val.Object != null)
                        {
                            newMentions.Add(RestUser.Create(Discord, val.Object));
                        }
                    }
                    _userMentions = newMentions.ToImmutable();
                }
            }

            if (model.Content.IsSpecified)
            {
                var text    = model.Content.Value;
                var guildId = (Channel as IGuildChannel)?.GuildId;
                var guild   = guildId != null ? (Discord as IDiscordClient).GetGuildAsync(guildId.Value, CacheMode.CacheOnly).Result : null;
                _tags         = MessageHelper.ParseTags(text, null, guild, _userMentions);
                model.Content = text;
            }
        }
        internal static MessageDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);

            return(new MessageDeleteAuditLogData(entry.Options.ChannelId.Value, entry.Options.Count.Value, userInfo != null ? RestUser.Create(discord, userInfo) : null));
        }
Exemplo n.º 25
0
        internal static GuildUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            var changes = entry.Changes;

            var afkTimeoutModel = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
            var defaultMessageNotificationsModel = changes.FirstOrDefault(x => x.ChangedProperty == "default_message_notifications");
            var afkChannelModel        = changes.FirstOrDefault(x => x.ChangedProperty == "afk_channel_id");
            var nameModel              = changes.FirstOrDefault(x => x.ChangedProperty == "name");
            var regionIdModel          = changes.FirstOrDefault(x => x.ChangedProperty == "region");
            var iconHashModel          = changes.FirstOrDefault(x => x.ChangedProperty == "icon_hash");
            var verificationLevelModel = changes.FirstOrDefault(x => x.ChangedProperty == "verification_level");
            var ownerIdModel           = changes.FirstOrDefault(x => x.ChangedProperty == "owner_id");
            var mfaLevelModel          = changes.FirstOrDefault(x => x.ChangedProperty == "mfa_level");
            var contentFilterModel     = changes.FirstOrDefault(x => x.ChangedProperty == "explicit_content_filter");
            var systemChannelIdModel   = changes.FirstOrDefault(x => x.ChangedProperty == "system_channel_id");
            var widgetChannelIdModel   = changes.FirstOrDefault(x => x.ChangedProperty == "widget_channel_id");
            var widgetEnabledModel     = changes.FirstOrDefault(x => x.ChangedProperty == "widget_enabled");

            int?oldAfkTimeout = afkTimeoutModel?.OldValue?.ToObject <int>(discord.ApiClient.Serializer),
               newAfkTimeout  = afkTimeoutModel?.NewValue?.ToObject <int>(discord.ApiClient.Serializer);
            DefaultMessageNotifications?oldDefaultMessageNotifications = defaultMessageNotificationsModel?.OldValue?.ToObject <DefaultMessageNotifications>(discord.ApiClient.Serializer),
                                       newDefaultMessageNotifications  = defaultMessageNotificationsModel?.NewValue?.ToObject <DefaultMessageNotifications>(discord.ApiClient.Serializer);
            ulong?oldAfkChannelId = afkChannelModel?.OldValue?.ToObject <ulong>(discord.ApiClient.Serializer),
                 newAfkChannelId  = afkChannelModel?.NewValue?.ToObject <ulong>(discord.ApiClient.Serializer);
            string oldName        = nameModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer),
                   newName        = nameModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            string oldRegionId    = regionIdModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer),
                   newRegionId    = regionIdModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            string oldIconHash    = iconHashModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer),
                   newIconHash    = iconHashModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            VerificationLevel?oldVerificationLevel = verificationLevelModel?.OldValue?.ToObject <VerificationLevel>(discord.ApiClient.Serializer),
                             newVerificationLevel  = verificationLevelModel?.NewValue?.ToObject <VerificationLevel>(discord.ApiClient.Serializer);
            ulong?oldOwnerId     = ownerIdModel?.OldValue?.ToObject <ulong>(discord.ApiClient.Serializer),
                 newOwnerId      = ownerIdModel?.NewValue?.ToObject <ulong>(discord.ApiClient.Serializer);
            MfaLevel?oldMfaLevel = mfaLevelModel?.OldValue?.ToObject <MfaLevel>(discord.ApiClient.Serializer),
                    newMfaLevel  = mfaLevelModel?.NewValue?.ToObject <MfaLevel>(discord.ApiClient.Serializer);
            ExplicitContentFilterLevel?oldContentFilter = contentFilterModel?.OldValue?.ToObject <ExplicitContentFilterLevel>(discord.ApiClient.Serializer),
                                      newContentFilter  = contentFilterModel?.NewValue?.ToObject <ExplicitContentFilterLevel>(discord.ApiClient.Serializer);
            ulong?oldSystemChannelId = systemChannelIdModel?.OldValue?.ToObject <ulong>(discord.ApiClient.Serializer),
                 newSystemChannelId  = systemChannelIdModel?.NewValue?.ToObject <ulong>(discord.ApiClient.Serializer);
            ulong?oldWidgetChannelId = widgetChannelIdModel?.OldValue?.ToObject <ulong>(discord.ApiClient.Serializer),
                 newWidgetChannelId  = widgetChannelIdModel?.NewValue?.ToObject <ulong>(discord.ApiClient.Serializer);
            bool?oldWidgetEnabled    = widgetEnabledModel?.OldValue?.ToObject <bool>(discord.ApiClient.Serializer),
                newWidgetEnabled     = widgetEnabledModel?.NewValue?.ToObject <bool>(discord.ApiClient.Serializer);

            IUser oldOwner = null;

            if (oldOwnerId != null)
            {
                var oldOwnerInfo = log.Users.FirstOrDefault(x => x.Id == oldOwnerId.Value);
                oldOwner = RestUser.Create(discord, oldOwnerInfo);
            }

            IUser newOwner = null;

            if (newOwnerId != null)
            {
                var newOwnerInfo = log.Users.FirstOrDefault(x => x.Id == newOwnerId.Value);
                newOwner = RestUser.Create(discord, newOwnerInfo);
            }

            var before = new GuildInfo(oldAfkTimeout, oldDefaultMessageNotifications,
                                       oldAfkChannelId, oldName, oldRegionId, oldIconHash, oldVerificationLevel, oldOwner,
                                       oldMfaLevel, oldContentFilter, oldSystemChannelId, oldWidgetChannelId, oldWidgetEnabled);
            var after = new GuildInfo(newAfkTimeout, newDefaultMessageNotifications,
                                      newAfkChannelId, newName, newRegionId, newIconHash, newVerificationLevel, newOwner,
                                      newMfaLevel, newContentFilter, newSystemChannelId, newWidgetChannelId, newWidgetEnabled);

            return(new GuildUpdateAuditLogData(before, after));
        }