Advertisement
ComputerMan123

HouseBot

Oct 16th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const yt = require("ytdl-core");
  3. const bot = new Discord.Client();
  4. const now = require("performance-now");
  5. const prefix = '>>'; // Prefix for commands, you can change this
  6. const token = 'Token'; // Token to login to bot goes here
  7. const publicLog = "housebot-log" // Change this to the name of the logging channel
  8. const logid = "237308574857035777" // Change this to the channel ID of the log channel you want, make it "" for nothing
  9. var totalmsgs = []
  10.  
  11.  
  12.  
  13. // HouseBot by houseofkraft
  14. // Please don't copy this
  15.  
  16.  
  17. bot.on("ready", () => { // Executes the code below when the bot is ready for use
  18.     bot.user.setStatus("online", "HouseBot | >>help");
  19.     console.log("Ready!");
  20. });
  21.  
  22. setInterval(() => { // This code here will make the log channel's description will have the uptime
  23.     msg.guild.channels.get(logid).setTopic(":gear: HouseBot Logs | Uptime: " + process.uptime() /60).toFixed(0) + " minute(s)"
  24. }, 10000)
  25.  
  26.  
  27.  
  28.    
  29. bot.on("message", message => {  // Executes all the code below when a user sends a message
  30.  
  31. function checkPerm(member, perm) { // This function will come in handy
  32.     if( message.member.roles.filter(r=>r.hasPermission(perm)).size > 0) {
  33.         return true
  34.     }
  35.     else {
  36.         return false
  37.     }
  38. }  
  39.  
  40.  
  41. function play(url) { // A little broken at the moment
  42. // play streams using ytdl-core
  43. const ytdl = require('ytdl-core');
  44. const streamOptions = { seek: 0, volume: 1 };
  45.    const stream = ytdl(url, {filter : 'audioonly'});
  46.    const dispatcher = connection.playStream(stream, streamOptions);
  47. }
  48.  
  49.  
  50.  
  51. // My little chat logger
  52. if (logid !== "") {
  53.   if (message.author !== bot.user) {
  54.   totalmsgs.push(message.content);
  55.   var user = message.author.username;
  56.   var m = message.content;
  57.   var channelname = message.channel.name;
  58.   var r = message.author.role
  59.   message.guild.channels.get(logid).sendMessage("[INFO]: " + user + " said " + m); //+ " in channel " + channelname);
  60.   }
  61. }
  62.  
  63.  
  64. // Commands
  65. if (message.content.startsWith(prefix + "about"))  message.channel.sendMessage("HouseBot Beta made by houseofkraft");  
  66. if (message.content.startsWith(prefix + "help"))  message.channel.sendMessage("```Commands:\n help - Gets help for commands.\n ping - Pong!\n about - Show's who made this bot.\n logo - HouseBot logo\n winlogo - Windows logo\n invite - Tell's you the link to invite HouseBot to other Discord Servers\n isadmin - Says if your an admin (admin perm) or not\n say <message> - Says a message\n kick <person> - Kick's the person (Admins Only) \n music_join - Makes the bot join the voice channel \nBy houseofkraft```");  
  67. if (message.content.startsWith(prefix + "logo"))  message.channel.sendFile("http://i.imgur.com/yy4aG6o.png");
  68. if (message.content.startsWith(prefix + "winlogo"))  message.channel.sendFile("http://i.imgur.com/Gy2aISn.png");
  69. if (message.content === "<@236597190611566602> Hi") message.channel.sendMessage("Hi, " + message.author);
  70. if (message.content === "<@236597190611566602> hi") message.channel.sendMessage("Hi, " + message.author);
  71. if (message.content === "<@236597190611566602>") message.channel.sendMessage("Wat?");
  72. if (message.content.startsWith(prefix + "invite")) message.channel.sendMessage("You can invite the bot to other servers by using this link: https://discordapp.com/oauth2/authorize?client_id=236597190611566602&scope=bot&permissions=101376=0x400|0x800|0x8000|0x10000");
  73. if (message.content.startsWith(prefix + "isadmin"))  message.channel.sendMessage("Admin: " + checkPerm(message.author, "ADMINISTRATOR")); // Mostly for checking if the permission checking works, comment this cmd out to disable
  74. if (message.content.startsWith(prefix + "uptime")) message.channel.sendMessage("Uptime: " + (process.uptime() /60).toFixed(0) + " minute(s)")
  75. if (message.content.startsWith(prefix + "wipeall")) {
  76.    let args = message.content.split(" ").slice(1);
  77.    message.channel.sendMessage("Purging " + totalmsgs.length + " messages...");
  78.    message.channel.bulkDelete(totalmsgs);
  79.    message.channel.sendMessage("Purged " + totalmsgs.length + " messages.");  
  80. }
  81.  
  82. if (message.content.startsWith(prefix + "say")) { // For saying text, blacklist is all the way up
  83.     var user = message.author;
  84.     let saytext = message.content.split(" ").slice(1);
  85.     message.channel.sendMessage(saytext);
  86. }
  87.  
  88. if (message.content.startsWith(prefix + "kick")) { // Admin Command
  89.      let userToKick = message.mentions.users.first();
  90.      if (checkPerm(message.author, "KICK_MEMBERS") === true) {
  91.       if (checkPerm(userToKick, "ADMINISTRATOR") === true) {
  92.           message.channel.sendMessage("You cannot kick admins!");
  93.       }
  94.       else {
  95.                message.guild.member(userToKick).kick();
  96.              message.channel.sendMessage("Kicked " + userToKick + " by " + message.author);
  97.       }
  98.   };
  99. }
  100.  
  101. if (message.content.startsWith(prefix + "ban")) { // Admin Command
  102.      let userToKick = message.mentions.users.first();
  103.      if (checkPerm(message.author, "KICK_MEMBERS") === true) {
  104.       if (checkPerm(userToKick, "ADMINISTRATOR") === true) {
  105.           message.channel.sendMessage("You cannot ban admins!");
  106.       }
  107.       else {
  108.                message.guild.member(userToKick).ban();
  109.              message.channel.sendMessage("Banned " + userToKick + " by " + message.author);
  110.       }
  111.   };
  112. }
  113.  
  114. if (message.content.startsWith(prefix + "ping")) {
  115.   message.channel.sendMessage("Ping");
  116.   message.edit("Pong!");
  117. }
  118.  
  119. if (message.content.startsWith(prefix + "music_join")) {
  120.   const voiceChannel = message.member.voiceChannel;
  121.   if (!voiceChannel || voiceChannel.type !== 'voice') {
  122.       message.channel.sendMessage(":warning: You are not in a voice channel")
  123.   }
  124.   else {
  125.       message.channel.sendMessage(":white_check_mark: Sucessfully joined " + voiceChannel);
  126.       voiceChannel.join().then(connection => resolve(connection)).catch(err => reject(err));
  127.   }
  128.    if (message.guild.voiceConnection === "") {
  129.        message.channel.sendMessage(":warning: Your voice channel either reached the max people allowed or is locked")
  130.    }
  131. }
  132.  
  133. if (message.content.startsWith(prefix + "music_leave")) {
  134.    const voiceChannel = message.member.voiceChannel;
  135.   voiceChannel.leave()
  136.   message.channel.sendMessage(":white_check_mark: Sucessfully left " + voiceChannel);
  137. }
  138.  
  139. if (message.content.startsWith(prefix + "play")) { // Don't get this confused with the play function, this just activates the play function
  140.     let args = message.content.split(" ").slice(1);
  141.     let song = args[0];
  142.     play(song);
  143. }
  144.  
  145.  
  146.      
  147.  
  148. });
  149. bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement