help: collapsible sections with TS6 markdown
Rebuild the !help output using TeamSpeak 6 markdown: an H1 title, a > [!TIP] callout for the prefix, and a collapsible <details>/<summary> block per command category (with a category icon). Aliases are separated by a middot. Each category folds away, keeping a long command list compact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
b9c6c5dbc9
commit
df99b6ea7f
1 file changed
+38
-16
+38
-16
@@ -25,9 +25,12 @@ namespace Echoion::Core
|
|||||||
try {
|
try {
|
||||||
auto prefix = manager_.getPrefix();
|
auto prefix = manager_.getPrefix();
|
||||||
|
|
||||||
std::string helpMsg = std::format(
|
std::string helpMsg =
|
||||||
"\xf0\x9f\x8e\xb5 **Echoion Bot Help**\n\n");
|
"# \xf0\x9f\x8e\xb5 Echoion Bot Help\n\n";
|
||||||
helpMsg += std::format("Prefix: `{}`\n\n", prefix);
|
helpMsg += std::format(
|
||||||
|
"> [!TIP]\n> Prefix is `{}` \xe2\x80\x94 e.g. "
|
||||||
|
"`{}play lofi`\n\n",
|
||||||
|
prefix, prefix);
|
||||||
|
|
||||||
// Get commands visible to this client
|
// Get commands visible to this client
|
||||||
auto visibleCommands =
|
auto visibleCommands =
|
||||||
@@ -42,35 +45,52 @@ namespace Echoion::Core
|
|||||||
grouped[cmd->getCategory()].push_back({name, cmd});
|
grouped[cmd->getCategory()].push_back({name, cmd});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Per-category icon for the collapsible section header.
|
||||||
|
auto categoryEmoji =
|
||||||
|
[](CommandCategory c) -> std::string_view {
|
||||||
|
switch (c) {
|
||||||
|
case CommandCategory::Music:
|
||||||
|
return "\xf0\x9f\x8e\xb5"; // music note
|
||||||
|
case CommandCategory::Queue:
|
||||||
|
return "\xf0\x9f\x93\x9c"; // scroll
|
||||||
|
case CommandCategory::Playback:
|
||||||
|
return "\xe2\x8f\xaf"; // play/pause
|
||||||
|
case CommandCategory::Utility:
|
||||||
|
return "\xf0\x9f\x94\xa7"; // wrench
|
||||||
|
case CommandCategory::Admin:
|
||||||
|
return "\xf0\x9f\x9b\xa0"; // tools
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
|
||||||
for (const auto& [cat, cmds] : grouped) {
|
for (const auto& [cat, cmds] : grouped) {
|
||||||
helpMsg +=
|
// Collapsible section per category (TS6 supports
|
||||||
std::format("**{} Commands**\n", toString(cat));
|
// <details>/<summary>). Blank lines around the inner
|
||||||
|
// content let the Markdown render inside the block.
|
||||||
|
helpMsg += std::format(
|
||||||
|
"<details>\n<summary>{} {} Commands</summary>\n\n",
|
||||||
|
categoryEmoji(cat), toString(cat));
|
||||||
|
|
||||||
for (const auto& [name, cmd] : cmds) {
|
for (const auto& [name, cmd] : cmds) {
|
||||||
// Format: prefix!command usage
|
|
||||||
if (!cmd->getUsage().empty()) {
|
if (!cmd->getUsage().empty()) {
|
||||||
helpMsg += std::format("`{}{}` {}\n",
|
helpMsg += std::format("`{}{}` {}\n", prefix,
|
||||||
prefix,
|
name, cmd->getUsage());
|
||||||
name,
|
|
||||||
cmd->getUsage());
|
|
||||||
} else {
|
} else {
|
||||||
helpMsg +=
|
helpMsg +=
|
||||||
std::format("`{}{}`\n", prefix, name);
|
std::format("`{}{}`\n", prefix, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description
|
|
||||||
helpMsg +=
|
helpMsg +=
|
||||||
std::format("> {}\n", cmd->getDescription());
|
std::format("> {}\n", cmd->getDescription());
|
||||||
|
|
||||||
// Aliases
|
|
||||||
auto aliases = cmd->getAliases();
|
auto aliases = cmd->getAliases();
|
||||||
if (!aliases.empty()) {
|
if (!aliases.empty()) {
|
||||||
helpMsg += "> Aliases: ";
|
helpMsg += "> Aliases: ";
|
||||||
for (size_t i = 0; i < aliases.size(); ++i) {
|
for (size_t i = 0; i < aliases.size(); ++i) {
|
||||||
helpMsg += std::format(
|
helpMsg += std::format("`{}{}`", prefix,
|
||||||
"`{}{}`", prefix, aliases[i]);
|
aliases[i]);
|
||||||
if (i < aliases.size() - 1) {
|
if (i + 1 < aliases.size()) {
|
||||||
helpMsg += ", ";
|
helpMsg += " \xc2\xb7 "; // middot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
helpMsg += "\n";
|
helpMsg += "\n";
|
||||||
@@ -78,6 +98,8 @@ namespace Echoion::Core
|
|||||||
|
|
||||||
helpMsg += "\n";
|
helpMsg += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helpMsg += "</details>\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.reply(helpMsg);
|
ctx.reply(helpMsg);
|
||||||
|
|||||||
Reference in new issue
Block a user