mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
- Reworked embed builder
- Use IEmbedBuilderService to create embed builders - Wrapped embed builder and using IEmbedBuilder
This commit is contained in:
@@ -22,6 +22,7 @@ namespace NadekoBot.Modules.Games.Services
|
||||
private readonly CommandHandler _cmd;
|
||||
private readonly IBotStrings _strings;
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
|
||||
public ConcurrentDictionary<ulong, Lazy<IChatterBotSession>> ChatterBotGuilds { get; }
|
||||
@@ -30,13 +31,14 @@ namespace NadekoBot.Modules.Games.Services
|
||||
|
||||
public ChatterBotService(DiscordSocketClient client, PermissionService perms,
|
||||
Bot bot, CommandHandler cmd, IBotStrings strings, IHttpClientFactory factory,
|
||||
IBotCredentials creds)
|
||||
IBotCredentials creds, IEmbedBuilderService eb)
|
||||
{
|
||||
_client = client;
|
||||
_perms = perms;
|
||||
_cmd = cmd;
|
||||
_strings = strings;
|
||||
_creds = creds;
|
||||
_eb = eb;
|
||||
_httpFactory = factory;
|
||||
|
||||
ChatterBotGuilds = new ConcurrentDictionary<ulong, Lazy<IChatterBotSession>>(
|
||||
@@ -86,18 +88,18 @@ namespace NadekoBot.Modules.Games.Services
|
||||
return message;
|
||||
}
|
||||
|
||||
public static async Task<bool> TryAsk(IChatterBotSession cleverbot, ITextChannel channel, string message)
|
||||
public async Task<bool> TryAsk(IChatterBotSession cleverbot, ITextChannel channel, string message)
|
||||
{
|
||||
await channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
|
||||
var response = await cleverbot.Think(message).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await channel.SendConfirmAsync(response.SanitizeMentions(true)).ConfigureAwait(false);
|
||||
await channel.SendConfirmAsync(_eb, response.SanitizeMentions(true)).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await channel.SendConfirmAsync(response.SanitizeMentions(true)).ConfigureAwait(false); // try twice :\
|
||||
await channel.SendConfirmAsync(_eb, response.SanitizeMentions(true)).ConfigureAwait(false); // try twice :\
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -121,7 +123,7 @@ namespace NadekoBot.Modules.Games.Services
|
||||
if (pc.Verbose)
|
||||
{
|
||||
var returnMsg = _strings.GetText("trigger", guild.Id, index + 1, Format.Bold(pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild)));
|
||||
try { await usrMsg.Channel.SendErrorAsync(returnMsg).ConfigureAwait(false); } catch { }
|
||||
try { await usrMsg.Channel.SendErrorAsync(_eb, returnMsg).ConfigureAwait(false); } catch { }
|
||||
Log.Information(returnMsg);
|
||||
}
|
||||
return true;
|
||||
|
@@ -23,11 +23,13 @@ namespace NadekoBot.Modules.Games.Services
|
||||
|
||||
private readonly DbService _db;
|
||||
private readonly IBotStrings _strs;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
|
||||
public PollService(DbService db, IBotStrings strs)
|
||||
public PollService(DbService db, IBotStrings strs, IEmbedBuilderService eb)
|
||||
{
|
||||
_db = db;
|
||||
_strs = strs;
|
||||
_eb = eb;
|
||||
|
||||
using (var uow = db.GetDbContext())
|
||||
{
|
||||
@@ -97,7 +99,7 @@ namespace NadekoBot.Modules.Games.Services
|
||||
|
||||
private async Task Pr_OnVoted(IUserMessage msg, IGuildUser usr)
|
||||
{
|
||||
var toDelete = await msg.Channel.SendConfirmAsync(_strs.GetText("poll_voted",
|
||||
var toDelete = await msg.Channel.SendConfirmAsync(_eb, _strs.GetText("poll_voted",
|
||||
usr.Guild.Id, Format.Bold(usr.ToString())))
|
||||
.ConfigureAwait(false);
|
||||
toDelete.DeleteAfter(5);
|
||||
|
Reference in New Issue
Block a user