How to get value of a module.exports description in another file [Discord.js]

I am trying to make a discord bot that has a help command which sends an embed with fields, each one corresponding to a command. I want to automatically set the values of these fields to the correct command file description. This is an example of the command file:

module.exports = {
    name: 'kick',
    description: "Kicks the mentioned user. Administrator permissions required",
    execute(message, args) {
      // command code

I am trying to set the field values to the module exports description. If this is possible, how would I achieve this?

2 thoughts on “How to get value of a module.exports description in another file [Discord.js]”

  1. You can use Client#commands#get to get the object of the command, then simply use .description to get that command’s description.

    For this example I will use Client as the Client object, however if yours is Bot or anything else, adjust the code accordingly.

    Example Module:

    module.exports = {
       name: 'testCommand',
       description: 'Hello World!'

    How to get the description:

    const cmd = Client.commands.get('testCommand');
    // 'Hello World!'

    If you’re inside the command you want to get the description of, simply use this to reference the current command

    module.exports = {
       name: 'testCommand',
       description: 'Hello World!',
       // this.description = 'Hello World!'

Leave a Comment