DudeThatsErin

Untitled

Nov 18th, 2020
397
21 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('message', message => {
  2.  
  3. if (!message.content.startsWith(prefix) || message.author.bot) return;
  4.  
  5. const args = message.content.slice(prefix.length).trim().split(/ +/);
  6. const commandName = args.shift().toLowerCase();
  7.  
  8. const command = client.commands.get(commandName)
  9.     || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
  10.  
  11. if (!command) return;
  12.  
  13. if (!message.guild) return;
  14.  
  15. if (command.guildOnly && message.channel.type !== 'text') {
  16.   return message.reply('I can\'t execute that command inside DMs!');
  17. }
  18.  
  19. if (command.args && !args.length) {
  20.     let reply = `You didn't provide any arguments, ${message.author}!`;
  21.  
  22.     if (command.usage) {
  23.         reply += `\nThe proper usage would be: \`${prefix}${command.name} ${command.usage}\``;
  24.     }
  25.  
  26.     return message.channel.send(reply);
  27. }
  28.  
  29. try {
  30.     command.execute(message, args);
  31. } catch (error) {
  32.     console.error(error);
  33.     message.reply('there was an error trying to execute that command!');
  34. }
RAW Paste Data