Advertisement
dfhfjjfgjfsfeedgf

Untitled

Nov 30th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 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.  
  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!`);
  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!");
  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.  
  72. bot.on("message", async message => {
  73.  
  74. if(message.author.bot) return;
  75. if(message.channel.type === "dm") return;
  76.  
  77. let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
  78. if(!prefixes[message.guild.id]){
  79. prefixes[message.guild.id] = {
  80. prefixes: config.prefix
  81. };
  82. }
  83. let prefix = prefixes[message.guild.id].prefixes;
  84. if(!message.content.startsWith(prefix)) return;
  85. let messageArray = message.content.split(" ");
  86. let cmd = messageArray[0];
  87. let args = messageArray.slice(1);
  88.  
  89. let commandfile = bot.commands.get(cmd.slice(prefix.length));
  90. if(commandfile) commandfile.run(bot, message, args);
  91.  
  92.  
  93.  
  94. })
  95.  
  96.  
  97.  
  98. bot.login(Token.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement