diff --git a/src/Fergun.csproj b/src/Fergun.csproj index 88c4b6d..2fbc33a 100644 --- a/src/Fergun.csproj +++ b/src/Fergun.csproj @@ -13,9 +13,9 @@ - - - + + + diff --git a/src/Modules/UtilityModule.cs b/src/Modules/UtilityModule.cs index 73ffd30..ee7dab5 100644 --- a/src/Modules/UtilityModule.cs +++ b/src/Modules/UtilityModule.cs @@ -388,13 +388,13 @@ public async Task HelpAsync() links.Add(Format.Url(_localizer["Donate"], _fergunOptions.DonationUrl)); } - string joinedLinks = string.Join(" | ", links); - var page = new PageBuilder() .WithTitle(_localizer["FergunHelp"]) .WithDescription(description) .WithColor(Color.Orange); + string joinedLinks = string.Join(" | ", links); + if (!string.IsNullOrEmpty(joinedLinks)) { page.AddField(_localizer["Links"], joinedLinks); @@ -413,31 +413,28 @@ public async Task HelpAsync() var modules = _commands.Modules.Where(x => x.Name is not nameof(OwnerModule) and not nameof(BlacklistModule)) .ToDictionary(x => x.Name, x => x); - InteractiveMessageResult? result = null; - var interaction = Context.Interaction; - var responseType = InteractionResponseType.ChannelMessageWithSource; - _logger.LogInformation("Displaying help menu to user {User} ({Id})", Context.User, Context.User.Id); - while (result is null || result.Status == InteractiveStatus.Success) - { - var selection = new SelectionBuilder() - .AddUser(Context.User) - .WithOptions(categories) - .WithEmoteConverter(x => x.Emote) - .WithStringConverter(x => x.Name) - .WithInputType(InputType.SelectMenus) - .WithSelectionPage(page) - .WithActionOnTimeout(ActionOnStop.DisableInput) - .Build(); + var menu = new MenuSelectionBuilder() + .AddUser(Context.User) + .WithOptions(categories) + .WithEmoteConverter(x => x.Emote) + .WithStringConverter(x => x.Name) + .WithPlaceholder(_localizer["HelpMenuPlaceholder"]) + .WithInputHandler(SetModule) + .WithSetDefaultValues(true) + .WithInputType(InputType.SelectMenus) + .WithSelectionPage(page) + .WithActionOnTimeout(ActionOnStop.DisableInput) + .Build(); - result = await _interactive.SendSelectionAsync(selection, interaction, _fergunOptions.SelectionTimeout, responseType); + await _interactive.SendSelectionAsync(menu, Context.Interaction, _fergunOptions.SelectionTimeout); - if (!result.IsSuccess) break; + return FergunResult.FromSuccess(); - responseType = InteractionResponseType.UpdateMessage; - interaction = result.StopInteraction!; - var module = modules[result.Value.Name.Name]; + IPage SetModule(ModuleOption option) + { + var module = modules[option.Name.Name]; IEnumerable commandDescriptions; string locale = Context.Interaction.UserLocale; @@ -459,9 +456,9 @@ public async Task HelpAsync() .Select(x => $" - {x.DescriptionLocalizations.GetValueOrDefault(locale, x.Description)}"); } - page = new PageBuilder() - .WithTitle($"{result.Value.Emote} {_localizer[result.Value.Name]}") - .WithDescription(_localizer[result.Value.Description]) + var builder = new PageBuilder() + .WithTitle($"{option.Emote} {_localizer[option.Name]}") + .WithDescription(_localizer[option.Description]) .AddField(_localizer["Commands"], string.Join('\n', commandDescriptions)) .WithColor(Color.Orange); @@ -469,9 +466,9 @@ public async Task HelpAsync() { page.AddField(_localizer["Links"], joinedLinks); } - } - return FergunResult.FromSuccess(); + return builder.Build(); + } } [SlashCommand("ping", "Sends the response time of the bot.")] diff --git a/src/Resources/Modules.OtherModule.es.resx b/src/Resources/Modules.OtherModule.es.resx index e880429..baa56cf 100644 --- a/src/Resources/Modules.OtherModule.es.resx +++ b/src/Resources/Modules.OtherModule.es.resx @@ -210,6 +210,12 @@ Obtiene la letra de la canción que estás escuchando en Spotify. + + Nota + + + ℹ️ Usa {0} para obtener fácilmente la letra de la canción que estás escuchando. + Muestra las estadísticas de uso de los comandos. @@ -249,10 +255,7 @@ letra-spotify - - Nota - - - ℹ️ Usa {0} para obtener fácilmente la letra de la canción que estás escuchando. + + Selecciona una categoría \ No newline at end of file diff --git a/src/Resources/Modules.OtherModule.resx b/src/Resources/Modules.OtherModule.resx index a607278..604ce40 100644 --- a/src/Resources/Modules.OtherModule.resx +++ b/src/Resources/Modules.OtherModule.resx @@ -216,4 +216,7 @@ ℹ️ Use {0} to easily get the lyrics of the song you're currently listening to. + + Select a category + \ No newline at end of file