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 superagent = require("superagent");
- const bot = new Discord.Client;
- 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("Could not find the command");
- return;
- }
- jsfile.forEach((f, i) =>{
- let props = require(`./commands/${f}`);
- console.log(`${f} has loaded and is now working!`);
- bot.commands.set(props.help.name, props);
- });
- });
- //${bot.guilds.size} servers!
- bot.on("ready", async () =>{
- console.log (`${bot.user.username} is online! It's running on ${bot.guilds.size} servers!`);
- bot.user.setActivity(`*help| *update new update!`, {type:"PLAYING"});
- })
- //start of joins
- bot.on("guildMemberAdd", async member => {
- let welcomeChannel = member.guild.channels.find(`name`, "welcome");
- if(!welcomeChannel) return;
- welcomeChannel.send(`Welcome ${member} to ${message.guild.name} server! Hope you have a great stay!`);
- // send a dm
- member.send(`Hi and welcome to ${message.guild.name} We hope you have a very fun time here! Have a good day!`).catch(O_o=>{ welcomeChannel.send("this user does not have dms enabled")});
- });
- //end of joins
- //start of leaves
- bot.on("guildMemberRemove", async member => {
- let welcomeChannel = member.guild.channels.find(`name`, "welcome");
- if(!welcomeChannel) return;
- welcomeChannel.send(`Welcome ${member} to the server! Hope you have a great stay!`);
- // send a dm
- member.send("Sorry to see you go!").catch(O_o=>{ welcomeChannel.send("this user does not have dms enabled")});
- });
- // end of leaves
- //start of blacklisted words
- bot.on('message', async message => {
- //1 blacklisted words
- let blacklisted = ['nigger',`spic`] //words put , after the word
- //2 looking for words
- let foundInText = false;
- for (var i in blacklisted) { // loops through the blacklisted list
- if (message.content.toLowerCase().includes(blacklisted[i].toLowerCase())) foundInText = true;
- }
- //3 deletes and send message
- if (foundInText) {
- message.delete();
- message.channel.sendMessage('Hey! No bad words!')
- }
- });
- //end of blacklisted words
- bot.on("message", async message => {
- if(message.author.bot) return;
- if(message.channel.type === "dm") return;
- let prefix = Config.prefix;
- let msgArray = message.content.split(" ");
- let cmd = msgArray[0];
- let args = msgArray.slice(1);
- let cmdFile = bot.commands.get(cmd.slice(prefix.length));
- if(cmdFile) cmdFile.run(bot, message, args);
- //start of cat command
- if(cmd === `${prefix}cat`) {
- let msg = await message.channel.send("Generating...")
- let {body} = await superagent
- .get(`http://aws.random.cat/meow`)
- 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 cEmbed = new Discord.RichEmbed()
- .setColor("#409e43")
- .setAuthor("Staffy's cats!", bot.user.displayAvatarURL)
- .setImage(body.file)
- .setFooter("Staffy | Join the discord for support: https://discord.gg/srNkdvV", bot.user.displayAvatarURL)
- message.channel.send({embed: cEmbed})
- msg.delete();
- }
- // end of cat comand
- //start of dog command
- if(cmd === `${prefix}dog`) {
- let msg = await message.channel.send("Generating...")
- let {body} = await superagent
- .get(`https://dog.ceo/api/breeds/image/random`)
- 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 dEmbed = new Discord.RichEmbed()
- .setColor("#409e43")
- .setAuthor("Staffy's dogs!", bot.user.displayAvatarURL)
- .setImage(body.message)
- .setFooter("Staffy | Join the discord for support: https://discord.gg/srNkdvV", bot.user.displayAvatarURL)
- message.channel.send({embed: dEmbed})
- msg.delete();
- }
- //end of dog command
- // 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("#409e43")
- .setAuthor("Staffy's memes!", bot.user.displayAvatarURL)
- .setImage(body.url)
- .setFooter("Staffy | Join the discord for support: https://discord.gg/srNkdvV", bot.user.displayAvatarURL)
- 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