Advertisement
Guest User

hexbot

a guest
Jan 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const moment = require('moment')
  2. const util = require("util");
  3. const Eris = require("eris")
  4. const axios = require('axios')
  5. const Permissions = require('eris').Constants.Permissions;
  6. var bot = new
  7. Eris.CommandClient("BOT_TOKEN", {}, {
  8.     description: "A test bot made entirely",
  9.     owner: "Axiatinc",
  10.     prefix: "!"
  11. });
  12.  
  13. bot.on("ready", () => {
  14.     console.log("Ready!");
  15. })
  16.  
  17.  
  18. bot.registerCommand("about", "**About this bot:** \n This bot was coded by Juuzou Suzuya, using the **Eris** library by abalabahaha, in JavaScript\n \n For more information, contact Juuzou Suzuya#6044, or join our support server here: https://discord.gg/QtQBHcW", {
  19.     description: "About",
  20.     fullDescription: "This command gives you information about the bot."
  21. });
  22.  
  23. var echoCommand = bot.registerCommand("echo", (msg, args) => { // Make an echo command
  24.     if(args.length === 0) { // If the user just typed "!echo", say "Invalid input"
  25.         return "Invalid input";
  26.     }
  27.     var text = args.join(" "); // Make a string of the text after the command label
  28.     return text; // Return the generated string
  29. }, {
  30.     description: "Make the bot say something",
  31.     fullDescription: "The bot will echo whatever is after the command label.",
  32.     usage: "<text>"
  33. });
  34.  
  35.  
  36. //Kick command
  37. //Usage: !kick @Username
  38. bot.registerCommand("kick", (msg, args) => {
  39.     bot.kickGuildMember(msg.channel.guild.id, msg.mentions[0].id);
  40.         bot.createMessage(msg.channel.id, "Kicked user " + msg.mentions[0].username);
  41. },{
  42.     requirements: {
  43.         permissions: {
  44.         "kickMembers": true
  45.     }
  46.     }
  47. });
  48.  
  49.  
  50.  
  51. bot.registerCommand("invite", (msg) => {
  52. bot.createMessage(msg.channel.id, "**Hello!** | I see you want to invite me to your server! Well heres the link: https://discordapp.com/oauth2/authorize?client_id=401844837793660939&scope=bot&permissions=2146958591");
  53. },{
  54.     description: "Get the discord bots invite link",
  55.     fullDescription: "Invite HexBot to your discord server, so you can use it yourself!"
  56. });
  57.  
  58. //Ban Command
  59. //Usage: !ban @Username
  60. bot.registerCommand("ban", (msg, args) => {
  61.     bot.banGuildMember(msg.channel.guild.id, msg.mentions[0].id);
  62.         bot.createMessage(msg.channel.id, "Banned user " + msg.mentions[0].username);
  63. },{
  64.     requirements: {
  65.         permissions: {
  66.         "banMembers": true
  67.     }
  68.     }
  69. });
  70.  
  71. module.exports = {
  72.     process: async message => {
  73.         let guild = message.channel.guild, channel = message.channel, author = message.author, member = message.member; // eslint-disable-line
  74.  
  75.         try {
  76.             let output = await eval(`(async function(){${message.args[0].replace(/“|”/g, "\"")}}).call()`);
  77.             output = util.inspect(output, { depth: 0 }).substring(0, 1900);
  78.             return `:white_check_mark: **Output:** ${bot.utils.codeBlock(output, "js")}`;
  79.         } catch(error) {
  80.             return `:x: **Error:** ${bot.utils.codeBlock(error)}`;
  81.         }
  82.     },
  83.     caseSensitive: true,
  84.     description: "Execute code",
  85.     args: [{
  86.         type: "text",
  87.         label: "code"
  88.     }]
  89. };
  90.  
  91. echoCommand.registerSubcommand("reverse", (msg, args) => { // Make a reverse subcommand under echo
  92.     if(args.length === 0) { // If the user just typed "!echo reverse", say "Invalid input"
  93.         return "Invalid input";
  94.     }
  95.     var text = args.join(" "); // Make a string of the text after the command label
  96.     text = text.split("").reverse().join(""); // Reverse the string
  97.     return text; // Return the generated string
  98. }, {
  99.     description: "Make the bot say something in reverse",
  100.     fullDescription: "The bot will echo, in reverse, whatever is after the command label.",
  101.     usage: "<text>"
  102. });
  103.  
  104.  
  105. echoCommand.registerSubcommandAlias("backwards", "reverse"); // Alias "!echo backwards" to "!echo reverse"
  106.  
  107. let clean = bot.registerCommand('clean', (msg, args) => {
  108.     let toDelete = parseInt(args.length > 0 ? args[0] : 10);
  109.     if(!toDelete) return 'Please supply a valid number';
  110.  
  111.     bot.purgeChannel(msg.channel.id, toDelete + 1).then(del => {
  112.         bot.createMessage(msg.channel.id, `${del - 1} messages deleted`).then(msg => {
  113.             setTimeout(() => bot.deleteMessage(msg.channel.id, msg.id), 4000);
  114.         });
  115.     });
  116. }, {
  117.     description: 'Deletes messages',
  118.     fullDescription: 'The bot will delete messages from all users in the last specified number of messages',
  119.     usage: '<number to search through>',
  120.     requirements: {
  121.         permissions: {
  122.             "manageMessages": true
  123.         }
  124.     }
  125. });
  126.  
  127. bot.registerCommand('ping', (msg, args) => {
  128.     bot.createMessage(msg.channel.id, 'pong').
  129.     then(newMsg => {
  130.         bot.editMessage(newMsg.channel.id, newMsg.id, `\`\`\`javascript\npong | Time taken: ${newMsg.timestamp - msg.timestamp} ms\`\`\``);
  131.     });
  132. }, {
  133.     description: 'Ping me to make sure I\'m alive',
  134.     fullDescription: 'The bot will reply with the amount of time taken'
  135. });
  136.  
  137. bot.registerCommand('uptime', (msg, args) => {
  138.     let totalSeconds = process.uptime();
  139.  
  140.     let days = Math.floor(totalSeconds / 86400);
  141.     totalSeconds %= 86400;
  142.  
  143.     let hours = Math.floor(totalSeconds / 3600);
  144.     totalSeconds %= 3600;
  145.  
  146.     let minutes = Math.floor(totalSeconds / 60);
  147.     let seconds = Math.floor(totalSeconds % 60);
  148.  
  149.     bot.createMessage(msg.channel.id, `\`${days} days, ${hours} hrs, ${minutes} min, ${seconds} sec\``);
  150. }, {
  151.     description: 'Check my uptime',
  152.     fullDescription: 'The bot will reply with the amount of time it has been available'
  153.  
  154. });
  155.  
  156.  
  157. bot.registerCommand('mute', (msg, args) => {
  158.     if(args.length === 0) return 'Please supply a user to mute';
  159.  
  160.     let toFind = bot.users.find(u => u.username === args[0]);
  161.     if(!toFind) return 'Please supply a valid user';
  162.  
  163.     bot.editChannelPermissions(msg.channel.id, msg.author.id, 0, Permissions.sendMessages);
  164. }, {
  165.     description: 'Mutes a user',
  166.     fullDescription: 'Mutes a user so they will not be able to send messages in their current channel',
  167.     usage: '<number to search through>',
  168.     requirements: {
  169.         permissions: {
  170.             "manageMessages": true
  171.         }
  172.     }
  173. });
  174.  
  175. bot.registerCommand('roll', (msg, args) => {
  176.     if(args.length === 0) return Math.floor(Math.random() * 100000) + 1;
  177.  
  178.     let roll = parseInt(args[0]);
  179.     if(!roll) return 'Please supply a number';
  180.  
  181.     return Math.floor(Math.random() * roll) + 1;
  182. }, {
  183.     description: 'Roll a 100000sided die',
  184.     fullDescription: 'Have the bot roll a number between 0 and 100, or a different specified max',
  185.     usage: '<max number for roll>'
  186. });
  187.  
  188.   bot.registerCommand('movie', (msg, args) => {
  189.     axios
  190.       .get(`https://api.themoviedb.org/3/search/movie?api_key=${'18098c7fa8072885bb609c96512e1d32'}&query=${args}`)
  191.       .then(response => {
  192.         axios
  193.             .get(`https://api.themoviedb.org/3/movie/${response.data.results[0].id}?api_key=${'18098c7fa8072885bb609c96512e1d32'}&language=en-US`)
  194.             .then(response => {
  195.               const embed = {
  196.                 author: {
  197.                   name: response.data.original_title,
  198.                   icon_url: 'https://www.themoviedb.org/assets/static_cache/2dceae11589334eecd61443249261daf/images/v4/logos/208x226-stacked-green.png',
  199.                   url: response.data.homepage !== null ? response.data.homepage : ''
  200.                 },
  201.                 title: 'Movie Information:',
  202.                 color: 16765404,
  203.                 fields: [
  204.                   {
  205.                     name: 'Release Date',
  206.                     value: response.data.release_date !== null ? response.data.release_date : 'N/A',
  207.                     inline: true
  208.                   },
  209.                   {
  210.                     name: 'Vote Average',
  211.                     value: response.data.vote_average.toString() !== null ? response.data.vote_average.toString() : 'N/A',
  212.                     inline: true
  213.                   },
  214.                   {
  215.                     name: 'Status',
  216.                     value: response.data.status !== null ? response.data.status : 'N/A',
  217.                     inline: true
  218.                   },
  219.                   {
  220.                     name: 'Runtime',
  221.                     value: response.data.runtime.toString() !== null ? response.data.runtime.toString() + ' min' : 'N/A',
  222.                     inline: true
  223.                   },
  224.                   {
  225.                     name: 'Genre',
  226.                     value: response.data.genres[0].name !== null ? response.data.genres[0].name : 'N/A',
  227.                     inline: true
  228.                   },
  229.                   {
  230.                     name: 'Production Company',
  231.                     value: response.data.production_companies[0].name !== null ? response.data.production_companies[0].name : 'N/A',
  232.                     inline: true
  233.                   },
  234.                   {
  235.                     name: 'Language',
  236.                     value: response.data.original_language !== null ? response.data.original_language : 'N/A',
  237.                     inline: true
  238.                   },
  239.                   {
  240.                     name: 'Country',
  241.                     value: response.data.production_countries[0].name !== null ? response.data.production_countries[0].name : 'N/A',
  242.                     inline: true
  243.                   },
  244.                   {
  245.                     name: 'Plot',
  246.                     value: response.data.overview !== null ? response.data.overview : 'N/A',
  247.                     inline: false
  248.                   }
  249.                 ],
  250.                 thumbnail: {
  251.                   url: response.data.poster_path !== null ? 'https://image.tmdb.org/t/p/w500' + response.data.poster_path : 'https://www.themoviedb.org/assets/static_cache/2dceae11589334eecd61443249261daf/images/v4/logos/208x226-stacked-green.png'
  252.                 },
  253.                 timestamp: new Date(),
  254.                 footer: {
  255.                   icon_url: bot.user.avatarURL,
  256.                   text: bot.user.username
  257.                 }
  258.               }
  259.               bot.createMessage(msg.channel.id, {
  260.                 embed: embed
  261.               })
  262.             })
  263.       })
  264.   })
  265.   bot.registerCommand('anime', (msg, args) => {
  266.     axios
  267.       .get(`https://kitsu.io/api/edge/anime?filter[text]=${args}`)
  268.       .then(response => {
  269.         const embed = {
  270.           author: {
  271.             name: response.data.data[0].attributes.titles.en,
  272.             icon_url:
  273.               'https://pbs.twimg.com/profile_images/807964865511862278/pIYOVdsl_400x400.jpg',
  274.             url: `https://kitsu.io/anime/${response.data.data[0].attributes.slug}`
  275.           },
  276.           title: 'Anime Information:',
  277.           color: 16765404,
  278.           fields: [
  279.             {
  280.               name: 'Episode Count',
  281.               value: response.data.data[0].attributes.episodeCount != null ? response.data.data[0].attributes.episodeCount.toString() : 'None',
  282.               inline: true
  283.             },
  284.             {
  285.               name: 'Episode Length',
  286.               value: response.data.data[0].attributes.episodeLength != null ? response.data.data[0].attributes.episodeLength.toString() : 'None',
  287.               inline: true
  288.             },
  289.             {
  290.               name: 'Started Airing',
  291.               value: response.data.data[0].attributes.startDate != null ? response.data.data[0].attributes.startDate : 'None',
  292.               inline: true
  293.             },
  294.             {
  295.               name: 'Finished Airing',
  296.               value: response.data.data[0].attributes.endDate != null ? response.data.data[0].attributes.endDate : 'None',
  297.               inline: true
  298.             },
  299.             {
  300.               name: 'Kitsu.io Rating',
  301.               value: response.data.data[0].attributes.averageRating != null ? response.data.data[0].attributes.averageRating.toString() : 'None',
  302.               inline: true
  303.             },
  304.             {
  305.               name: 'Age Rating',
  306.               value: response.data.data[0].attributes.ageRating != null ? response.data.data[0].attributes.ageRating : 'None',
  307.               inline: true
  308.             },
  309.             {
  310.               name: 'Synopsis',
  311.               value: response.data.data[0].attributes.synopsis != null ? response.data.data[0].attributes.synopsis : 'None',
  312.               inline: false
  313.             }
  314.           ],
  315.           thumbnail: {
  316.             url: response.data.data[0].attributes.posterImage.medium
  317.           },
  318.           timestamp: new Date(),
  319.           footer: {
  320.             icon_url: bot.user.avatarURL,
  321.             text: bot.user.username
  322.           }
  323.         }
  324.  
  325.         // Create message
  326.         bot.createMessage(msg.channel.id, {
  327.           embed: embed
  328.         })
  329.       })
  330.   })
  331.  
  332.  
  333.  
  334. bot.connect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement