Advertisement
dfhfjjfgjfsfeedgf

Untitled

Nov 30th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const Config = require("./config.json");
  3. const Token = require("./token.json");
  4. const fs = require("fs");
  5. const superagent = require("superagent");
  6. let config = require("./config.json")
  7. let xp = require("./xp.json");
  8.  
  9. const bot = new Discord.Client;
  10. bot.commands = new Discord.Collection();
  11.  
  12. fs.readdir("./commands/", (err, files) =>{
  13. if(err) console.log(err);
  14. let jsfile = files.filter(f => f.split(".").pop() === "js");
  15. if(jsfile.length <= 0 ){
  16. console.log("Could not find the command");
  17. return;
  18. }
  19.  
  20. jsfile.forEach((f, i) =>{
  21. let props = require(`./commands/${f}`);
  22. console.log(`${f} has loaded and is now working!`);
  23. bot.commands.set(props.help.name, props);
  24. });
  25. });
  26. //${bot.guilds.size} servers!
  27. bot.on("ready", async () =>{
  28. console.log (`${bot.user.username} is online! It's running on ${bot.guilds.size} servers!`);
  29. bot.user.setActivity(`*help | justicecountyrp.com`, {type:"PLAYING"});
  30. })
  31.  
  32. //start of joins
  33. bot.on("guildMemberAdd", async member => {
  34. let welcomeChannel = member.guild.channels.find(`name`, "welcome");
  35. 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***");
  36. 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! `);
  37. // send a dm
  38. 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")});
  39. });
  40. //end of joins
  41.  
  42. //start of leaves
  43. bot.on("guildMemberRemove", async member => {
  44. let welcomeChannel = member.guild.channels.find(`name`, "welcome");
  45. 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***");
  46. welcomeChannel.send(`nooooo!!! ${member} left us!! Now im sad :(`);
  47. // send a dm
  48. member.send("Sorry to see you go!").catch(O_o=>{ welcomeChannel.send("this user does not have dms enabled")});
  49. });
  50. // end of leaves
  51.  
  52. //start of blacklisted words
  53. bot.on('message', async message => {
  54. //1 blacklisted words
  55. let blacklisted = ['nigger',`spic`] //words put , after the word
  56.  
  57. //2 looking for words
  58. let foundInText = false;
  59. for (var i in blacklisted) { // loops through the blacklisted list
  60. if (message.content.toLowerCase().includes(blacklisted[i].toLowerCase())) foundInText = true;
  61. }
  62.  
  63.  
  64. //3 deletes and send message
  65. if (foundInText) {
  66. message.delete();
  67. message.channel.sendMessage('Hey! No bad words!')
  68. }
  69. });
  70. //end of blacklisted words
  71. //start of xp system
  72. let xpAdd = Math.floor(Math.random() * 7) + 8;
  73. console.log(xpAdd);
  74.  
  75. if(!xp[message.author.id]){
  76. xp[message.author.id] = {
  77. xp: 0,
  78. level: 1
  79. };
  80. }
  81.  
  82.  
  83. let curxp = xp[message.author.id].xp;
  84. let curlvl = xp[message.author.id].level;
  85. let nxtLvl = xp[message.author.id].level * 300;
  86. xp[message.author.id].xp = curxp + xpAdd;
  87. if(nxtLvl <= xp[message.author.id].xp){
  88. xp[message.author.id].level = curlvl + 1;
  89. let lvlup = new Discord.RichEmbed()
  90. .setTitle("Level Up!")
  91. .setColor("RANDOM")
  92. .addField("New Level", curlvl + 1);
  93.  
  94. message.channel.send(lvlup).then(msg => {msg.delete(5000)});
  95. }
  96. fs.writeFile("./xp.json", JSON.stringify(xp), (err) => {
  97. if(err) console.log(err)
  98. });
  99. //end of xp system
  100.  
  101.  
  102.  
  103.  
  104. bot.on("message", async message => {
  105.  
  106. if(message.author.bot) return;
  107. if(message.channel.type === "dm") return;
  108.  
  109. let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
  110. if(!prefixes[message.guild.id]){
  111. prefixes[message.guild.id] = {
  112. prefixes: config.prefix
  113. };
  114. }
  115. let prefix = prefixes[message.guild.id].prefixes;
  116. if(!message.content.startsWith(prefix)) return;
  117. let messageArray = message.content.split(" ");
  118. let cmd = messageArray[0];
  119. let args = messageArray.slice(1);
  120.  
  121. let commandfile = bot.commands.get(cmd.slice(prefix.length));
  122. if(commandfile) commandfile.run(bot, message, args);
  123.  
  124.  
  125.  
  126. })
  127.  
  128.  
  129.  
  130. bot.login(Token.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement