Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const Config = require("./config.json")
- const Token = require("./token.json")
- const fs = require("fs");
- const bot = new Discord.Client({disableEveryone: true});
- bot.commands = new Discord.Collection();
- fs.readdir("./commands/", (err, files) =>{
- if(err) console.log(err);
- let jsfile = files.filter(f => f.split(".").pop() === "js");
- if(jsfile.length <= 0){
- console.log("couldnt find the command!");
- return;
- }
- jsfile.forEach((f, i) =>{
- let props = require(`./commands/${f}`);
- console.log(`${f} has loaded and is working!`);
- bot.commands.set(props.help.name, props);
- });
- });
- bot.on('ready', ()=> {
- console.log('im online!')
- bot.user.setActivity("Work in");
- });
- bot.on('message', async message => {
- if(message.author.bot) return;
- if(message.channel.type === "dm") return;
- let prefix = Config.prefix;
- let messageArray = message.content.split(" ");
- let cmd = messageArray[0];
- let args = messageArray.slice(1);
- let cmdFile = bot.commands.get(cmd.slice(prefix.length));
- if(cmdFile) cmdFile.run(bot, message, args);
- if(!message.content.startsWith(prefix))return;
- // start of memes command
- if(cmd === `${prefix}memes`) {
- let msg = await message.channel.send("Generating...")
- let {body} = await superagent
- .get(`https://api-to.get-a.life/meme`)
- console.log(body.file)
- if(!{body}) return message.channel.send("My database failed to load it :( Please try again. If it doesnt work please contact my owner!")
- let mEmbed = new Discord.RichEmbed()
- .setColor("RANDOM")
- .setAuthor("Juicy memes!", bot.user.displayAvatarURL)
- .setImage(body.url);
- message.channel.send({embed: mEmbed})
- msg.delete();
- }
- //end of memes command
- })
- bot.login(Token.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement