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
Toastie 4a723b7c1c
Added .xplevelset
removed awardedxp from database.
.sclr show will now show hex
.awardxp will now add directly to user's real xp
2024-12-08 15:27:28 +13:00

65 lines
No EOL
2 KiB
C#

namespace EllieBot.Extensions;
public sealed class MessageSenderService : IMessageSenderService, IEService
{
private readonly IBotStrings _bs;
private readonly BotConfigService _bcs;
private readonly DiscordSocketClient _client;
private readonly IGuildColorsService _gcs;
public MessageSenderService(
IBotStrings bs,
DiscordSocketClient client,
IGuildColorsService gcs,
BotConfigService bcs)
{
_bs = bs;
_client = client;
_gcs = gcs;
_bcs = bcs;
}
public ResponseBuilder Response(IMessageChannel channel)
=> new ResponseBuilder(_bs, this, _client)
.Channel(channel);
public ResponseBuilder Response(ICommandContext ctx)
=> new ResponseBuilder(_bs, this, _client)
.Context(ctx);
public ResponseBuilder Response(IUser user)
=> new ResponseBuilder(_bs, this, _client)
.User(user);
public ResponseBuilder Response(SocketMessageComponent smc)
=> new ResponseBuilder(_bs, this, _client)
.Channel(smc.Channel);
public EllieEmbedBuilder CreateEmbed(ulong? guildId = null)
=> new EllieEmbedBuilder(_bcs, guildId is { } gid ? _gcs.GetColors(gid) : null);
}
public class EllieEmbedBuilder : EmbedBuilder
{
private readonly Color _okColor;
private readonly Color _errorColor;
private readonly Color _pendingColor;
public EllieEmbedBuilder(BotConfigService bcsData, Colors? guildColors = null)
{
var bcColors = bcsData.Data.Color;
_okColor = guildColors?.Ok ?? bcColors.Ok.ToDiscordColor();
_errorColor = guildColors?.Error ?? bcColors.Error.ToDiscordColor();
_pendingColor = guildColors?.Warn ?? bcColors.Pending.ToDiscordColor();
}
public EmbedBuilder WithOkColor()
=> WithColor(_okColor);
public EmbedBuilder WithErrorColor()
=> WithColor(_errorColor);
public EmbedBuilder WithPendingColor()
=> WithColor(_pendingColor);
}