Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. const botconfig = require("./botconfig.json");
  2. const Discord = require("discord.js");
  3. const fs = require("fs");
  4. const bot = new Discord.Client({disableEveryone: true});
  5. bot.commands = new Discord.Collection();
  6.  
  7. fs.readdir("./commands/", (err, file) => {
  8.  
  9. if(err) console.log(err);
  10.  
  11. let jsfile = file.filter(f => f.split(".").pop() === "js")
  12. if(jsfile.length <= 0){
  13. console.log("Couldn't find commands.");
  14. return;
  15. }
  16. jsfile.forEach((f, i) =>{
  17. let props = require(`./commands/${f}`);
  18. console.log(`${f} Loaded!`);
  19. bot.commands.set(props.help.name, props);
  20. });
  21. });
  22. bot.on("ready", async () => {
  23. console.log(`${bot.user.username} is online`)
  24. bot.user.setActivity("!help");
  25. });
  26. bot.on("message", async message => {
  27. if(message.author.bot) return;
  28. if(message.channel.type === "dm") return;
  29.  
  30. let prefix = botconfig.prefix;
  31. let messageArray = message.content.split(" ");
  32. let cmd = messageArray[0];
  33. let args = messageArray.slice(1);
  34.  
  35. let commandfile = bot.commands.get(cmd.slice(prefix.length));
  36. if(commandfile) commandfile.run(bot,message,args);
  37.  
  38.  
  39.  
  40. if(cmd === `${prefix}help`){
  41.  
  42. let bicon = bot.user.displayAvatarURL;
  43. let botembed = new Discord.RichEmbed()
  44. .setDescription("Hello welcome to the Silkyy marketplace, here are a list of commands!")
  45. .setColor("EBD61D")
  46. .setThumbnail(bicon)
  47. .addField("!ban", 'bans a specific user')
  48. .addField("!kick", 'kicks a specific user')
  49. .addField("!clear", 'clears unwanted messages')
  50. .addField("!report", 'report actions against the rules!')
  51. .addField("!avatar", 'take a closer look to an avatar!')
  52. .addField("!open", 'open a ticket for support');
  53.  
  54. return message.channel.send(botembed);
  55. }
  56. });
  57.  
  58. bot.on('guildMemberAdd', member => {
  59. // Send the message to a designated channel on a server:
  60. const channel = member.guild.channels.find(ch => ch.name === 'join-logs');
  61. // Do nothing if the channel wasn't found on this server
  62. if (!channel) return;
  63. // Send the message, mentioning the member
  64. let sicon = bot.user.displayAvatarURL;
  65. let welcomeembed = new Discord.RichEmbed()
  66. .setTitle(`Welcome to the server, ${member}`)
  67. .setColor("#ff0000")
  68. .setThumbnail(sicon)
  69. .addField("IP:", "**Coming soon**")
  70. .addField("Release Date:", "**To be confirmed**")
  71. channel.send(welcomeembed)
  72. });
  73.  
  74.  
  75.  
  76. bot.login(botconfig.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement