Browse Source

fixed an issue when event was cahnged from in channel to external or vice versa

pull/2483/head
Rennorb 2 years ago
parent
commit
97e585572d
2 changed files with 9 additions and 10 deletions
  1. +3
    -3
      src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs
  2. +6
    -7
      src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs

+ 3
- 3
src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs View File

@@ -12,7 +12,7 @@ namespace Discord.Rest
/// </summary>
public ulong? GuildId { get; }
/// <summary>
/// Gets the snowflake id of the channel the event is associated with.
/// Gets the snowflake id of the channel the event is associated with. 0 for events with external location.
/// </summary>
public ulong? ChannelId { get; }
/// <summary>
@@ -50,7 +50,7 @@ namespace Discord.Rest
/// <summary>
/// Gets the metadata for the entity associated with the event.
/// </summary>
public string Location { get; }
public Optional<string>? Location { get; }
/// <summary>
/// Gets the count of users interested in this event.
/// </summary>
@@ -60,7 +60,7 @@ namespace Discord.Rest
/// </summary>
public string Image { get; }

internal ScheduledEventInfo(ulong? guildId, ulong? channelId, string name, string description, DateTimeOffset? scheduledStartTime, DateTimeOffset? scheduledEndTime, GuildScheduledEventPrivacyLevel? privacyLevel, GuildScheduledEventStatus? status, GuildScheduledEventType? entityType, ulong? entityId, string location, int? userCount, string image)
internal ScheduledEventInfo(ulong? guildId, ulong? channelId, string name, string description, DateTimeOffset? scheduledStartTime, DateTimeOffset? scheduledEndTime, GuildScheduledEventPrivacyLevel? privacyLevel, GuildScheduledEventStatus? status, GuildScheduledEventType? entityType, ulong? entityId, Optional<string>? location, int? userCount, string image)
{
GuildId = guildId ;
ChannelId = channelId ;


+ 6
- 7
src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs View File

@@ -4,6 +4,7 @@ using Discord.API;

using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Newtonsoft.Json.Linq;

namespace Discord.Rest
{
@@ -35,13 +36,13 @@ namespace Discord.Rest
var status = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "status");
var entityType = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_type");
var entityId = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_id");
var entityMetadata = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_metadata");
var location = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "location");
var userCount = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "user_count");
var image = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "image");

var before = new ScheduledEventInfo(
guildId?.OldValue.ToObject<ulong>(discord.ApiClient.Serializer),
channelId?.OldValue.ToObject<ulong?>(discord.ApiClient.Serializer),
channelId == null ? null : channelId.OldValue?.ToObject<ulong?>(discord.ApiClient.Serializer) ?? 0,
name?.OldValue.ToObject<string>(discord.ApiClient.Serializer),
description?.OldValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
.GetValueOrDefault(),
@@ -51,8 +52,7 @@ namespace Discord.Rest
status?.OldValue.ToObject<GuildScheduledEventStatus>(discord.ApiClient.Serializer),
entityType?.OldValue.ToObject<GuildScheduledEventType>(discord.ApiClient.Serializer),
entityId?.OldValue.ToObject<ulong?>(discord.ApiClient.Serializer),
entityMetadata?.OldValue.ToObject<GuildScheduledEventEntityMetadata>(discord.ApiClient.Serializer)
?.Location.GetValueOrDefault(),
location == null ? null : location.OldValue?.ToObject<string>(discord.ApiClient.Serializer) ?? Optional<string>.Unspecified,
userCount?.OldValue.ToObject<Optional<int>>(discord.ApiClient.Serializer)
.GetValueOrDefault(),
image?.OldValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
@@ -60,7 +60,7 @@ namespace Discord.Rest
);
var after = new ScheduledEventInfo(
guildId?.NewValue.ToObject<ulong>(discord.ApiClient.Serializer),
channelId?.NewValue.ToObject<ulong?>(discord.ApiClient.Serializer),
channelId == null ? null : channelId.NewValue?.ToObject<ulong?>(discord.ApiClient.Serializer) ?? 0,
name?.NewValue.ToObject<string>(discord.ApiClient.Serializer),
description?.NewValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
.GetValueOrDefault(),
@@ -70,8 +70,7 @@ namespace Discord.Rest
status?.NewValue.ToObject<GuildScheduledEventStatus>(discord.ApiClient.Serializer),
entityType?.NewValue.ToObject<GuildScheduledEventType>(discord.ApiClient.Serializer),
entityId?.NewValue.ToObject<ulong?>(discord.ApiClient.Serializer),
entityMetadata?.NewValue.ToObject<GuildScheduledEventEntityMetadata>(discord.ApiClient.Serializer)
?.Location.GetValueOrDefault(),
location == null ? null : location.NewValue?.ToObject<string>(discord.ApiClient.Serializer) ?? Optional<string>.Unspecified,
userCount?.NewValue.ToObject<Optional<int>>(discord.ApiClient.Serializer)
.GetValueOrDefault(),
image?.NewValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)


Loading…
Cancel
Save