mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 10:18:27 -04:00
Finished new response system
This commit is contained in:
@@ -84,32 +84,32 @@ public sealed class Help : NadekoModule<HelpService>
|
||||
topLevelModules.Add(m);
|
||||
}
|
||||
|
||||
await ctx.SendPaginatedConfirmAsync(page,
|
||||
cur =>
|
||||
{
|
||||
var embed = new EmbedBuilder().WithOkColor().WithTitle(GetText(strs.list_of_modules));
|
||||
await Response()
|
||||
.Paginated()
|
||||
.Items(topLevelModules)
|
||||
.CurrentPage(page)
|
||||
.AddFooter(false)
|
||||
.Page((items, _) =>
|
||||
{
|
||||
var embed = _sender.CreateEmbed().WithOkColor().WithTitle(GetText(strs.list_of_modules));
|
||||
|
||||
var localModules = topLevelModules.Skip(12 * cur).Take(12).ToList();
|
||||
if (!items.Any())
|
||||
{
|
||||
embed = embed.WithOkColor().WithDescription(GetText(strs.module_page_empty));
|
||||
return embed;
|
||||
}
|
||||
|
||||
if (!localModules.Any())
|
||||
{
|
||||
embed = embed.WithOkColor().WithDescription(GetText(strs.module_page_empty));
|
||||
return embed;
|
||||
}
|
||||
items.OrderBy(module => module.Name)
|
||||
.ToList()
|
||||
.ForEach(module => embed.AddField($"{GetModuleEmoji(module.Name)} {module.Name}",
|
||||
GetModuleDescription(module.Name)
|
||||
+ "\n"
|
||||
+ Format.Code(GetText(strs.module_footer(prefix, module.Name.ToLowerInvariant()))),
|
||||
true));
|
||||
|
||||
localModules.OrderBy(module => module.Name)
|
||||
.ToList()
|
||||
.ForEach(module => embed.AddField($"{GetModuleEmoji(module.Name)} {module.Name}",
|
||||
GetModuleDescription(module.Name)
|
||||
+ "\n"
|
||||
+ Format.Code(GetText(strs.module_footer(prefix, module.Name.ToLowerInvariant()))),
|
||||
true));
|
||||
|
||||
return embed;
|
||||
},
|
||||
topLevelModules.Count(),
|
||||
12,
|
||||
false);
|
||||
return embed;
|
||||
})
|
||||
.SendAsync();
|
||||
}
|
||||
|
||||
private string GetModuleDescription(string moduleName)
|
||||
@@ -271,7 +271,7 @@ public sealed class Help : NadekoModule<HelpService>
|
||||
|
||||
var cnt = 0;
|
||||
var groups = cmdsWithGroup.GroupBy(_ => cnt++ / 48).ToArray();
|
||||
var embed = new EmbedBuilder().WithOkColor();
|
||||
var embed = _sender.CreateEmbed().WithOkColor();
|
||||
foreach (var g in groups)
|
||||
{
|
||||
var last = g.Count();
|
||||
@@ -303,9 +303,9 @@ public sealed class Help : NadekoModule<HelpService>
|
||||
|
||||
private async Task Group(ModuleInfo group)
|
||||
{
|
||||
var eb = new EmbedBuilder()
|
||||
.WithTitle(GetText(strs.cmd_group_commands(group.Name)))
|
||||
.WithOkColor();
|
||||
var eb = _sender.CreateEmbed()
|
||||
.WithTitle(GetText(strs.cmd_group_commands(group.Name)))
|
||||
.WithOkColor();
|
||||
|
||||
foreach (var cmd in group.Commands.DistinctBy(x => x.Aliases[0]))
|
||||
{
|
||||
@@ -358,7 +358,8 @@ public sealed class Help : NadekoModule<HelpService>
|
||||
var data = await GetHelpString();
|
||||
if (data == default)
|
||||
return;
|
||||
await ch.SendAsync(data);
|
||||
|
||||
await Response().Text(data).SendAsync();
|
||||
try
|
||||
{
|
||||
await ctx.OkAsync();
|
||||
@@ -534,9 +535,9 @@ public sealed class Help : NadekoModule<HelpService>
|
||||
label: "Selfhosting"),
|
||||
SelfhostAction));
|
||||
|
||||
var eb = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("Thank you for considering to donate to the NadekoBot project!");
|
||||
var eb = _sender.CreateEmbed()
|
||||
.WithOkColor()
|
||||
.WithTitle("Thank you for considering to donate to the NadekoBot project!");
|
||||
|
||||
eb
|
||||
.WithDescription("NadekoBot relies on donations to keep the servers, services and APIs running.\n"
|
||||
@@ -575,7 +576,12 @@ Nadeko will DM you the welcome instructions, and you may start using the patron-
|
||||
|
||||
try
|
||||
{
|
||||
await (await ctx.User.CreateDMChannelAsync()).EmbedAsync(eb, inter: selfhostInter);
|
||||
await Response()
|
||||
.Channel(await ctx.User.CreateDMChannelAsync())
|
||||
.Embed(eb)
|
||||
.Interaction(selfhostInter)
|
||||
.SendAsync();
|
||||
|
||||
_ = ctx.OkAsync();
|
||||
}
|
||||
catch
|
||||
|
@@ -2,11 +2,22 @@ using NadekoBot.Common.ModuleBehaviors;
|
||||
|
||||
namespace NadekoBot.Modules.Help.Services;
|
||||
|
||||
public class HelpService(BotConfigService bss, IReplacementService repSvc) : IExecNoCommand, INService
|
||||
public class HelpService : IExecNoCommand, INService
|
||||
{
|
||||
private readonly BotConfigService _bss;
|
||||
private readonly IReplacementService _rs;
|
||||
private readonly IMessageSenderService _sender;
|
||||
|
||||
public HelpService(BotConfigService bss, IReplacementService repSvc, IMessageSenderService sender)
|
||||
{
|
||||
_bss = bss;
|
||||
_rs = repSvc;
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
public async Task ExecOnNoCommandAsync(IGuild? guild, IUserMessage msg)
|
||||
{
|
||||
var settings = bss.Data;
|
||||
var settings = _bss.Data;
|
||||
if (guild is null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(settings.DmHelpText) || settings.DmHelpText == "-")
|
||||
@@ -14,20 +25,20 @@ public class HelpService(BotConfigService bss, IReplacementService repSvc) : IEx
|
||||
|
||||
// only send dm help text if it contains one of the keywords, if they're specified
|
||||
// if they're not, then reply to every DM
|
||||
if (settings.DmHelpTextKeywords is not null &&
|
||||
!settings.DmHelpTextKeywords.Any(k => msg.Content.Contains(k)))
|
||||
if (settings.DmHelpTextKeywords is not null
|
||||
&& !settings.DmHelpTextKeywords.Any(k => msg.Content.Contains(k)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var repCtx = new ReplacementContext(guild: guild, channel: msg.Channel, users: msg.Author)
|
||||
.WithOverride("%prefix%", () => bss.Data.Prefix)
|
||||
.WithOverride("%bot.prefix%", () => bss.Data.Prefix);
|
||||
.WithOverride("%prefix%", () => _bss.Data.Prefix)
|
||||
.WithOverride("%bot.prefix%", () => _bss.Data.Prefix);
|
||||
|
||||
var text = SmartText.CreateFrom(settings.DmHelpText);
|
||||
text = await repSvc.ReplaceAsync(text, repCtx);
|
||||
text = await _rs.ReplaceAsync(text, repCtx);
|
||||
|
||||
await msg.Channel.SendAsync(text);
|
||||
await _sender.Response(msg.Channel).Text(text).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user