(command, category)
| 46 | } |
| 47 | |
| 48 | function buildHelpEntries(command, category) { |
| 49 | const commandData = normalizeCommandData(command); |
| 50 | if (!commandData?.name) { |
| 51 | return []; |
| 52 | } |
| 53 | |
| 54 | const baseName = commandData.name; |
| 55 | const baseDescription = commandData.description || "No description"; |
| 56 | const options = commandData.options || []; |
| 57 | |
| 58 | const entries = []; |
| 59 | |
| 60 | for (const option of options) { |
| 61 | if (!option) continue; |
| 62 | |
| 63 | if (option.type === SUBCOMMAND_TYPE) { |
| 64 | entries.push({ |
| 65 | baseName, |
| 66 | displayName: `${baseName} ${option.name}`, |
| 67 | description: option.description || baseDescription, |
| 68 | category, |
| 69 | }); |
| 70 | continue; |
| 71 | } |
| 72 | |
| 73 | if (option.type === SUBCOMMAND_GROUP_TYPE) { |
| 74 | const nestedOptions = option.options || []; |
| 75 | for (const nested of nestedOptions) { |
| 76 | if (nested?.type !== SUBCOMMAND_TYPE) continue; |
| 77 | |
| 78 | entries.push({ |
| 79 | baseName, |
| 80 | displayName: `${baseName} ${option.name} ${nested.name}`, |
| 81 | description: nested.description || option.description || baseDescription, |
| 82 | category, |
| 83 | }); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | if (entries.length === 0) { |
| 89 | entries.push({ |
| 90 | baseName, |
| 91 | displayName: baseName, |
| 92 | description: baseDescription, |
| 93 | category, |
| 94 | }); |
| 95 | } |
| 96 | |
| 97 | return entries; |
| 98 | } |
| 99 | |
| 100 | function normalizeCommandData(command) { |
| 101 | const rawData = command?.data; |
no test coverage detected