From 366f6de9dd30d598c13ecf42d1dc061979cf93aa Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Wed, 15 Nov 2017 20:52:34 +0100 Subject: [PATCH] You can now use embedbuilder in HelpString and DMHelpString --- NadekoBot.Core/Modules/Help/Help.cs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/NadekoBot.Core/Modules/Help/Help.cs b/NadekoBot.Core/Modules/Help/Help.cs index c6c0dfe4..4f5efac3 100644 --- a/NadekoBot.Core/Modules/Help/Help.cs +++ b/NadekoBot.Core/Modules/Help/Help.cs @@ -11,6 +11,8 @@ using System.Collections.Generic; using NadekoBot.Common.Attributes; using NadekoBot.Modules.Help.Services; using NadekoBot.Modules.Permissions.Services; +using NadekoBot.Common; +using NadekoBot.Common.Replacements; namespace NadekoBot.Modules.Help { @@ -23,7 +25,23 @@ namespace NadekoBot.Modules.Help private readonly CommandService _cmds; private readonly GlobalPermissionService _perms; - public string HelpString => String.Format(_config.BotConfig.HelpString, _creds.ClientId, Prefix); + public EmbedBuilder GetHelpStringEmbed() + { + var r = new ReplacementBuilder() + .WithDefault(Context) + .WithOverride("{0}", () => _creds.ClientId.ToString()) + .WithOverride("{1}", () => Prefix) + .Build(); + + + if (!CREmbed.TryParse(_config.BotConfig.HelpString, out var embed)) + return new EmbedBuilder().WithOkColor() + .WithDescription(String.Format(_config.BotConfig.HelpString, _creds.ClientId, Prefix)); + + r.Replace(embed); + + return embed.ToEmbed(); + } public Help(IBotCredentials creds, GlobalPermissionService perms, IBotConfigProvider config, CommandService cmds) { @@ -93,16 +111,10 @@ namespace NadekoBot.Modules.Help if (com == null) { IMessageChannel ch = channel is ITextChannel ? await ((IGuildUser)Context.User).GetOrCreateDMChannelAsync() : channel; - await ch.SendMessageAsync(HelpString).ConfigureAwait(false); + await ch.EmbedAsync(GetHelpStringEmbed()).ConfigureAwait(false); return; } - //if (com == null) - //{ - // await ReplyErrorLocalized("command_not_found").ConfigureAwait(false); - // return; - //} - var embed = _service.GetCommandHelp(com, Context.Guild); await channel.EmbedAsync(embed).ConfigureAwait(false); }