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

            var nameModel       = changes.FirstOrDefault(x => x.ChangedProperty == "name");
            var channelIdModel  = changes.FirstOrDefault(x => x.ChangedProperty == "channel_id");
            var avatarHashModel = changes.FirstOrDefault(x => x.ChangedProperty == "avatar_hash");

            var oldName      = nameModel?.OldValue?.ToObject <string>();
            var oldChannelId = channelIdModel?.OldValue?.ToObject <ulong>();
            var oldAvatar    = avatarHashModel?.OldValue?.ToObject <string>();
            var before       = new WebhookInfo(oldName, oldChannelId, oldAvatar);

            var newName      = nameModel?.NewValue?.ToObject <string>();
            var newChannelId = channelIdModel?.NewValue?.ToObject <ulong>();
            var newAvatar    = avatarHashModel?.NewValue?.ToObject <string>();
            var after        = new WebhookInfo(newName, newChannelId, newAvatar);

            var webhookInfo = log.Webhooks?.FirstOrDefault(x => x.Id == entry.TargetId);
            var webhook     = RestWebhook.Create(discord, (IGuild)null, webhookInfo);

            return(new WebhookUpdateAuditLogData(webhook, before, after));
        }
        internal static WebhookUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
        {
            API.AuditLogChangeJson[] changes = entry.Changes;

            API.AuditLogChangeJson nameModel       = changes.FirstOrDefault(x => x.ChangedProperty == "name");
            API.AuditLogChangeJson channelIdModel  = changes.FirstOrDefault(x => x.ChangedProperty == "channel_id");
            API.AuditLogChangeJson avatarHashModel = changes.FirstOrDefault(x => x.ChangedProperty == "avatar_hash");

            string      oldName      = nameModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer);
            ulong?      oldChannelId = channelIdModel?.OldValue?.ToObject <ulong>(discord.ApiClient.Serializer);
            string      oldAvatar    = avatarHashModel?.OldValue?.ToObject <string>(discord.ApiClient.Serializer);
            WebhookInfo before       = new WebhookInfo(oldName, oldChannelId, oldAvatar);

            string      newName      = nameModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            ulong?      newChannelId = channelIdModel?.NewValue?.ToObject <ulong>(discord.ApiClient.Serializer);
            string      newAvatar    = avatarHashModel?.NewValue?.ToObject <string>(discord.ApiClient.Serializer);
            WebhookInfo after        = new WebhookInfo(newName, newChannelId, newAvatar);

            API.WebhookJson webhookInfo = log.Webhooks?.FirstOrDefault(x => x.Id == entry.TargetId);
            RestWebhook     webhook     = webhookInfo != null?RestWebhook.Create(discord, (IGuild)null, webhookInfo) : null;

            return(new WebhookUpdateAuditLogData(webhook, before, after));
        }
Esempio n. 3
0
 private WebhookUpdateAuditLogData(IWebhook webhook, WebhookInfo before, WebhookInfo after)
 {
     Webhook = webhook;
     Before  = before;
     After   = after;
 }