mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
- Generator will now also add [NadekoDescription] attribute to commands
- CustomReactions module (and customreactions db table) renamed to Expressions. This was done to remove confusion about how it relates to discord Reactions (it doesn't, it was created and named before discord reactions existed) - Permissionv2 db table renamed to Permissions - Expression command now start with ex/expr and end with the name of the action or setting. For example .exd is expression delete - CommandStrings will now use methodname as the key, and not the command name (first entry in aliases.yml). In other words aliases.yml and commands.en-US.yml will use the same keys (once again).
This commit is contained in:
13
src/NadekoBot/Modules/Help/CommandJsonObject.cs
Normal file
13
src/NadekoBot/Modules/Help/CommandJsonObject.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
#nullable disable
|
||||
namespace NadekoBot.Modules.Help;
|
||||
|
||||
internal class CommandJsonObject
|
||||
{
|
||||
public string[] Aliases { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string[] Usage { get; set; }
|
||||
public string Submodule { get; set; }
|
||||
public string Module { get; set; }
|
||||
public List<string> Options { get; set; }
|
||||
public string[] Requirements { get; set; }
|
||||
}
|
@@ -12,8 +12,9 @@ namespace NadekoBot.Modules.Help;
|
||||
|
||||
public partial class Help : NadekoModule<HelpService>
|
||||
{
|
||||
public const string PatreonUrl = "https://patreon.com/nadekobot";
|
||||
public const string PaypalUrl = "https://paypal.me/Kwoth";
|
||||
public const string PATREON_URL = "https://patreon.com/nadekobot";
|
||||
public const string PAYPAL_URL = "https://paypal.me/Kwoth";
|
||||
|
||||
private readonly CommandService _cmds;
|
||||
private readonly BotConfigService _bss;
|
||||
private readonly GlobalPermissionService _perms;
|
||||
@@ -106,8 +107,8 @@ public partial class Help : NadekoModule<HelpService>
|
||||
return strs.module_description_help;
|
||||
case "administration":
|
||||
return strs.module_description_administration;
|
||||
case "customreactions":
|
||||
return strs.module_description_customreactions;
|
||||
case "expressions":
|
||||
return strs.module_description_expressions;
|
||||
case "searches":
|
||||
return strs.module_description_searches;
|
||||
case "utility":
|
||||
@@ -313,7 +314,7 @@ public partial class Help : NadekoModule<HelpService>
|
||||
.Select(com =>
|
||||
{
|
||||
List<string> optHelpStr = null;
|
||||
var opt = ((NadekoOptionsAttribute)com.Attributes.FirstOrDefault(x
|
||||
var opt = ((NadekoOptionsAttribute)com.Attributes.FirstOrDefault(static x
|
||||
=> x is NadekoOptionsAttribute))
|
||||
?.OptionType;
|
||||
if (opt is not null) optHelpStr = HelpService.GetCommandOptionHelpList(opt);
|
||||
@@ -371,7 +372,7 @@ public partial class Help : NadekoModule<HelpService>
|
||||
var versionListString = Encoding.UTF8.GetString(ms.ToArray());
|
||||
|
||||
var versionList = JsonSerializer.Deserialize<List<string>>(versionListString);
|
||||
if (!versionList.Contains(StatsService.BotVersion))
|
||||
if (versionList is not null && !versionList.Contains(StatsService.BotVersion))
|
||||
{
|
||||
// save the file with new version added
|
||||
// versionList.Add(StatsService.BotVersion);
|
||||
@@ -410,16 +411,5 @@ public partial class Help : NadekoModule<HelpService>
|
||||
|
||||
[Cmd]
|
||||
public async partial Task Donate()
|
||||
=> await ReplyConfirmLocalizedAsync(strs.donate(PatreonUrl, PaypalUrl));
|
||||
}
|
||||
|
||||
internal class CommandJsonObject
|
||||
{
|
||||
public string[] Aliases { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string[] Usage { get; set; }
|
||||
public string Submodule { get; set; }
|
||||
public string Module { get; set; }
|
||||
public List<string> Options { get; set; }
|
||||
public string[] Requirements { get; set; }
|
||||
=> await ReplyConfirmLocalizedAsync(strs.donate(PATREON_URL, PAYPAL_URL));
|
||||
}
|
@@ -62,11 +62,13 @@ public class HelpService : ILateExecutor, INService
|
||||
var alias = com.Aliases.Skip(1).FirstOrDefault();
|
||||
if (alias is not null)
|
||||
str += $" **/ `{prefix + alias}`**";
|
||||
|
||||
var em = _eb.Create().AddField(str, $"{com.RealSummary(_strings, guild?.Id, prefix)}", true);
|
||||
|
||||
_dpos.TryGetOverrides(guild?.Id ?? 0, com.Name, out var overrides);
|
||||
var reqs = GetCommandRequirements(com, overrides);
|
||||
if (reqs.Any()) em.AddField(GetText(strs.requires, guild), string.Join("\n", reqs));
|
||||
if (reqs.Any())
|
||||
em.AddField(GetText(strs.requires, guild), string.Join("\n", reqs));
|
||||
|
||||
em.AddField(_strings.GetText(strs.usage),
|
||||
string.Join("\n",
|
||||
@@ -128,6 +130,7 @@ public class HelpService : ILateExecutor, INService
|
||||
{
|
||||
if (userPerm.ChannelPermission is { } cPerm)
|
||||
userPermString = GetPreconditionString(cPerm);
|
||||
|
||||
if (userPerm.GuildPermission is { } gPerm)
|
||||
userPermString = GetPreconditionString(gPerm);
|
||||
}
|
||||
@@ -149,11 +152,11 @@ public class HelpService : ILateExecutor, INService
|
||||
}
|
||||
|
||||
public static string GetPreconditionString(ChannelPerm perm)
|
||||
=> (perm + " Channel Permission").Replace("Guild", "Server", StringComparison.InvariantCulture);
|
||||
=> (perm + " Channel Permission").Replace("Guild", "Server");
|
||||
|
||||
public static string GetPreconditionString(GuildPerm perm)
|
||||
=> (perm + " Server Permission").Replace("Guild", "Server", StringComparison.InvariantCulture);
|
||||
=> (perm + " Server Permission").Replace("Guild", "Server");
|
||||
|
||||
private string GetText(LocStr str, IGuild guild, params object[] replacements)
|
||||
private string GetText(LocStr str, IGuild guild)
|
||||
=> _strings.GetText(str, guild?.Id);
|
||||
}
|
Reference in New Issue
Block a user