[Bugfix] fixed an NRE when event was changed from in channel to external or vice versa (#2483)
* fixed an issue when event was cahnged from in channel to external or vice versa * simplidied location field
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Discord.Rest
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ulong? GuildId { get; }
|
public ulong? GuildId { get; }
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public ulong? ChannelId { get; }
|
public ulong? ChannelId { get; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -48,9 +48,9 @@ namespace Discord.Rest
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ulong? EntityId { get; }
|
public ulong? EntityId { get; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the metadata for the entity associated with the event.
|
/// Gets the metadata for the entity associated with the event. <see cref="Optional{T}.Unspecified"/> if there was no change.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Location { get; }
|
public Optional<string> Location { get; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the count of users interested in this event.
|
/// Gets the count of users interested in this event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -60,7 +60,7 @@ namespace Discord.Rest
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Image { get; }
|
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 ;
|
GuildId = guildId ;
|
||||||
ChannelId = channelId ;
|
ChannelId = channelId ;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Discord.API;
|
|
||||||
|
|
||||||
using Model = Discord.API.AuditLog;
|
using Model = Discord.API.AuditLog;
|
||||||
using EntryModel = Discord.API.AuditLogEntry;
|
using EntryModel = Discord.API.AuditLogEntry;
|
||||||
@@ -35,13 +34,13 @@ namespace Discord.Rest
|
|||||||
var status = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "status");
|
var status = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "status");
|
||||||
var entityType = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_type");
|
var entityType = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_type");
|
||||||
var entityId = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_id");
|
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 userCount = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "user_count");
|
||||||
var image = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "image");
|
var image = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "image");
|
||||||
|
|
||||||
var before = new ScheduledEventInfo(
|
var before = new ScheduledEventInfo(
|
||||||
guildId?.OldValue.ToObject<ulong>(discord.ApiClient.Serializer),
|
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),
|
name?.OldValue.ToObject<string>(discord.ApiClient.Serializer),
|
||||||
description?.OldValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
|
description?.OldValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
|
||||||
.GetValueOrDefault(),
|
.GetValueOrDefault(),
|
||||||
@@ -51,8 +50,7 @@ namespace Discord.Rest
|
|||||||
status?.OldValue.ToObject<GuildScheduledEventStatus>(discord.ApiClient.Serializer),
|
status?.OldValue.ToObject<GuildScheduledEventStatus>(discord.ApiClient.Serializer),
|
||||||
entityType?.OldValue.ToObject<GuildScheduledEventType>(discord.ApiClient.Serializer),
|
entityType?.OldValue.ToObject<GuildScheduledEventType>(discord.ApiClient.Serializer),
|
||||||
entityId?.OldValue.ToObject<ulong?>(discord.ApiClient.Serializer),
|
entityId?.OldValue.ToObject<ulong?>(discord.ApiClient.Serializer),
|
||||||
entityMetadata?.OldValue.ToObject<GuildScheduledEventEntityMetadata>(discord.ApiClient.Serializer)
|
location == null ? Optional<string>.Unspecified : new Optional<string>(location.OldValue?.ToObject<string>(discord.ApiClient.Serializer)),
|
||||||
?.Location.GetValueOrDefault(),
|
|
||||||
userCount?.OldValue.ToObject<Optional<int>>(discord.ApiClient.Serializer)
|
userCount?.OldValue.ToObject<Optional<int>>(discord.ApiClient.Serializer)
|
||||||
.GetValueOrDefault(),
|
.GetValueOrDefault(),
|
||||||
image?.OldValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
|
image?.OldValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
|
||||||
@@ -60,7 +58,7 @@ namespace Discord.Rest
|
|||||||
);
|
);
|
||||||
var after = new ScheduledEventInfo(
|
var after = new ScheduledEventInfo(
|
||||||
guildId?.NewValue.ToObject<ulong>(discord.ApiClient.Serializer),
|
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),
|
name?.NewValue.ToObject<string>(discord.ApiClient.Serializer),
|
||||||
description?.NewValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
|
description?.NewValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
|
||||||
.GetValueOrDefault(),
|
.GetValueOrDefault(),
|
||||||
@@ -70,8 +68,7 @@ namespace Discord.Rest
|
|||||||
status?.NewValue.ToObject<GuildScheduledEventStatus>(discord.ApiClient.Serializer),
|
status?.NewValue.ToObject<GuildScheduledEventStatus>(discord.ApiClient.Serializer),
|
||||||
entityType?.NewValue.ToObject<GuildScheduledEventType>(discord.ApiClient.Serializer),
|
entityType?.NewValue.ToObject<GuildScheduledEventType>(discord.ApiClient.Serializer),
|
||||||
entityId?.NewValue.ToObject<ulong?>(discord.ApiClient.Serializer),
|
entityId?.NewValue.ToObject<ulong?>(discord.ApiClient.Serializer),
|
||||||
entityMetadata?.NewValue.ToObject<GuildScheduledEventEntityMetadata>(discord.ApiClient.Serializer)
|
location == null ? Optional<string>.Unspecified : new Optional<string>(location.NewValue?.ToObject<string>(discord.ApiClient.Serializer)),
|
||||||
?.Location.GetValueOrDefault(),
|
|
||||||
userCount?.NewValue.ToObject<Optional<int>>(discord.ApiClient.Serializer)
|
userCount?.NewValue.ToObject<Optional<int>>(discord.ApiClient.Serializer)
|
||||||
.GetValueOrDefault(),
|
.GetValueOrDefault(),
|
||||||
image?.NewValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
|
image?.NewValue.ToObject<Optional<string>>(discord.ApiClient.Serializer)
|
||||||
|
|||||||
Reference in New Issue
Block a user