Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
- const fs = require(`fs`);
- const buttonPagination = require(`../../utils/buttonPagination`)
- module.exports = {
- data: new SlashCommandBuilder()
- .setName('helptest')
- .setDescription('This command will explain all commands on the bot'),
- async execute(interaction, client) {
- try {
- const commandFolders = fs.readdirSync('./commands');
- const helpEmbeds = [];
- for (const folder of commandFolders) {
- const commandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith(`.js`));
- const categoryEmbed = new EmbedBuilder()
- .setTitle(folder)
- .setTimestamp()
- // .setThumbnail(client.user.displayAvatarURL());
- const subcommands = [];
- for (const file of commandFiles) {
- const command = require(`./../${folder}/${file}`);
- if (command.deleted) {
- continue;
- }
- const description = `${command.data.description || 'No description provided'}`;
- if (command.data.type === 'SUB_COMMAND' || command.data.type === 'SUB_COMMAND_GROUP') {
- subcommands.push(command);
- } else {
- categoryEmbed.addFields(
- {
- name: `/${command.data.name}`,
- value: `${description}`
- })
- }
- }
- if (subcommands.length > 0) {
- categoryEmbed.addFields({
- name: `Subcommands`,
- value: subcommands.map(subcommand => `/${subcommand.data.name}`).join('\n')
- })
- }
- helpEmbeds.push(categoryEmbed);
- }
- await buttonPagination(interaction, helpEmbeds);
- } catch (e) {
- await console.log(e)
- }
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement