Discord.js Help with Help command

I was making all my commands Embed and i have done almost all but i am stuck at this point
there is a weird , before and after commands


Here is code if needed:

const prefix = “.”;
const Discord = require(discord.js)

module.exports = {
name: ‘help’,
description: ‘List all of my commands or info about a specific command.’,
aliases: [‘commands’],
usage: ‘[command name]’,
cooldown: “5”,
run: async(message, args) =>
{
const data = ;
const { commands } = message.client;

    if (!args.length) 
    {
        data.push(`Here\'s a list of all my commands:\n \n`)
        data.push(commands.map(command => command.name).join(`\n`))
        data.push(`\n \nYou can send \`${prefix}help [command name]\` to get info on a specific command!`)
        var Embed = new Discord.MessageEmbed()
        .setDescription (`${data}`)

        return message.channel.send(Embed);
    }
    const name = args[0].toLowerCase();
    const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
    
    if (!command) {
        return message.reply('that\'s not a valid command!');
    }
    
    data.push(`**Name:** ${command.name}`);
    
    if (command.aliases) data.push(`**Aliases:**)

{command.aliases.join(', ')}`); if (command.description) data.push(`**Description:** {command.description}); if (command.usage) data.push(Usage: {prefix}{command.name} ${command.usage}`);

    data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);
    
    message.channel.send(data, { split: true });
},

};

It’s because you are using an array, easiest fix is to just do data.join(’ ')

Formatting the code so that everybody can read the code better:

const prefix = “.”;
const Discord = require(discord.js)

module.exports = {
    name: ‘help’,
    description: ‘List all of my commands or info about a specific command.’,
    aliases: [‘commands’],
    usage: ‘[command name]’,
    cooldown: “5”,
    run: async (message, args) => {
        const data = ;
        const {
            commands
        } = message.client;

        if (!args.length) {
            data.push(`Here\'s a list of all my commands:\n \n`)
            data.push(commands.map(command => command.name).join(`\n`))
            data.push(`\n \nYou can send \`${prefix}help [command name]\` to get info on a specific command!`)
            var Embed = new Discord.MessageEmbed()
                .setDescription(`${data}`)

            return message.channel.send(Embed);
        }
        const name = args[0].toLowerCase();
        const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));

        if (!command) {
            return message.reply('that\'s not a valid command!');
        }

        data.push(`**Name:** ${command.name}`);

        if (command.aliases) data.push(`**Aliases:**)

{command.aliases.join(', ')}`);
        if (command.description) data.push(`**Description:** {command.description}); if (command.usage) data.push(Usage: {prefix}{command.name} ${command.usage}`);

        data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);

        message.channel.send(data, {
            split: true
        });
    },

};

Something’s wrong with this line:

if (command.aliases) data.push(`**Aliases:**)

{command.aliases.join(', ')}`);
1 Like