Advertisement
sambeano7

Help.js File

Jul 18th, 2025
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
  2. const fs = require(`fs`);
  3. const buttonPagination = require(`../../utils/buttonPagination`)
  4.  
  5. module.exports = {
  6.     data: new SlashCommandBuilder()
  7.         .setName('helptest')
  8.         .setDescription('This command will explain all commands on the bot'),
  9.     async execute(interaction, client) {
  10.         try {
  11.             const commandFolders = fs.readdirSync('./commands');
  12.             const helpEmbeds = [];
  13.             for (const folder of commandFolders) {
  14.                 const commandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith(`.js`));
  15.                 const categoryEmbed = new EmbedBuilder()
  16.                     .setTitle(folder)
  17.                     .setTimestamp()
  18.                 // .setThumbnail(client.user.displayAvatarURL());
  19.                 const subcommands = [];
  20.                 for (const file of commandFiles) {
  21.                     const command = require(`./../${folder}/${file}`);
  22.                     if (command.deleted) {
  23.                         continue;
  24.                     }
  25.                     const description = `${command.data.description || 'No description provided'}`;
  26.                     if (command.data.type === 'SUB_COMMAND' || command.data.type === 'SUB_COMMAND_GROUP') {
  27.                         subcommands.push(command);
  28.                     } else {
  29.                         categoryEmbed.addFields(
  30.                             {
  31.                                 name: `/${command.data.name}`,
  32.                                 value: `${description}`
  33.                             })
  34.                     }
  35.                 }
  36.                 if (subcommands.length > 0) {
  37.                     categoryEmbed.addFields({
  38.                         name: `Subcommands`,
  39.                         value: subcommands.map(subcommand => `/${subcommand.data.name}`).join('\n')
  40.                     })
  41.                 }
  42.                 helpEmbeds.push(categoryEmbed);
  43.             }
  44.             await buttonPagination(interaction, helpEmbeds);
  45.         } catch (e) {
  46.             await console.log(e)
  47.         }
  48.     },
  49. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement