issue with help command

https://sourceb.in/Klz09ynf0B i describe tags in the command but the bot does not pick them up and use them
SourceBin
error
Instantly share your code with the world.
6 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
lordwolfy
lordwolfyOP15mo ago
and there is no error just it cant find the tags in the command
lordwolfy
lordwolfyOP15mo ago
No description
lordwolfy
lordwolfyOP15mo ago
https://sourceb.in/Q6J16NbKsw @Qjuh but its defined in the command name: "statistic", description: "View your bot statistics.", tags: ["music"], options: [], permissions: "0x000000 you mean defining its name and description? OHH client.commands = []; fs.readdir(config.commandsDir, (err, files) => { if (err) throw err; files.forEach(async (f) => { try { if (f.endsWith(".js")) { let props = require(${config.commandsDir}/${f}); client.commands.push({ name: props.name, description: props.description, options: props.options, }); console.log(${lang.loadcmd}: ${props.name}); } } catch (err) { console.log(err); } }); }); i need to add the tags to the when it gets pushed okay so it now sees the tags but it doesnt filter by tags @Qjuh https://sourceb.in/CqXtkyIgaI the tags exist and the bot registers them now but the help command still cant filter by catagory sorry :c i dont i just run /help to list all the commands but /help info "command" gets the tag but it wont filter it in the main /help command that didnt matter before i made it filter yeah but it doesnt filter by showHelp it filters by tag
tagsToDisplay.forEach((tag) => {
const taggedCommands = client.commands.filter((cmd) => {
const tags = cmd.tags || []; // Check if tags are defined
return cmd.showHelp && tags.includes(tag);
});
if (taggedCommands.size > 0) {
const tagCommandsString = taggedCommands.map((cmd) => `\`/${cmd.name}\``).join(' \n ');
embed.addField(tag, tagCommandsString);
}
});
tagsToDisplay.forEach((tag) => {
const taggedCommands = client.commands.filter((cmd) => {
const tags = cmd.tags || []; // Check if tags are defined
return cmd.showHelp && tags.includes(tag);
});
if (taggedCommands.size > 0) {
const tagCommandsString = taggedCommands.map((cmd) => `\`/${cmd.name}\``).join(' \n ');
embed.addField(tag, tagCommandsString);
}
});
OHHH omg its so small i missed it lmao thanks okay but it still doesnt show in the help command even though its in the command
lordwolfy
lordwolfyOP15mo ago
lordwolfy
lordwolfyOP15mo ago
it does both it console.logs and sends it https://sourceb.in/Csw8zXpb0T but then theres no error for the code it just is somethign wrong with the filter as adding fields using .addFields([ { name: ${lang.msg33}, value: commands.map(x => \/${x.name}`).join(' | ') } ]) works mhm but it isnt erroring as it isnt even getting to that part to error at something isnt working before that because i added a console.log ```js tagsToDisplay.forEach((tag) => { const taggedCommands = client.commands.filter((cmd) => { const tags = cmd.tags || []; // Check if tags are defined return cmd.showHelp && tags.includes(tag); }); console.log(taggedCommands) console.log(taggedCommands.size) if (taggedCommands.size > 0) { const tagCommandsString = taggedCommands.map((cmd) => `/${cmd.name}`).join(' \n '); embed.addFields(tag, tagCommandsString); } });``` and they return empty so it doesnt run the next part as the command size is 0 tagsToDisplay.forEach((tag) for each tag in tags ```js const commands = client.commands.filter(x => x.showHelp !== false); const tagsToDisplay = ["Music", "Moderation", "Other"]; // Add your desired tags here const embed = new EmbedBuilder() .setColor(client.config.embedColor) .setTitle("Musi's Help GUI") .setDescription(lang.msg32) .setTimestamp() .addFields([ { name: ${lang.msg33}, value: commands.map(x => `/${x.name} | ${x.tags}`).join(' \n ') } ]) .setFooter({ text: "https://musibot.lag.tf" }); // Fix the error ``` this can get the tag with x.tags hmm ```js [] undefined [] undefined [ { name: 'statistic', description: 'View your bot statistics.', tags: [ 'Other' ], showHelp: true, options: [] }, { name: 'channel', description: 'It allows you to set the channel or channels where the bot can be used.', tags: [ 'Other' ], showHelp: true, options: [ [Object], [Object] ] }, { name: 'help', description: 'It helps you get information about the bot and commands.', tags: [ 'Other' ], showHelp: true, options: [ [Object] ] }, { name: 'language', description: 'It allows you to set the language of the bot.', tags: [ 'Other' ], showHelp: true, options: [] }, { name: 'ping', description: 'It helps you to get information about the speed of the bot.', tags: [ 'Other' ], showHelp: true, options: [] } ] undefined ``` [] undefined [] undefined the first two tags but size is undefined wait its .length not size okay now it returns the length but now error ```js [] 0 [] 0 [ { name: 'statistic', description: 'View your bot statistics.', tags: [ 'Other' ], showHelp: true, options: [] }, { name: 'channel', description: 'It allows you to set the channel or channels where the bot can be used.', tags: [ 'Other' ], showHelp: true, options: [ [Object], [Object] ] }, { name: 'help', description: 'It helps you get information about the bot and commands.', tags: [ 'Other' ], showHelp: true, options: [ [Object] ] }, { name: 'language', description: 'It allows you to set the language of the bot.', tags: [ 'Other' ], showHelp: true, options: [] }, { name: 'ping', description: 'It helps you to get information about the speed of the bot.', tags: [ 'Other' ], showHelp: true, options: [] } ] 5 CombinedPropertyError (2) Received one or more errors input[0] | ValidationError > s.object(T) | Expected the value to be an object, but received string instead | | Received: | | 'Other' input[1] | ValidationError > s.object(T) | Expected the value to be an object, but received string instead | | Received: | | '/statisticOther \n /channelOther \n /helpOther \n /languageOther \n /pingOther' at _ArrayValidator.handle (/workspaces/codespaces-blank/node_modules/@sapphire/shapeshift/dist/index.js:480:70) at _ArrayValidator.parse (/workspaces/codespaces-blank/node_modules/@sapphire/shapeshift/dist/index.js:216:88) at EmbedBuilder.addFields (/workspaces/codespaces-blank/node_modules/@discordjs/builders/dist/index.js:225:31) at /workspaces/codespaces-blank/commands/help.js:67:19 at Array.forEach (<anonymous>) at Object.run (/workspaces/codespaces-blank/commands/help.js:57:23) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) ``` but i did ```js if (taggedCommands.length > 0) { const tagCommandsString = taggedCommands.map((cmd) => `/${cmd.name}${cmd.tags}`).join(' \n '); embed.addFields(tag, tagCommandsString); } });``` ohh now i get an error trying to load the command /workspaces/codespaces-blank/commands/help.js:67 embed.addFields(name: tag, value: tagCommandsString); ^^^^ SyntaxError: missing ) after argument list at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1153:20) at Module._compile (node:internal/modules/cjs/loader:1205:27) at Module._extensions..js (node:internal/modules/cjs/loader:1295:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Module._load (node:internal/modules/cjs/loader:938:12) at Module.require (node:internal/modules/cjs/loader:1115:19) at require (node:internal/modules/helpers:130:18) at /workspaces/codespaces-blank/bot.js:71:21 at Array.forEach (<anonymous>) oop wrong code embed.addFields([ { name: ${tag}, value:tagCommandsString)join(' \n ') } ]) }); that one i didnt mean to i meant to delete the code lol yeah okay so now whats wrong here ```js /workspaces/codespaces-blank/commands/help.js:70 }); ^ SyntaxError: Unexpected token ')' at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1153:20) at Module._compile (node:internal/modules/cjs/loader:1205:27) at Module._extensions..js (node:internal/modules/cjs/loader:1295:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Module._load (node:internal/modules/cjs/loader:938:12) at Module.require (node:internal/modules/cjs/loader:1115:19) at require (node:internal/modules/helpers:130:18) at /workspaces/codespaces-blank/bot.js:71:21 at Array.forEach (<anonymous>)``` ```js const tagCommandsString = taggedCommands.map((cmd) => `\`/${cmd.name}\).join(' \n '); embed.addFields([ { name: ${tag}, value: `${tagCommandsString}`` } ]);
});```
Want results from more Discord servers?
Add your server