Advertisement
Wetzu

My bot

Jan 18th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2.  
  3. var eightball = [ // sets the answers to an eightball
  4.   "yes!",
  5.   "no...",
  6.   "maybe?",
  7.   "probably",
  8.   "I don't think so.",
  9.   "never!",
  10.   "you can try...",
  11.   "up to you!",
  12. ]
  13.  
  14. const bot = new Discord.Client();
  15.  
  16. const settings = require("./settings.json");
  17.  
  18. bot.on("ready", () => {
  19.   console.log(`Started! Welcome back, Wetzu`);
  20.   bot.user.setActivity('/shrug | >:help');
  21.   bot.user.setStatus("dnd")
  22. });
  23.  
  24.  
  25. bot.on("message", async message => {
  26.   if(message.author.bot) return;
  27.   var prefix = settings.prefix
  28.  
  29.   const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
  30.   const command = args.shift().toLowerCase();
  31.  
  32.  
  33.   if(command === "ping") {
  34.     const m = await message.channel.send("`Please wait...`");
  35.     m.edit(`*Pong!* Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(bot.ping)}ms `);
  36.   }
  37.  
  38.   if (command == "8ball") { // creates the command 8ball
  39.     if (args[1] != null) message.reply(eightball[Math.floor(Math.random() * eightball.length).toString(16)]); // if args[1], post random answer
  40.     else message.channel.send("Ummmm, what is your question? :rolling_eyes: (Correct usage: *8ball [question])"); // if not, error
  41.   }
  42.  
  43.   if (command == "cookie") { // creates the command cookie
  44.     if (args[1]) message.channel.send(message.author.toString() + " has given " + args[1].toString() + " a cookie! :cookie:") // sends the message saying someone has given someone else a cookie if someone mentions someone else
  45.     else message.channel.send("Who do you want to send a cookie to? :cookie: (Correct usage: *cookie @username)") // sends the error message if no-one is mentioned
  46.   }
  47.    
  48.   if(command === "say") {
  49.     const sayMessage = args.join(" ");
  50.     message.delete().catch(O_o=>{});  
  51.     message.channel.send(sayMessage);
  52.  
  53.  
  54.   if(command === "kick") {
  55.     if(!message.member.roles.some(r=>["Administrator", "Moderator", "administrator", "Owner"].includes(r.name)) )
  56.       return message.reply(":no_entry_sign: You have no permission to use this command.");
  57.    
  58.     let member = message.mentions.members.first();
  59.     if(!member)
  60.       return message.reply("Please mention a specific member in the server,");
  61.     if(!member.kickable)
  62.       return message.reply(":no_entry_sign: I cannot kick this user, Perhaps this member has a higher role.");
  63.    
  64.     let reason = args.slice(1).join(' ');
  65.     if(!reason)
  66.       return message.reply("Please indicate a reason for the kick!");
  67.    
  68.     await member.kick(reason)
  69.       .catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
  70.    message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`);
  71.  
  72.  }
  73.  
  74.  if(command === "ban") {
  75.    if(!message.member.roles.some(r=>["Administrator", "Moderator", "administrator", "Owner"].includes(r.name)) )
  76.      return message.reply(":no_entry_sign: You have no permission to use this command.");
  77.    
  78.    let member = message.mentions.members.first();
  79.    if(!member)
  80.      return message.reply("Please mention a specific member in the server.");
  81.    if(!member.bannable)
  82.      return message.reply(":no_entry_sign: I cannot ban this user, Perhaps this member has a higher role.");
  83.  
  84.    let reason = args.slice(1).join(' ');
  85.    if(!reason)
  86.      return message.reply("Please indicate a reason for the ban!");
  87.    
  88.    await member.ban(reason)
  89.      .catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
  90.     message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
  91.   }
  92.  
  93.   if(command === "purge") {    
  94.  
  95.     const deleteCount = parseInt(args[0], 10);
  96.    
  97.     if(!deleteCount || deleteCount < 2 || deleteCount > 100)
  98.       return message.reply("Please provide a number between 1 and 100 for the number of messages to delete");
  99.    
  100.     const fetched = await message.channel.fetchMessages({count: deleteCount});
  101.     message.channel.bulkDelete(fetched)
  102.       .catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
  103.  }
  104.  
  105.  if (message.content.startsWith(prefix + 'avatar')) {
  106.    message.reply(message.author.avatarURL)
  107. }
  108.  
  109.  
  110. if (message.content.startsWith(prefix + 'help')) {
  111.    message.reply(":white_check_mark: Check your DMs~")
  112.    message.author.send({embed: {
  113.        color: 3447003,
  114.        description: "`Here are my commands!`\n**MISC**\n`help - Shows this menu`\n`invite - Gives your a link to invite me to your server!` \n`ping - To test if your bot is alive`\n`shrug - Shows a shrug picture`\n` 8ball - ??? It's random!`\n `cookie - Give a cookie to someone! (only one words: ex: (random thing) Wetzu~`\n `say - Make the bot say something (removed your command :^))`\n **MODERATION**\n `purge - purges text 1 - 100`\n `kick - kicks a member!`\n `ban - bans the user mentioned!`\n `mute - muted the mentioned user`\n `unmute - unmutes the mentioned user`\n"
  115.    }});
  116.  
  117. }
  118.  
  119. if (message.content.startsWith(prefix + 'invite')) {
  120.   message.reply(":white_check_mark: Check yours DMs~")
  121.   message.author.send({embed: {
  122.    "color": 3447003,
  123.    "description": "Use this to invite me!\n https://discordapp.com/oauth2/authorize?&client_id=401967891869597697&scope=bot&permissions=0"
  124.   }});
  125. }
  126.  
  127. if (command == "mute") { // creates the command mute
  128.   if (!message.member.roles.some(r=>["Administrator", "Moderator", "administrator", "Owner"].includes(r.name)) ) return message.reply("Sorry, you do not have the permission to do this!"); // if author has no perms
  129.   var mutedmember = message.mentions.members.first(); // sets the mentioned user to the var kickedmember
  130.   if (!mutedmember) return message.reply("Please mention a specific member in the server.") // if there is no kickedmmeber var
  131.   if (mutedmember.hasPermission("ADMINISTRATOR")) return message.reply(":no_entry_sign: I cannot mute this user, Perhaps this member has a higher role.!") // if memebr is an admin
  132.   var mutereasondelete = 10 + mutedmember.user.id.length //sets the length of the kickreasondelete
  133.   var mutereason = message.content.substring(mutereasondelete).split(" "); // deletes the first letters until it reaches the reason
  134.   var mutereason = mutereason.join(" "); // joins the list kickreason into one line
  135.   if (!mutereason) return message.reply("Please indicate a reason for the mute.") // if no reason
  136.   mutedmember.addRole(mutedrole) //if reason, kick
  137.       .catch(error => message.reply(`Sorry ${message.author} I couldn't mute because of : ${error}`)); //if error, display error
  138.  message.reply(`${mutedmember.user} has been shutdown or specificly muted. `); // sends a message saying he was kicked
  139. }
  140.  
  141. if (command == "unmute") { // creates the command unmute
  142.  if (!message.member.roles.some(r=>["Administrator", "Moderator", "administrator", "Owner"].includes(r.name)) ) return message.reply("Sorry, you do not have the permission to do this!"); // if author has no perms
  143.  var unmutedmember = message.mentions.members.first(); // sets the mentioned user to the var kickedmember
  144.  if (!unmutedmember) return message.reply("Please mention a specific member in the server.") // if there is no kickedmmeber var
  145.  unmutedmember.removeRole(mutedrole) //if reason, kick
  146.      .catch(error => message.reply(`Sorry ${message.author} I couldn't mute because of : ${error}`)); //if error, display error
  147.   message.reply(`${unmutedmember.user} has been unmuted.`);
  148. }
  149.  
  150. if (message.content.startsWith(prefix + 'shrug')) {
  151.   message.reply(' https://imgur.com/Zx9EboQ ');
  152. }
  153.  
  154. if (command === "setgame") {
  155.   if (message.author.id == "391451008124846080") {
  156.   var argresult = args.join(' ');
  157.   if (!argresult) argresult = null;
  158.   bot.user.setGame(argresult);
  159.   message.reply("It has been set..");
  160.   } else {
  161.     message.reply("DONT EVEN TRY IT BOI!");
  162.   }
  163. });
  164.  
  165. bot.login(settings.token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement