1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 00:19:00 +03:00
Octobot/TeamOctolings.Octobot/Extensions/ChannelApiExtensions.cs
Octol1ttle daef4f1d48
Upgrade NuGet dependencies (#313)
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2024-05-30 15:32:27 +05:00

30 lines
1.5 KiB
C#

using OneOf;
using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Abstractions.Rest;
using Remora.Discord.API.Objects;
using Remora.Rest.Core;
using Remora.Results;
namespace TeamOctolings.Octobot.Extensions;
public static class ChannelApiExtensions
{
public static async Task<Result> CreateMessageWithEmbedResultAsync(this IDiscordRestChannelAPI channelApi,
Snowflake channelId, Optional<string> message = default, Optional<string> nonce = default,
Optional<bool> isTextToSpeech = default, Optional<Result<Embed>> embedResult = default,
Optional<IAllowedMentions> allowedMentions = default, Optional<IMessageReference> messageReference = default,
Optional<IReadOnlyList<IMessageComponent>> components = default,
Optional<IReadOnlyList<Snowflake>> stickerIds = default,
Optional<IReadOnlyList<OneOf<FileData, IPartialAttachment>>> attachments = default,
Optional<MessageFlags> flags = default, Optional<bool> enforceNonce = default,
Optional<IPollCreateRequest> poll = default, CancellationToken ct = default)
{
if (!embedResult.IsDefined() || !embedResult.Value.IsDefined(out var embed))
{
return ResultExtensions.FromError(embedResult.Value);
}
return (Result)await channelApi.CreateMessageAsync(channelId, message, nonce, isTextToSpeech, new[] { embed },
allowedMentions, messageReference, components, stickerIds, attachments, flags, enforceNonce, poll, ct);
}
}