SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const bot = new Discord.Client();
  3. const token = "secret token";
  4. const prefix = ".";
  5. bot.commands = new Discord.Collection();
  6. const fs = require("fs");
  7. let command = messageArray[0];
  8. let args = messageArray.slice(1);
  9.  
  10. fs.readdir("./commands/", (err, files) => {
  11.   if (err) console.err(err);
  12.   let jsfiles = files.filter(f => f.split(".").pop() === "js");
  13.   if (jsfiles.length <= 0) {
  14.     console.log("No commands to load");
  15.     return;
  16.   }
  17.  
  18.   console.log(`Loading ${jsfiles.length} commands`);
  19.  
  20.   jsfiles.forEach((f, i) => {
  21.     let props = require(`./commands/${f}`);
  22.     console.log(`${i + 1}: ${f} loaded!`);
  23.     bot.commands.set(f, props);
  24.   });
  25. });
  26.  
  27. bot.on("ready", () => {
  28.   console.log("S&S Bot is online!");
  29.   console.log(bot.commands);
  30. });
  31.  
  32. bot.on("message", message => {
  33.   let messageArray = message.content.split(" ");
  34.   let args = messageArray.slice(1);
  35.   let command = messageArray[0];
  36.  
  37.   if (message.content === "ping") {
  38.     message.channel.send("pong");
  39.   }
  40. });
  41.  
  42. bot.login(token);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top