Dm help string now allows usage of embed strings

This commit is contained in:
Master Kwoth 2017-11-15 20:39:51 +01:00
parent 5d4fdea620
commit b6a1e9a420
2 changed files with 15 additions and 6 deletions

View File

@ -24,7 +24,6 @@ namespace NadekoBot.Modules.Help
private readonly GlobalPermissionService _perms;
public string HelpString => String.Format(_config.BotConfig.HelpString, _creds.ClientId, Prefix);
public string DMHelpString => _config.BotConfig.DMHelpString;
public Help(IBotCredentials creds, GlobalPermissionService perms, IBotConfigProvider config, CommandService cmds)
{

View File

@ -9,6 +9,8 @@ using NadekoBot.Common.Attributes;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Core.Services;
using NadekoBot.Core.Services.Impl;
using NadekoBot.Common;
using NLog;
namespace NadekoBot.Modules.Help.Services
{
@ -17,26 +19,34 @@ namespace NadekoBot.Modules.Help.Services
private readonly IBotConfigProvider _bc;
private readonly CommandHandler _ch;
private readonly NadekoStrings _strings;
private readonly Logger _log;
public HelpService(IBotConfigProvider bc, CommandHandler ch, NadekoStrings strings)
{
_bc = bc;
_ch = ch;
_strings = strings;
_log = LogManager.GetCurrentClassLogger();
}
public async Task LateExecute(DiscordSocketClient client, IGuild guild, IUserMessage msg)
public Task LateExecute(DiscordSocketClient client, IGuild guild, IUserMessage msg)
{
try
{
if(guild == null)
await msg.Channel.SendMessageAsync(_bc.BotConfig.DMHelpString).ConfigureAwait(false);
}
catch (Exception)
if (guild == null)
{
//ignore
if (CREmbed.TryParse(_bc.BotConfig.DMHelpString, out var embed))
return msg.Channel.EmbedAsync(embed.ToEmbed(), embed.PlainText?.SanitizeMentions() ?? "");
return msg.Channel.SendMessageAsync(_bc.BotConfig.DMHelpString);
}
}
catch (Exception ex)
{
_log.Warn(ex);
}
return Task.CompletedTask;
}
public EmbedBuilder GetCommandHelp(CommandInfo com, IGuild guild)
{