Guest User

Untitled

a guest
Jun 29th, 2020
50,287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3.  
  4. const prefix = '-';
  5.  
  6. const fs = require('fs');
  7.  
  8. client.commands = new Discord.Collection();
  9.  
  10. const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
  11. for(const file of commandFiles){
  12.     const command = require(`./commands/${file}`);
  13.  
  14.     client.commands.set(command.name, command);
  15. }
  16.  
  17.  
  18. client.once('ready', () => {
  19.     console.log('Codelyon is online!');
  20. });
  21.  
  22. client.on('message', message =>{
  23.     if(!message.content.startsWith(prefix) || message.author.bot) return;
  24.  
  25.     const args = message.content.slice(prefix.length).split(/ +/);
  26.     const command = args.shift().toLowerCase();
  27.  
  28.     if(command === 'ping'){
  29.         client.commands.get('ping').execute(message, args);
  30.     }
  31. });
  32.  
  33. client.login('   ');
  34.  
  35.  
  36. ----- Command JS File -----
  37.  
  38. module.exports = {
  39.     name: 'ping',
  40.     description: "this is a ping command!",
  41.     execute(message, args){
  42.         message.channel.send('pong!');
  43.     }
  44. }
Add Comment
Please, Sign In to add comment