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 CreateMessageWithEmbedResultAsync(this IDiscordRestChannelAPI channelApi, Snowflake channelId, Optional message = default, Optional nonce = default, Optional isTextToSpeech = default, Optional> embedResult = default, Optional allowedMentions = default, Optional messageRefenence = default, Optional> components = default, Optional> stickerIds = default, Optional>> attachments = default, Optional flags = 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, messageRefenence, components, stickerIds, attachments, flags, ct); } }