Advertisement
jensie1996

deploy-Commands.js

Jun 14th, 2023 (edited)
1,318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const commandsPath = path.join(__dirname, 'commands');
  2. const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
  3.  
  4. for (const file of commandFiles) {
  5.     const filePath = path.join(commandsPath, file);
  6.     const command = require(filePath);
  7.     // Set a new item in the Collection with the key as the command name and the value as the exported module
  8.     if ('data' in command && 'execute' in command) {
  9.         commands.push(command.data.toJSON());
  10.     } else {
  11.         console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement