mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 10:18:27 -04:00
Medusa System Added
Read about the medusa system [here](https://nadekobot.readthedocs.io/en/latest/medusa/creating-a-medusa/)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#nullable disable
|
||||
using Amazon.S3;
|
||||
using Nadeko.Medusa;
|
||||
using NadekoBot.Modules.Help.Common;
|
||||
using NadekoBot.Modules.Help.Services;
|
||||
using NadekoBot.Modules.Permissions.Services;
|
||||
@@ -23,6 +24,7 @@ public partial class Help : NadekoModule<HelpService>
|
||||
private readonly IBotStrings _strings;
|
||||
|
||||
private readonly AsyncLazy<ulong> _lazyClientId;
|
||||
private readonly IMedusaLoaderService _medusae;
|
||||
|
||||
public Help(
|
||||
GlobalPermissionService perms,
|
||||
@@ -30,7 +32,8 @@ public partial class Help : NadekoModule<HelpService>
|
||||
BotConfigService bss,
|
||||
IServiceProvider services,
|
||||
DiscordSocketClient client,
|
||||
IBotStrings strings)
|
||||
IBotStrings strings,
|
||||
IMedusaLoaderService medusae)
|
||||
{
|
||||
_cmds = cmds;
|
||||
_bss = bss;
|
||||
@@ -38,6 +41,7 @@ public partial class Help : NadekoModule<HelpService>
|
||||
_services = services;
|
||||
_client = client;
|
||||
_strings = strings;
|
||||
_medusae = medusae;
|
||||
|
||||
_lazyClientId = new(async () => (await _client.GetApplicationInfoAsync()).Id);
|
||||
}
|
||||
@@ -329,8 +333,8 @@ public partial class Help : NadekoModule<HelpService>
|
||||
return new CommandJsonObject
|
||||
{
|
||||
Aliases = com.Aliases.Select(alias => prefix + alias).ToArray(),
|
||||
Description = com.RealSummary(_strings, ctx.Guild?.Id, prefix),
|
||||
Usage = com.RealRemarksArr(_strings, ctx.Guild?.Id, prefix),
|
||||
Description = com.RealSummary(_strings, _medusae, Culture, prefix),
|
||||
Usage = com.RealRemarksArr(_strings, _medusae, Culture, prefix),
|
||||
Submodule = com.Module.Name,
|
||||
Module = com.Module.GetTopLevelModule().Name,
|
||||
Options = optHelpStr,
|
||||
|
@@ -1,33 +1,40 @@
|
||||
#nullable disable
|
||||
using CommandLine;
|
||||
using Nadeko.Medusa;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Modules.Administration.Services;
|
||||
|
||||
namespace NadekoBot.Modules.Help.Services;
|
||||
|
||||
public class HelpService : ILateExecutor, INService
|
||||
public class HelpService : IExecNoCommand, INService
|
||||
{
|
||||
private readonly CommandHandler _ch;
|
||||
private readonly IBotStrings _strings;
|
||||
private readonly DiscordPermOverrideService _dpos;
|
||||
private readonly BotConfigService _bss;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly ILocalization _loc;
|
||||
private readonly IMedusaLoaderService _medusae;
|
||||
|
||||
public HelpService(
|
||||
CommandHandler ch,
|
||||
IBotStrings strings,
|
||||
DiscordPermOverrideService dpos,
|
||||
BotConfigService bss,
|
||||
IEmbedBuilderService eb)
|
||||
IEmbedBuilderService eb,
|
||||
ILocalization loc,
|
||||
IMedusaLoaderService medusae)
|
||||
{
|
||||
_ch = ch;
|
||||
_strings = strings;
|
||||
_dpos = dpos;
|
||||
_bss = bss;
|
||||
_eb = eb;
|
||||
_loc = loc;
|
||||
_medusae = medusae;
|
||||
}
|
||||
|
||||
public Task LateExecute(IGuild guild, IUserMessage msg)
|
||||
public Task ExecOnNoCommandAsync(IGuild guild, IUserMessage msg)
|
||||
{
|
||||
var settings = _bss.Data;
|
||||
if (guild is null)
|
||||
@@ -57,13 +64,16 @@ public class HelpService : ILateExecutor, INService
|
||||
public IEmbedBuilder GetCommandHelp(CommandInfo com, IGuild guild)
|
||||
{
|
||||
var prefix = _ch.GetPrefix(guild);
|
||||
|
||||
|
||||
var str = $"**`{prefix + com.Aliases.First()}`**";
|
||||
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);
|
||||
var culture = _loc.GetCultureInfo(guild);
|
||||
|
||||
var em = _eb.Create()
|
||||
.AddField(str, $"{com.RealSummary(_strings, _medusae, culture, prefix)}", true);
|
||||
|
||||
_dpos.TryGetOverrides(guild?.Id ?? 0, com.Name, out var overrides);
|
||||
var reqs = GetCommandRequirements(com, overrides);
|
||||
@@ -72,7 +82,7 @@ public class HelpService : ILateExecutor, INService
|
||||
|
||||
em.AddField(_strings.GetText(strs.usage),
|
||||
string.Join("\n",
|
||||
Array.ConvertAll(com.RealRemarksArr(_strings, guild?.Id, prefix), arg => Format.Code(arg))))
|
||||
Array.ConvertAll(com.RealRemarksArr(_strings,_medusae, culture, prefix), arg => Format.Code(arg))))
|
||||
.WithFooter(GetText(strs.module(com.Module.GetTopLevelModule().Name), guild))
|
||||
.WithOkColor();
|
||||
|
||||
|
Reference in New Issue
Block a user