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/EllieBot/_common/Sender/MessageSenderService.cs

56 lines
1.5 KiB
C#
Raw Normal View History

2024-09-20 23:23:21 +12:00
using EllieBot.Common.Configs;
namespace EllieBot.Extensions;
public sealed class MessageSenderService : IMessageSenderService, IEService
{
private readonly IBotStrings _bs;
private readonly BotConfigService _bcs;
private readonly DiscordSocketClient _client;
public MessageSenderService(IBotStrings bs, BotConfigService bcs, DiscordSocketClient client)
{
_bs = bs;
_bcs = bcs;
_client = client;
}
public ResponseBuilder Response(IMessageChannel channel)
=> new ResponseBuilder(_bs, _bcs, _client)
.Channel(channel);
public ResponseBuilder Response(ICommandContext ctx)
=> new ResponseBuilder(_bs, _bcs, _client)
.Context(ctx);
public ResponseBuilder Response(IUser user)
=> new ResponseBuilder(_bs, _bcs, _client)
.User(user);
public ResponseBuilder Response(SocketMessageComponent smc)
=> new ResponseBuilder(_bs, _bcs, _client)
.Channel(smc.Channel);
public EllieEmbedBuilder CreateEmbed()
=> new EllieEmbedBuilder(_bcs);
}
public class EllieEmbedBuilder : EmbedBuilder
{
private readonly BotConfig _bc;
public EllieEmbedBuilder(BotConfigService bcs)
{
_bc = bcs.Data;
}
public EmbedBuilder WithOkColor()
=> WithColor(_bc.Color.Ok.ToDiscordColor());
public EmbedBuilder WithErrorColor()
=> WithColor(_bc.Color.Error.ToDiscordColor());
public EmbedBuilder WithPendingColor()
=> WithColor(_bc.Color.Pending.ToDiscordColor());
}