😎Creating New Commands

Learn how to create new commands

This is meant for experienced developers

Current DiscordJS version: 14.9.0

  1. Open LuxuDiscordBot/server/commands

  2. Create a new file for your new command: example.js

  3. Follow this structure 👇

example.js
module.exports = {
  data: {
    name: "command-name",
    description: "Command description",
    options: [
      {
        name: "example-option",
        description: "Option description",
        type: ApplicationCommandOptionType.String,
        required: true,
      },
    ],
  },
  async execute(client, interaction) {
  // Checking for user permission
    const hasPerm = await client.checkPermission(interaction, this.data.name);
    if (!hasPerm) return;

   // do some logic...
   
   // replying
      interaction.reply({
          content: `${client.Locale("UnBanPlayerFailed")}`,
          ephemeral: true,
        });
      
     // adding a log to the usage 
     const hasSubcommands = false // change this depending on your command
  client.utils?.log.info(interaction, hasSubcommands);

    } catch (e) {
      console.error("Error banning player", e);
    }
  },
};
  1. Save and Refresh and Restart the script 🥳

As easy as that.

Last updated