Discord_API_Bot/slash-commands/help.js

38 lines
No EOL
1.1 KiB
JavaScript

const fs = require('fs');
const path = require("node:path");
const { SlashCommandBuilder, inlineCode, EmbedBuilder } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName('help')
.setDescription("Info regarding each slash command"),
async run(interaction) {
let commandFiles = fs.readdirSync(__dirname).filter(file => file.endsWith(".js"));
const footerText = { text: "Coded by @onurcansevinc" };
let helpEmbed = new EmbedBuilder()
.setTitle("Help")
.setColor("Random")
.setFooter(footerText)
.setDescription("This is a list of all of this bot's slash commands");
for (let file of commandFiles) {
let filePath = path.join(__dirname, file);
let command = require(filePath);
helpEmbed.addFields({
name: inlineCode('/' + command.data.name.toString()),
value: command.data.description.toString(),
inline: false
});
}
const replyOptions = {
embeds: [helpEmbed],
ephemeral: true
};
return interaction.reply(replyOptions);
}
};