This repository has been archived on 2024-12-22. You can view files and clone it, but cannot push or open issues or pull requests.
elliebot/src/Ellie.Marmalade/Extensions/MarmaladeExtensions.cs

61 lines
2.7 KiB
C#
Raw Normal View History

2024-03-23 18:42:46 +13:00
using Discord;
2024-05-12 23:43:23 +12:00
namespace EllieBot.Marmalade;
2024-03-23 18:42:46 +13:00
public static class MarmaladeExtensions
{
2024-05-12 23:43:23 +12:00
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, EmbedBuilder embed, string msg = "")
2024-03-23 18:42:46 +13:00
=> ch.SendMessageAsync(msg,
embed: embed.Build(),
options: new()
{
RetryMode = RetryMode.Retry502
});
// unlocalized
public static Task<IUserMessage> SendConfirmAsync(this AnyContext ctx, string msg)
2024-05-12 23:43:23 +12:00
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
.WithColor(0, 200, 0)
.WithDescription(msg));
2024-03-23 18:42:46 +13:00
public static Task<IUserMessage> SendPendingAsync(this AnyContext ctx, string msg)
2024-05-12 23:43:23 +12:00
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
.WithColor(200, 200, 0)
.WithDescription(msg));
2024-03-23 18:42:46 +13:00
public static Task<IUserMessage> SendErrorAsync(this AnyContext ctx, string msg)
2024-05-12 23:43:23 +12:00
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
.WithColor(200, 0, 0)
.WithDescription(msg));
2024-03-23 18:42:46 +13:00
// 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<IUserMessage> ErrorLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
=> ctx.SendErrorAsync(ctx.GetText(key, args));
public static Task<IUserMessage> PendingLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
=> ctx.SendPendingAsync(ctx.GetText(key, args));
public static Task<IUserMessage> ConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
=> ctx.SendConfirmAsync(ctx.GetText(key, args));
public static Task<IUserMessage> ReplyErrorLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
=> ctx.SendErrorAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
public static Task<IUserMessage> ReplyPendingLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
=> ctx.SendPendingAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
public static Task<IUserMessage> ReplyConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
=> ctx.SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
2024-05-12 23:43:23 +12:00
}