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");
- let config = require("./config.json")
- let xp = require("./xp.json");
- 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 | justicecountyrp.com`, {type:"PLAYING"});
- })
- //start of joins
- bot.on("guildMemberAdd", async member => {
- let welcomeChannel = member.guild.channels.find(`name`, "welcome");
- if(!welcomeChannel) return message.channel.send("I cant find a welcome channel to put the person that joined us in. Please make a channel called ***welcome***");
- welcomeChannel.send(`Welcome ${member} to the offical discord server of, ${message.guild.name} Hope you have a great stay! But make sure to read #rules and apply in #server-info there will be the fivem server ip and our teamspeak ip. If you have any general questions please ask in #general-questions but if it is questions for staff ask that in #questions-for-staff but other than that, have an awesome day! `);
- // 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 message.channel.send("I cant find a welcome channel to put the person that left us in. Please make a channel called ***welcome***");
- welcomeChannel.send(`nooooo!!! ${member} left us!! Now im sad :(`);
- // 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
- //start of xp system
- let xpAdd = Math.floor(Math.random() * 7) + 8;
- console.log(xpAdd);
- if(!xp[message.author.id]){
- xp[message.author.id] = {
- xp: 0,
- level: 1
- };
- }
- let curxp = xp[message.author.id].xp;
- let curlvl = xp[message.author.id].level;
- let nxtLvl = xp[message.author.id].level * 300;
- xp[message.author.id].xp = curxp + xpAdd;
- if(nxtLvl <= xp[message.author.id].xp){
- xp[message.author.id].level = curlvl + 1;
- let lvlup = new Discord.RichEmbed()
- .setTitle("Level Up!")
- .setColor("RANDOM")
- .addField("New Level", curlvl + 1);
- message.channel.send(lvlup).then(msg => {msg.delete(5000)});
- }
- fs.writeFile("./xp.json", JSON.stringify(xp), (err) => {
- if(err) console.log(err)
- });
- //end of xp system
- bot.on("message", async message => {
- if(message.author.bot) return;
- if(message.channel.type === "dm") return;
- let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
- if(!prefixes[message.guild.id]){
- prefixes[message.guild.id] = {
- prefixes: config.prefix
- };
- }
- let prefix = prefixes[message.guild.id].prefixes;
- if(!message.content.startsWith(prefix)) return;
- let messageArray = message.content.split(" ");
- let cmd = messageArray[0];
- let args = messageArray.slice(1);
- let commandfile = bot.commands.get(cmd.slice(prefix.length));
- if(commandfile) commandfile.run(bot, message, args);
- })
- bot.login(Token.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement