Advertisement
Garuda2703

index.js

Sep 29th, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. const { Client, Collection, MessageEmbed, Presence } = require("discord.js");
  2. const client = new Client();
  3. const token = "rahasia"
  4. const prefix = "t!"
  5.  
  6. client.on("ready", () => {
  7. console.log("Ticket Manager Online.")
  8. client.user.setActivity('Type t!help To Get Started', { type: 'PLAYING' })
  9. })
  10.  
  11. const fs = require('fs');
  12. client.commands = new Collection()
  13. client.aliases = new Collection();
  14.  
  15. fs.readdir("./commands/", (err, files) => {
  16. if (err) console.log(err)
  17.  
  18. let jsfile = files.filter(f => f.split(".").pop() === 'js')
  19. if(jsfile.length <= 0) {
  20. return console.log("I couldnt file commands!");
  21. }
  22.  
  23. jsfile.forEach((file, i) => {
  24. let pullcmd = require(`./commands/${file}`)
  25. client.commands.set(pullcmd.config.name, pullcmd)
  26. pullcmd.config.aliases.forEach(alias => {
  27. client.aliases.set(alias, pullcmd.config.name)
  28. })
  29. })
  30. })
  31.  
  32. client.on("message", async message => {
  33.  
  34. let messageArray = message.content.split(" ")
  35. let cmd = messageArray[0]
  36. let args = messageArray.slice(1)
  37.  
  38. if(!message.content.startsWith(prefix)) return;
  39. let commandfile = client.commands.get(cmd.slice(prefix.length)) || client.commands.get(client.aliases.get(cmd.slice(prefix.length)))
  40. if (commandfile) commandfile.run(client, message, args)
  41. })
  42. client.login(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement