help fully localized, hgit might not work properly though, needs testing
This commit is contained in:
parent
e6af53d647
commit
e68608770f
@ -13,19 +13,26 @@ using System.Collections.Generic;
|
||||
namespace NadekoBot.Modules.Help
|
||||
{
|
||||
[NadekoModule("Help", "-")]
|
||||
public partial class Help : NadekoModule
|
||||
public class Help : NadekoModule
|
||||
{
|
||||
private static string helpString { get; } = NadekoBot.BotConfig.HelpString;
|
||||
public static string HelpString => String.Format(helpString, NadekoBot.Credentials.ClientId, NadekoBot.ModulePrefixes[typeof(Help).Name]);
|
||||
|
||||
public static string DMHelpString { get; } = NadekoBot.BotConfig.DMHelpString;
|
||||
|
||||
public const string PatreonUrl = "https://patreon.com/nadekobot";
|
||||
public const string PaypalUrl = "https://paypal.me/Kwoth";
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task Modules()
|
||||
{
|
||||
|
||||
var embed = new EmbedBuilder().WithOkColor().WithFooter(efb => efb.WithText($" ℹ️ Type `-cmds ModuleName` to get a list of commands in that module. eg `-cmds games`"))
|
||||
.WithTitle("📜 List Of Modules").WithDescription("\n• " + string.Join("\n• ", NadekoBot.CommandService.Modules.GroupBy(m => m.GetTopLevelModule()).Select(m => m.Key.Name).OrderBy(s => s)));
|
||||
var embed = new EmbedBuilder().WithOkColor()
|
||||
.WithFooter(efb => efb.WithText("ℹ️" + GetText("modules_footer", Prefix)))
|
||||
.WithTitle(GetText("list_of_modules"))
|
||||
.WithDescription(string.Join("\n",
|
||||
NadekoBot.CommandService.Modules.GroupBy(m => m.GetTopLevelModule())
|
||||
.Select(m => "• " + m.Key.Name)
|
||||
.OrderBy(s => s)));
|
||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@ -45,18 +52,13 @@ namespace NadekoBot.Modules.Help
|
||||
var cmdsArray = cmds as CommandInfo[] ?? cmds.ToArray();
|
||||
if (!cmdsArray.Any())
|
||||
{
|
||||
await channel.SendErrorAsync("That module does not exist.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("module_not_found").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (module != "customreactions" && module != "conversations")
|
||||
{
|
||||
await channel.SendTableAsync("📃 **List Of Commands:**\n", cmdsArray, el => $"{el.Aliases.First(),-15} {"["+el.Aliases.Skip(1).FirstOrDefault()+"]",-8}").ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await channel.SendMessageAsync("📃 **List Of Commands:**\n• " + string.Join("\n• ", cmdsArray.Select(c => $"{c.Aliases.First()}")));
|
||||
}
|
||||
await channel.SendConfirmAsync($"ℹ️ **Type** `\"{NadekoBot.ModulePrefixes[typeof(Help).Name]}h CommandName\"` **to see the help for that specified command.** ***e.g.*** `-h >8ball`").ConfigureAwait(false);
|
||||
|
||||
await channel.SendTableAsync($"📃 **{GetText("list_of_commands")}**\n", cmdsArray, el => $"{el.Aliases.First(),-15} {"["+el.Aliases.Skip(1).FirstOrDefault()+"]",-8}").ConfigureAwait(false);
|
||||
|
||||
await ConfirmLocalized("commands_instr", Prefix).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -75,32 +77,33 @@ namespace NadekoBot.Modules.Help
|
||||
|
||||
if (com == null)
|
||||
{
|
||||
await channel.SendErrorAsync("I can't find that command. Please check the **command** and **command prefix** before trying again.");
|
||||
await ReplyErrorLocalized("command_not_found").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var str = $"**`{com.Aliases.First()}`**";
|
||||
var str = string.Format("**`{0}`**", com.Aliases.First());
|
||||
var alias = com.Aliases.Skip(1).FirstOrDefault();
|
||||
if (alias != null)
|
||||
str += $" **/ `{alias}`**";
|
||||
str += string.Format(" **/ `{0}`**", alias);
|
||||
var embed = new EmbedBuilder()
|
||||
.AddField(fb => fb.WithName(str).WithValue($"{ string.Format(com.Summary, com.Module.Aliases.First())} { GetCommandRequirements(com)}").WithIsInline(true))
|
||||
.AddField(fb => fb.WithName("**Usage**").WithValue($"{string.Format(com.Remarks, com.Module.Aliases.First())}").WithIsInline(false))
|
||||
.AddField(fb => fb.WithName(str).WithValue($"{string.Format(com.Summary, com.Module.Aliases.First())} {GetCommandRequirements(com)}").WithIsInline(true))
|
||||
.AddField(fb => fb.WithName(GetText("usage")).WithValue(string.Format(com.Remarks, com.Module.Aliases.First())).WithIsInline(false))
|
||||
.WithColor(NadekoBot.OkColor);
|
||||
await channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private string GetCommandRequirements(CommandInfo cmd) =>
|
||||
String.Join(" ", cmd.Preconditions
|
||||
string.Join(" ", cmd.Preconditions
|
||||
.Where(ca => ca is OwnerOnlyAttribute || ca is RequireUserPermissionAttribute)
|
||||
.Select(ca =>
|
||||
{
|
||||
if (ca is OwnerOnlyAttribute)
|
||||
return "**Bot Owner only.**";
|
||||
return Format.Bold(GetText("bot_owner_only"));
|
||||
var cau = (RequireUserPermissionAttribute)ca;
|
||||
if (cau.GuildPermission != null)
|
||||
return $"**Requires {cau.GuildPermission} server permission.**".Replace("Guild", "Server");
|
||||
else
|
||||
return $"**Requires {cau.ChannelPermission} channel permission.**".Replace("Guild", "Server");
|
||||
return Format.Bold(GetText("server_permission", cau.GuildPermission))
|
||||
.Replace("Guild", "Server");
|
||||
return Format.Bold(GetText("channel_permission", cau.ChannelPermission))
|
||||
.Replace("Guild", "Server");
|
||||
}));
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -109,14 +112,14 @@ namespace NadekoBot.Modules.Help
|
||||
public async Task Hgit()
|
||||
{
|
||||
var helpstr = new StringBuilder();
|
||||
helpstr.AppendLine("You can support the project on patreon: <https://patreon.com/nadekobot> or paypal: <https://www.paypal.me/Kwoth>\n");
|
||||
helpstr.AppendLine("##Table Of Contents");
|
||||
helpstr.AppendLine(GetText("cmdlist_donate", PatreonUrl, PaypalUrl) + "\n");
|
||||
helpstr.AppendLine("##"+ GetText("table_of_contents"));
|
||||
helpstr.AppendLine(string.Join("\n", NadekoBot.CommandService.Modules.Where(m => m.GetTopLevelModule().Name.ToLowerInvariant() != "help")
|
||||
.Select(m => m.GetTopLevelModule().Name)
|
||||
.Distinct()
|
||||
.OrderBy(m => m)
|
||||
.Prepend("Help")
|
||||
.Select(m => $"- [{m}](#{m.ToLowerInvariant()})")));
|
||||
.Select(m => string.Format("- [{0}](#{1})", m, m.ToLowerInvariant()))));
|
||||
helpstr.AppendLine();
|
||||
string lastModule = null;
|
||||
foreach (var com in NadekoBot.CommandService.Commands.OrderBy(com => com.Module.GetTopLevelModule().Name).GroupBy(c => c.Aliases.First()).Select(g => g.First()))
|
||||
@ -127,44 +130,35 @@ namespace NadekoBot.Modules.Help
|
||||
if (lastModule != null)
|
||||
{
|
||||
helpstr.AppendLine();
|
||||
helpstr.AppendLine("###### [Back to TOC](#table-of-contents)");
|
||||
helpstr.AppendLine($"###### [{GetText("back_to_toc")}](#{GetText("table_of_contents").ToLowerInvariant().Replace(' ', '-')})");
|
||||
}
|
||||
helpstr.AppendLine();
|
||||
helpstr.AppendLine("### " + module.Name + " ");
|
||||
helpstr.AppendLine("Command and aliases | Description | Usage");
|
||||
helpstr.AppendLine($"{GetText("cmd_and_alias")} | {GetText("desc")} | {GetText("usage")}");
|
||||
helpstr.AppendLine("----------------|--------------|-------");
|
||||
lastModule = module.Name;
|
||||
}
|
||||
helpstr.AppendLine($"{string.Join(" ", com.Aliases.Select(a => "`" + a + "`"))} | {string.Format(com.Summary, com.Module.GetPrefix())} {GetCommandRequirements(com)} | {string.Format(com.Remarks, com.Module.GetPrefix())}");
|
||||
helpstr.AppendLine($"{string.Join(" ", com.Aliases.Select(a => "`" + a + "`"))} |" +
|
||||
$" {string.Format(com.Summary, com.Module.GetPrefix())} {GetCommandRequirements(com)} |" +
|
||||
$" {string.Format(com.Remarks, com.Module.GetPrefix())}");
|
||||
}
|
||||
helpstr = helpstr.Replace(NadekoBot.Client.CurrentUser.Username , "@BotName");
|
||||
File.WriteAllText("../../docs/Commands List.md", helpstr.ToString());
|
||||
await Context.Channel.SendConfirmAsync("Commandlist Regenerated").ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("commandlist_regen").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Guide()
|
||||
{
|
||||
var channel = (ITextChannel)Context.Channel;
|
||||
|
||||
await channel.SendConfirmAsync(
|
||||
@"**LIST OF COMMANDS**: <http://nadekobot.readthedocs.io/en/latest/Commands%20List/>
|
||||
**Hosting Guides and docs can be found here**: <http://nadekobot.readthedocs.io/en/latest/>").ConfigureAwait(false);
|
||||
await ConfirmLocalized("guide",
|
||||
"http://nadekobot.readthedocs.io/en/latest/Commands%20List/",
|
||||
"http://nadekobot.readthedocs.io/en/latest/").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Donate()
|
||||
{
|
||||
var channel = (ITextChannel)Context.Channel;
|
||||
|
||||
await channel.SendConfirmAsync(
|
||||
$@"You can support the NadekoBot project on patreon. <https://patreon.com/nadekobot> or
|
||||
Paypal <https://paypal.me/Kwoth>
|
||||
Don't forget to leave your discord name or id in the message.
|
||||
|
||||
**Thank you** ♥️").ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("donate", PatreonUrl, PaypalUrl).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace NadekoBot.Modules
|
||||
public readonly string ModuleTypeName;
|
||||
public readonly string LowerModuleTypeName;
|
||||
|
||||
public NadekoModule(bool isTopLevelModule = true)
|
||||
protected NadekoModule(bool isTopLevelModule = true)
|
||||
{
|
||||
//if it's top level module
|
||||
ModuleTypeName = isTopLevelModule ? this.GetType().Name : this.GetType().DeclaringType.Name;
|
||||
@ -81,7 +81,7 @@ namespace NadekoBot.Modules
|
||||
GetTextStatic(key, _cultureInfo, LowerModuleTypeName);
|
||||
|
||||
protected string GetText(string key, params object[] replacements) =>
|
||||
GetText(key, _cultureInfo, LowerModuleTypeName, replacements);
|
||||
GetTextStatic(key, _cultureInfo, LowerModuleTypeName, replacements);
|
||||
|
||||
public Task<IUserMessage> ErrorLocalized(string textKey, params object[] replacements)
|
||||
{
|
||||
@ -110,7 +110,7 @@ namespace NadekoBot.Modules
|
||||
|
||||
public abstract class NadekoSubmodule : NadekoModule
|
||||
{
|
||||
public NadekoSubmodule() : base(false)
|
||||
protected NadekoSubmodule() : base(false)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
168
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
168
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
@ -383,6 +383,174 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Back to ToC.
|
||||
/// </summary>
|
||||
public static string help_back_to_toc {
|
||||
get {
|
||||
return ResourceManager.GetString("help_back_to_toc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bot Owner Only.
|
||||
/// </summary>
|
||||
public static string help_bot_owner_only {
|
||||
get {
|
||||
return ResourceManager.GetString("help_bot_owner_only", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Requires {0} channel permission..
|
||||
/// </summary>
|
||||
public static string help_channel_permission {
|
||||
get {
|
||||
return ResourceManager.GetString("help_channel_permission", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Command and aliases.
|
||||
/// </summary>
|
||||
public static string help_cmd_and_alias {
|
||||
get {
|
||||
return ResourceManager.GetString("help_cmd_and_alias", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You can support the project on patreon: <{0}> or paypal: <{1}>.
|
||||
/// </summary>
|
||||
public static string help_cmdlist_donate {
|
||||
get {
|
||||
return ResourceManager.GetString("help_cmdlist_donate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to I can't find that command. Please verify that the command exists before trying again..
|
||||
/// </summary>
|
||||
public static string help_command_not_found {
|
||||
get {
|
||||
return ResourceManager.GetString("help_command_not_found", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Commandlist Regenerated..
|
||||
/// </summary>
|
||||
public static string help_commandlist_regen {
|
||||
get {
|
||||
return ResourceManager.GetString("help_commandlist_regen", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Type `{0}h CommandName` to see the help for that specified command. e.g. `{0}h >8ball`.
|
||||
/// </summary>
|
||||
public static string help_commands_instr {
|
||||
get {
|
||||
return ResourceManager.GetString("help_commands_instr", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Description.
|
||||
/// </summary>
|
||||
public static string help_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("help_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You can support the NadekoBot project on
|
||||
///Patreon <{0}> or
|
||||
///Paypal <{1}>
|
||||
///Don't forget to leave your discord name or id in the message.
|
||||
///
|
||||
///**Thank you** ♥️.
|
||||
/// </summary>
|
||||
public static string help_donate {
|
||||
get {
|
||||
return ResourceManager.GetString("help_donate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to **List of Commands**: <{0}>
|
||||
///**Hosting Guides and docs can be found here**: <{1}>.
|
||||
/// </summary>
|
||||
public static string help_guide {
|
||||
get {
|
||||
return ResourceManager.GetString("help_guide", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to List Of Commands.
|
||||
/// </summary>
|
||||
public static string help_list_of_commands {
|
||||
get {
|
||||
return ResourceManager.GetString("help_list_of_commands", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to List Of Modules.
|
||||
/// </summary>
|
||||
public static string help_list_of_modules {
|
||||
get {
|
||||
return ResourceManager.GetString("help_list_of_modules", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to That module does not exist..
|
||||
/// </summary>
|
||||
public static string help_module_not_found {
|
||||
get {
|
||||
return ResourceManager.GetString("help_module_not_found", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Type `{0}cmds ModuleName` to get a list of commands in that module. eg `{0}cmds games`.
|
||||
/// </summary>
|
||||
public static string help_modules_footer {
|
||||
get {
|
||||
return ResourceManager.GetString("help_modules_footer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Requires {0} server permission..
|
||||
/// </summary>
|
||||
public static string help_server_permission {
|
||||
get {
|
||||
return ResourceManager.GetString("help_server_permission", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Table Of Contents.
|
||||
/// </summary>
|
||||
public static string help_table_of_contents {
|
||||
get {
|
||||
return ResourceManager.GetString("help_table_of_contents", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Usage.
|
||||
/// </summary>
|
||||
public static string help_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("help_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Autohentai started. Reposting every {0}s with one of the following tags:
|
||||
///{1}.
|
||||
|
@ -298,6 +298,66 @@
|
||||
<data name="pokemon_you_fainted" xml:space="preserve">
|
||||
<value>You fainted, so you are not able to move!</value>
|
||||
</data>
|
||||
<data name="help_back_to_toc" xml:space="preserve">
|
||||
<value>Back to ToC</value>
|
||||
</data>
|
||||
<data name="help_bot_owner_only" xml:space="preserve">
|
||||
<value>Bot Owner Only</value>
|
||||
</data>
|
||||
<data name="help_channel_permission" xml:space="preserve">
|
||||
<value>Requires {0} channel permission.</value>
|
||||
</data>
|
||||
<data name="help_cmdlist_donate" xml:space="preserve">
|
||||
<value>You can support the project on patreon: <{0}> or paypal: <{1}></value>
|
||||
</data>
|
||||
<data name="help_cmd_and_alias" xml:space="preserve">
|
||||
<value>Command and aliases</value>
|
||||
</data>
|
||||
<data name="help_commandlist_regen" xml:space="preserve">
|
||||
<value>Commandlist Regenerated.</value>
|
||||
</data>
|
||||
<data name="help_commands_instr" xml:space="preserve">
|
||||
<value>Type `{0}h CommandName` to see the help for that specified command. e.g. `{0}h >8ball`</value>
|
||||
</data>
|
||||
<data name="help_command_not_found" xml:space="preserve">
|
||||
<value>I can't find that command. Please verify that the command exists before trying again.</value>
|
||||
</data>
|
||||
<data name="help_desc" xml:space="preserve">
|
||||
<value>Description</value>
|
||||
</data>
|
||||
<data name="help_donate" xml:space="preserve">
|
||||
<value>You can support the NadekoBot project on
|
||||
Patreon <{0}> or
|
||||
Paypal <{1}>
|
||||
Don't forget to leave your discord name or id in the message.
|
||||
|
||||
**Thank you** ♥️</value>
|
||||
</data>
|
||||
<data name="help_guide" xml:space="preserve">
|
||||
<value>**List of Commands**: <{0}>
|
||||
**Hosting Guides and docs can be found here**: <{1}></value>
|
||||
</data>
|
||||
<data name="help_list_of_commands" xml:space="preserve">
|
||||
<value>List Of Commands</value>
|
||||
</data>
|
||||
<data name="help_list_of_modules" xml:space="preserve">
|
||||
<value>List Of Modules</value>
|
||||
</data>
|
||||
<data name="help_modules_footer" xml:space="preserve">
|
||||
<value>Type `{0}cmds ModuleName` to get a list of commands in that module. eg `{0}cmds games`</value>
|
||||
</data>
|
||||
<data name="help_module_not_found" xml:space="preserve">
|
||||
<value>That module does not exist.</value>
|
||||
</data>
|
||||
<data name="help_server_permission" xml:space="preserve">
|
||||
<value>Requires {0} server permission.</value>
|
||||
</data>
|
||||
<data name="help_table_of_contents" xml:space="preserve">
|
||||
<value>Table Of Contents</value>
|
||||
</data>
|
||||
<data name="help_usage" xml:space="preserve">
|
||||
<value>Usage</value>
|
||||
</data>
|
||||
<data name="nsfw_autohentai_started" xml:space="preserve">
|
||||
<value>Autohentai started. Reposting every {0}s with one of the following tags:
|
||||
{1}</value>
|
||||
|
Loading…
Reference in New Issue
Block a user