using Discord; using Ellie.Marmalade; namespace EllieBot; public static class MarmaladeExtensions { public static Task EmbedAsync(this IMessageChannel ch, IEmbedBuilder embed, string msg = "") => ch.SendMessageAsync(msg, embed: embed.Build(), options: new() { RetryMode = RetryMode.Retry502 }); // unlocalized public static Task SendConfirmAsync(this IMessageChannel ch, AnyContext ctx, string msg) => ch.EmbedAsync(ctx.Embed().WithOkColor().WithDescription(msg)); public static Task SendPendingAsync(this IMessageChannel ch, AnyContext ctx, string msg) => ch.EmbedAsync(ctx.Embed().WithPendingColor().WithDescription(msg)); public static Task SendErrorAsync(this IMessageChannel ch, AnyContext ctx, string msg) => ch.EmbedAsync(ctx.Embed().WithErrorColor().WithDescription(msg)); // unlocalized public static Task SendConfirmAsync(this AnyContext ctx, string msg) => ctx.Channel.SendConfirmAsync(ctx, msg); public static Task SendPendingAsync(this AnyContext ctx, string msg) => ctx.Channel.SendPendingAsync(ctx, msg); public static Task SendErrorAsync(this AnyContext ctx, string msg) => ctx.Channel.SendErrorAsync(ctx, msg); // localized public static Task ConfirmAsync(this AnyContext ctx) => ctx.Message.AddReactionAsync(new Emoji("✅")); public static Task ErrorAsync(this AnyContext ctx) => ctx.Message.AddReactionAsync(new Emoji("❌")); public static Task WarningAsync(this AnyContext ctx) => ctx.Message.AddReactionAsync(new Emoji("⚠️")); public static Task WaitAsync(this AnyContext ctx) => ctx.Message.AddReactionAsync(new Emoji("🤔")); public static Task ErrorLocalizedAsync(this AnyContext ctx, string key, params object[]? args) => ctx.SendErrorAsync(ctx.GetText(key, args)); public static Task PendingLocalizedAsync(this AnyContext ctx, string key, params object[]? args) => ctx.SendPendingAsync(ctx.GetText(key, args)); public static Task ConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args) => ctx.SendConfirmAsync(ctx.GetText(key, args)); public static Task ReplyErrorLocalizedAsync(this AnyContext ctx, string key, params object[]? args) => ctx.SendErrorAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}"); public static Task ReplyPendingLocalizedAsync(this AnyContext ctx, string key, params object[]? args) => ctx.SendPendingAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}"); public static Task ReplyConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args) => ctx.SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}"); }