mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-13 02:38:27 -04:00
- Reworked embed builder
- Use IEmbedBuilderService to create embed builders - Wrapped embed builder and using IEmbedBuilder
This commit is contained in:
@@ -18,15 +18,17 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
{
|
||||
public class CommandMapService : IInputTransformer, INService
|
||||
{
|
||||
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
|
||||
public ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>> AliasMaps { get; } = new ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>>();
|
||||
|
||||
private readonly DbService _db;
|
||||
|
||||
//commandmap
|
||||
public CommandMapService(DiscordSocketClient client, DbService db)
|
||||
public CommandMapService(DiscordSocketClient client, DbService db, IEmbedBuilderService eb)
|
||||
{
|
||||
|
||||
_eb = eb;
|
||||
|
||||
using (var uow = db.GetDbContext())
|
||||
{
|
||||
var guildIds = client.Guilds.Select(x => x.Id).ToList();
|
||||
@@ -87,7 +89,7 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
|
||||
try
|
||||
{
|
||||
var toDelete = await channel.SendConfirmAsync($"{input} => {newInput}").ConfigureAwait(false);
|
||||
var toDelete = await channel.SendConfirmAsync(_eb, $"{input} => {newInput}").ConfigureAwait(false);
|
||||
var _ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(1500).ConfigureAwait(false);
|
||||
|
@@ -31,12 +31,13 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
private readonly ICurrencyService _currency;
|
||||
private readonly GamblingConfigService _gamblingConfigService;
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public DateTime LastUpdate { get; private set; } = DateTime.UtcNow;
|
||||
|
||||
public PatreonRewardsService(IBotCredentials creds, DbService db,
|
||||
ICurrencyService currency, IHttpClientFactory factory,
|
||||
ICurrencyService currency, IHttpClientFactory factory, IEmbedBuilderService eb,
|
||||
DiscordSocketClient client, GamblingConfigService gamblingConfigService)
|
||||
{
|
||||
_creds = creds;
|
||||
@@ -44,6 +45,7 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
_currency = currency;
|
||||
_gamblingConfigService = gamblingConfigService;
|
||||
_httpFactory = factory;
|
||||
_eb = eb;
|
||||
_client = client;
|
||||
|
||||
if (client.ShardId == 0)
|
||||
@@ -211,7 +213,7 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
return;
|
||||
|
||||
var channel = await user.GetOrCreateDMChannelAsync();
|
||||
await channel.SendConfirmAsync(message);
|
||||
await channel.SendConfirmAsync(_eb, message);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@@ -21,12 +21,14 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly DbService _db;
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
|
||||
public RemindService(DiscordSocketClient client, DbService db, IBotCredentials creds)
|
||||
public RemindService(DiscordSocketClient client, DbService db, IBotCredentials creds, IEmbedBuilderService eb)
|
||||
{
|
||||
_client = client;
|
||||
_db = db;
|
||||
_creds = creds;
|
||||
_eb = eb;
|
||||
_ = StartReminderLoop();
|
||||
}
|
||||
|
||||
@@ -167,7 +169,7 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
if (ch is null)
|
||||
return;
|
||||
|
||||
await ch.EmbedAsync(new EmbedBuilder()
|
||||
await ch.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("Reminder")
|
||||
.AddField("Created At", r.DateAdded.HasValue ? r.DateAdded.Value.ToLongDateString() : "?")
|
||||
|
@@ -26,16 +26,18 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
|
||||
private readonly DbService _db;
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private LinkedList<RunningRepeater> _repeaterQueue;
|
||||
private ConcurrentHashSet<int> _noRedundant;
|
||||
|
||||
private readonly object _queueLocker = new object();
|
||||
|
||||
public RepeaterService(DiscordSocketClient client, DbService db, IBotCredentials creds)
|
||||
public RepeaterService(DiscordSocketClient client, DbService db, IBotCredentials creds, IEmbedBuilderService eb)
|
||||
{
|
||||
_db = db;
|
||||
_creds = creds;
|
||||
_eb = eb;
|
||||
_client = client;
|
||||
|
||||
var uow = _db.GetDbContext();
|
||||
@@ -261,7 +263,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
if (CREmbed.TryParse(repeater.Message, out var crEmbed))
|
||||
{
|
||||
rep.Replace(crEmbed);
|
||||
newMsg = await channel.EmbedAsync(crEmbed);
|
||||
newMsg = await channel.EmbedAsync(crEmbed, _eb);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user