Advertisement
ComputerMan123

HouseBot Source Code

Oct 28th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.86 KB | None | 0 0
  1.  
  2. const Discord = require("discord.js");
  3. const yt = require("ytdl-core");
  4. const bot = new Discord.Client();
  5.  
  6. const mamajokes = [ // Some amazing yo mama jokes
  7. "Yo mama so fat she left the house in high heels and when she came back she had on flip flops.",
  8. "Yo mama so fat she sat on an iPhone and turned it into an iPad",
  9. "Yo mama so fat she went to KFC to get a bucket of chicken they asked her what size and she said the one on the roof",
  10. "Yo momma so fat she sued xbox 360 for guessing her weight",
  11. "yo mama so fat that she dont need the internet she's already world wide",
  12. "Yo mama so fat that I ran out of gas trying to drive around her.",
  13. ];
  14.  
  15. const square = [
  16. "------------------"
  17. ]
  18. const prefix = '>>'; // Prefix for commands, you can change this
  19. const token = 'Token'; // Token to login to bot goes here
  20. const annouce_channel = ""
  21.  
  22.  
  23. // HouseBot by houseofkraft
  24. // This is a basic bot using discord.js
  25. // If you copy this bot, Please give me credit
  26.  
  27.  
  28. bot.on("ready", () => { // Executes the code below when the bot is ready for use
  29. bot.user.setStatus("online", "HouseBot | >>help");
  30. console.log("Ready!");
  31. });
  32.  
  33.  
  34.  
  35.  
  36.  
  37. bot.on("message", message => { // Executes all the code below when a user sends a message
  38.  
  39. // Functions
  40. function checkPerm(member, perm) {
  41. if( message.member.roles.filter(r=>r.hasPermission(perm)).size > 0) {
  42. return true
  43. // Returns True
  44. }
  45. else {
  46. return false
  47. // Returns False
  48. }
  49. }
  50.  
  51.  
  52. function play(url) { // A little broken at the moment
  53. const ytdl = require('ytdl-core');
  54. const streamOptions = { seek: 0, volume: 1 };
  55. const stream = ytdl(url, {filter : 'audioonly'});
  56. const dispatcher = connection.playStream(stream, streamOptions);
  57. }
  58.  
  59. // Commands
  60. if (message.content.startsWith(prefix + "about")) var sent = true message.channel.sendMessage("HouseBot made by houseofkraft");
  61. if (message.content.startsWith(prefix + "help")) var sent = true message.author.sendMessage("HouseBot Help \n```Commands:\n help - Get's 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 ban <person> - Ban's the person (Admins only) \n music_join - Makes the bot join the voice channel \n music_leave - Makes the bot leave the voice channel \n roll - Roll's the dice! \n yomama - Yo mama jokes!\n servers - Tells you how much servers HouseBot is on \n square - Makes a square \nBy houseofkraft``` Version: V1.1.0");
  62. if (message.content.startsWith(prefix + "logo")) var sent = true message.channel.sendFile("http://i.imgur.com/yy4aG6o.png");
  63. if (message.content.startsWith(prefix + "winlogo")) var sent = true message.channel.sendFile("http://i.imgur.com/Gy2aISn.png");
  64. if (message.content === "<@236597190611566602> Hi") var sent = true message.channel.sendMessage("Hi, " + message.author);
  65. if (message.content === "<@236597190611566602> hi") var sent = true message.channel.sendMessage("Hi, " + message.author);
  66. if (message.content === "<@236597190611566602>") var sent = true message.channel.sendMessage("Wat?");
  67. if (message.content.startsWith(prefix + "invite")) var sent = true message.author.sendMessage("You can invite the bot to other servers by using this link: https://discordapp.com/oauth2/authorize?client_id=236597190611566602&scope=bot&permissions=101378");
  68. if (message.content.startsWith(prefix + "isadmin")) var sent = true message.channel.sendMessage("Admin: " + checkPerm(message.author, "ADMINISTRATOR")); // Mostly for checking if the permission checking works, comment this cmd out to disable
  69. if (message.content.startsWith(prefix + "uptime")) var sent = true message.channel.sendMessage("Uptime: " + (process.uptime() /60).toFixed(0) + " minute(s)")
  70. if (message.content.startsWith(prefix + "wipeall")) {
  71. let args = message.content.split(" ").slice(1);
  72. message.channel.sendMessage("Purging " + totalmsgs.length + " messages...");
  73. message.channel.bulkDelete(totalmsgs);
  74. message.channel.sendMessage("Purged " + totalmsgs.length + " messages.");
  75. var sent = true
  76. }
  77.  
  78. if (message.content.startsWith(prefix + "say")) {
  79. var user = message.author;
  80. let saytext = message.content.split(" ").slice(1);
  81. message.delete();
  82. message.channel.sendMessage(saytext);
  83. var sent = true
  84. }
  85.  
  86. if (message.content.startsWith(prefix + "kick")) { // Admin Command
  87. let userToKick = message.mentions.users.first();
  88. if (checkPerm(message.author, "KICK_MEMBERS") === true) {
  89. if (checkPerm(userToKick, "ADMINISTRATOR") === true) {
  90. message.channel.sendMessage("You cannot kick admins!");
  91. }
  92. else {
  93. message.guild.member(userToKick).kick();
  94. message.channel.sendMessage("Kicked " + userToKick + " by " + message.author);
  95. }
  96. };
  97. var sent = true
  98. }
  99.  
  100. if (message.content.startsWith(prefix + "ban")) { // Admin Command
  101. let userToKick = message.mentions.users.first();
  102. if (checkPerm(message.author, "KICK_MEMBERS") === true) {
  103. if (checkPerm(userToKick, "ADMINISTRATOR") === true) {
  104. message.channel.sendMessage("You cannot ban admins!");
  105. }
  106. else {
  107. message.guild.member(userToKick).ban();
  108. message.channel.sendMessage("Banned " + userToKick + " by " + message.author);
  109. }
  110. };
  111. var sent = true
  112. }
  113.  
  114. if (message.content.startsWith(prefix + "music_join")) { // Music Module
  115. const voiceChannel = message.member.voiceChannel;
  116. if (!voiceChannel || voiceChannel.type !== 'voice') {
  117. message.channel.sendMessage(":warning: You are not in a voice channel")
  118. }
  119. else {
  120. message.channel.sendMessage(":white_check_mark: Sucessfully joined " + voiceChannel);
  121. voiceChannel.join().then(connection => resolve(connection)).catch(err => reject(err));
  122. }
  123. if (message.guild.voiceConnection === "") {
  124. message.channel.sendMessage(":warning: Your voice channel either reached the max people allowed or is locked")
  125. }
  126. var sent = true
  127. }
  128.  
  129. if (message.content.startsWith(prefix + "music_leave")) {
  130. const voiceChannel = message.member.voiceChannel;
  131. voiceChannel.leave()
  132. message.channel.sendMessage(":white_check_mark: Sucessfully left " + voiceChannel);
  133. var sent = true
  134. }
  135.  
  136. if (message.content.startsWith(prefix + "play")) { // Don't get this confused with the play function, this just activates the play function
  137. let args = message.content.split(" ").slice(1);
  138. let song = args[0];
  139. play(song);
  140. var sent = true
  141. }
  142.  
  143. if (message.content.startsWith(prefix + "roll")) {
  144. var roll = Math.floor(Math.random() * 4) + 1
  145. if (roll === 1) {
  146. return message.channel.sendMessage(":one:");
  147. }
  148. if (roll === 2) {
  149. return message.channel.sendMessage(":two:");
  150. }
  151. if (roll === 3) {
  152. return message.channel.sendMessage(":three:");
  153. }
  154. if (roll === 4) {
  155. return message.channel.sendMessage(":four:");
  156. }
  157. var sent = true
  158. }
  159.  
  160. if (message.content.startsWith(prefix + "yomama")) {
  161. var joke = Math.floor(Math.random() * mamajokes.length) + 1
  162. message.channel.sendMessage(mamajokes[joke])
  163. var sent = true
  164. }
  165.  
  166. if (message.content.startsWith(prefix + "servers")) {
  167. message.channel.sendMessage("HouseBot is on **" + bot.guilds.size + "** servers, monitoring **" + bot.channels.size + "** channels.");
  168. var sent = true
  169. }
  170.  
  171. if (message.content.startsWith(prefix + "square")) {
  172. square.forEach(function (i, index, array) {
  173. message.channel.sendMessage(i)
  174. var sent = true
  175. });
  176. }
  177.  
  178. else {
  179. if message.content.startsWith(prefix) {
  180. if sent === false {
  181. message.channel.sendMessage("Invaild Message!")
  182. }
  183. }
  184. }
  185.  
  186. });
  187. bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement