1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 17:19:00 +03:00
Octobot/TeamOctolings.Octobot/Extensions/GuildScheduledEventExtensions.cs

29 lines
935 B
C#
Raw Normal View History

using Remora.Discord.API.Abstractions.Objects;
using Remora.Rest.Core;
using Remora.Results;
namespace TeamOctolings.Octobot.Extensions;
public static class GuildScheduledEventExtensions
{
public static Result TryGetExternalEventData(this IGuildScheduledEvent scheduledEvent, out DateTimeOffset endTime,
out string? location)
{
endTime = default;
location = default;
if (!scheduledEvent.EntityMetadata.AsOptional().IsDefined(out var metadata))
{
return new ArgumentNullError(nameof(scheduledEvent.EntityMetadata));
}
if (!metadata.Location.IsDefined(out location))
{
return new ArgumentNullError(nameof(metadata.Location));
}
return scheduledEvent.ScheduledEndTime.AsOptional().IsDefined(out endTime)
? Result.Success
: new ArgumentNullError(nameof(scheduledEvent.ScheduledEndTime));
}
}