Closed WilliamAcosta1 closed 6 months ago
Here are the code search results. I'm now analyzing these search results to write the PR.
src/modules/info/commands/help.ts
Calculate the maximum length of command names and pad each command name with spaces to achieve equal spacing and alignment.
---
+++
@@ -1,29 +1,13 @@
- for (let i = 0; i < commands.length; i++)
- {
- if (interaction.values[0] === "information" && i % 4 == 0) { i == 4 && categoryEmbed
- .addFields(
- {
- name: "📖" + " " + framework.translations.get("command.help.commands", guildSettings.lang),
- value: "```" + (commands[i]?.name || "") + " " + (commands[i + 1]?.name || "") + " " + (commands[i + 2]?.name || "") + " " + (commands[i + 3]?.name || "") + " " + valuesToPush.join("") + "```",
- }
- )
- .setColor(config.colors.default);
-
- i == 0 && valuesToPush.push(
+ const maxLength = commands.reduce((max, command) => Math.max(max, command.name.length), 0);
+ const paddedCommands = commands.map(command => command.name.padEnd(maxLength, ' '));
- (commands[i]?.name || "") + " " + (commands[i + 1]?.name || "") + " " + (commands[i + 2]?.name || "") + " " + (commands[i + 3]?.name || "")
-
- );
- } else {
- if (i % 4 == 0) {
- categoryEmbed
- .addFields(
- {
- name: "📖" + " " + framework.translations.get("command.help.commands", guildSettings.lang),
- value: "```" + (commands[i]?.name || "") + " " + (commands[i + 1]?.name || "") + " " + (commands[i + 2]?.name || "") + " " + (commands[i + 3]?.name || "") + " " + "```",
- }
- )
- .setColor(config.colors.default);
+ for (let i = 0; i < paddedCommands.length; i += 4) {
+ const row = paddedCommands.slice(i, i + 4).join(' ');
+ categoryEmbed.addFields(
+ {
+ name: "📖" + " " + framework.translations.get("command.help.commands", guildSettings.lang),
+ value: "```" + row + "```",
}
- }
+ )
+ .setColor(config.colors.default);
}
Your changes have been successfully made to the branch sweep/improve_command_list_formatting
. I have validated these changes using a syntax checker and a linter.
[!TIP] To recreate the pull request, edit the issue title or description.
This is an automated message generated by Sweep AI.
Branch issue-131-Sweep_Improve_command_list_formatting created!
Details
Currently in the help command in your message where it says commands come out in a non-aligned format my request is to align the text shown below:
It should look as follows:
Possible solution: you can count the string and then do 15-stringSize and you already have the number of spaces