Updated help command
This commit is contained in:
@@ -5,7 +5,7 @@ const { SlashCommandBuilder } = require('discord.js');
|
|||||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||||
const log = new DebugBuilder("server", "help");
|
const log = new DebugBuilder("server", "help");
|
||||||
|
|
||||||
const prefix = process.env.PREFIX;
|
const { EmmeliaEmbedBuilder } = require("../libUtils");
|
||||||
|
|
||||||
const commandsPath = path.resolve(__dirname, '../commands'); // Resolves from either working dir or __dirname
|
const commandsPath = path.resolve(__dirname, '../commands'); // Resolves from either working dir or __dirname
|
||||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||||
@@ -18,23 +18,43 @@ module.exports = {
|
|||||||
isPrivileged: false,
|
isPrivileged: false,
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
try{
|
try{
|
||||||
messageText = "";
|
generalCommandText = "";
|
||||||
|
paidCommandText = "";
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
const filePath = path.join(commandsPath, file);
|
const filePath = path.join(commandsPath, file);
|
||||||
const command = require(filePath);
|
const command = require(filePath);
|
||||||
|
|
||||||
if (!command.isPrivileged){ // TODO - Need to add middleware for admins
|
if (!command.isPrivileged){ // TODO - Need to add middleware for admins
|
||||||
if (messageText.length > 1 && messageText.slice(-2) != `\n`){
|
if (!command.requiresTokens){
|
||||||
messageText += `\n`;
|
if (generalCommandText.length > 1 && generalCommandText.slice(-2) != `\n`){
|
||||||
|
generalCommandText += `\n\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
generalCommandText += `**/${command.data.name}** - *${command.data.description}*`;
|
||||||
|
|
||||||
|
if (command.example) generalCommandText += `\n\t\t***Usage:*** \`/${command.example}\``
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
messageText += `**/${command.data.name}** - *${command.data.description}*`;
|
if (paidCommandText.length > 1 && paidCommandText.slice(-2) != `\n`){
|
||||||
|
paidCommandText += `\n\n`;
|
||||||
if (command.example) messageText += `\n\t\t***Usage:*** \`${command.example}\``
|
}
|
||||||
|
|
||||||
|
paidCommandText += `**/${command.data.name}** - *${command.data.description}*`;
|
||||||
|
|
||||||
|
if (command.example) paidCommandText += `\n\t\t***Usage:*** \`/${command.example}\``
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await interaction.reply(messageText);
|
|
||||||
|
const helpEmbed = new EmmeliaEmbedBuilder()
|
||||||
|
.setColor(0x0099FF)
|
||||||
|
.setTitle(`Help`)
|
||||||
|
.addFields(
|
||||||
|
{ name: 'General Commands', value: `${generalCommandText}` },
|
||||||
|
{ name: 'Paid Commands', value: `${paidCommandText}` }
|
||||||
|
)
|
||||||
|
await interaction.reply({ embeds: [helpEmbed], ephemeral: true });
|
||||||
}catch(err){
|
}catch(err){
|
||||||
log.ERROR(err)
|
log.ERROR(err)
|
||||||
//await interaction.reply(err.toString());
|
//await interaction.reply(err.toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user