Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const discord = require('discord.js');
- const bot = new discord.Client({disableEveryone: true})
- bot.commands = {};
- bot.alias = {};
- bot.on('ready', () => {
- console.log(`Logged in as ${bot.user.username}`)
- });
- bot.on('error', (err => {
- console.log(err)
- }));
- fs.readdir("./commands/", (err, files) => {
- if (err) console.log(err)
- let jsfile = files.filter(f => f.split(".").pop() === 'js')
- if (jsfile.length <= 0) {
- return console.log(chalk.red("[LOGS] Couldn't find commands!"));
- }
- jsfile.forEach((f, i) => {
- let pull = require(`./commands/${f}`)
- bot.commands.set(pull.config.name, pull);
- pull.config.alias.forEach(alias => {
- bot.alias.set(alias, pull.config.name)
- })
- })
- })
- bot.on("message", (message) => {
- if (message.channel.type === 'dm') return;
- if (message.author.bot) return;
- let prefix = botconfig.prefix
- let messageArray = message.content.split(" ")
- let cmd = messageArray[0]
- let args = messageArray.slice(1)
- if (!message.content.startsWith(prefix)) return;
- let commandfile = bot.commands.get(cmd.slice(prefix.length)) || bot.commands.get(bot.alias.get(cmd.slice(prefix.length)))
- if (commandfile) commandfile.run(bot, message, args)
- });
- bot.login('NjQ2NTQ1Mjc0MTY0MjE1ODI5.XdS2Zw._rgqVKUwTOPTGfr8Nid0LYEjfDs');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement