Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require("discord.js");
- const bot = new Discord.Client();
- const token = "secret token";
- const prefix = ".";
- bot.commands = new Discord.Collection();
- const fs = require("fs");
- let command = messageArray[0];
- let args = messageArray.slice(1);
- fs.readdir("./commands/", (err, files) => {
- if (err) console.err(err);
- let jsfiles = files.filter(f => f.split(".").pop() === "js");
- if (jsfiles.length <= 0) {
- console.log("No commands to load");
- return;
- }
- console.log(`Loading ${jsfiles.length} commands`);
- jsfiles.forEach((f, i) => {
- let props = require(`./commands/${f}`);
- console.log(`${i + 1}: ${f} loaded!`);
- bot.commands.set(f, props);
- });
- });
- bot.on("ready", () => {
- console.log("S&S Bot is online!");
- console.log(bot.commands);
- });
- bot.on("message", message => {
- let messageArray = message.content.split(" ");
- let args = messageArray.slice(1);
- let command = messageArray[0];
- if (message.content === "ping") {
- message.channel.send("pong");
- }
- });
- bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement