Guest User

Untitled

a guest
Feb 23rd, 2020
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. var express = require("express");
  2. var app = express();
  3. app.get("/", (request, response) => {
  4. response.sendStatus(200);
  5. });
  6. app.listen(process.env.PORT);
  7.  
  8.  
  9. const Discord = require("discord.js");
  10. const cheerio = require("cheerio");
  11. const request = require('request');
  12. const ms = require('ms');
  13. const bot = new Discord.Client();
  14. const TOKEN = process.env.TOKEN;
  15. bot.once("ready", () => {
  16. console.log("Bots Online!");
  17. });
  18.  
  19. const PREFIX = "`";
  20.  
  21. bot.on("message", message => {
  22. let args = message.content.substring(PREFIX.length).split(" ");
  23. if(!message.content.startsWith(PREFIX)) return
  24.  
  25. switch (args[0]) {
  26. case 'Userinfo':
  27. const embed = new Discord.RichEmbed()
  28. .setTitle("User Information")
  29. .setDescription("Information about yourself.")
  30. .addField('Users Name', message.author.username)
  31. .addField('Current Server', message.guild.name)
  32. .setColor(0xc328db)
  33. .setThumbnail(message.author.avatarURL)
  34. .setFooter('Made by Thatguylenin')
  35. message.channel.send(embed);
  36. break;
  37.  
  38. case'Help':
  39. const embed2 = new Discord.RichEmbed()
  40. .setTitle('Currently available Commands')
  41. .addField('ping', 'Tests if the bot is alive')
  42. .addField('info', 'Gives info on certain commands, Still a work in progress, prolly insignificant now.')
  43. .addField('website', 'Our current *useless* website.')
  44. .addField('If there are any issues with the bot (which there probably will be) Ping Lenin or Error')
  45. .setColor(0xc328db)
  46. .setFooter('Made by Thatguylenin', message.author.avatarURL)
  47. message.channel.send(embed2);
  48. break;
  49.  
  50. case 'mute':
  51. let person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]))
  52. if(!person) return message.reply("Couldn't find mentioned user");
  53.  
  54. let mainrole = message.guild.roles.find(role => role.name === "Readers");
  55. let muterole = message.guild.roles.find(role => role.name === "Annoying shit");
  56.  
  57. if(!muterole) return message.reply("No mute role");
  58.  
  59. let time = args[2];
  60.  
  61. if(!time){
  62. return message.reply("You didnt Specify a time!");
  63. }
  64. person.removeRole(mainrole.id);
  65. person.addRole(muterole.id);
  66.  
  67. message.channel.send(`@${person.user.tag} has now been muted for ${ms(ms(time))}`);
  68.  
  69. setTimeout(function(){
  70. person.addRole(mainrole.id)
  71. person.removeRole(muterole.id);
  72. message.channel.send(`@${person.user.tag} Has now been unmuted`)
  73. }, ms(time));
  74.  
  75. case 'image':
  76. image(message);
  77.  
  78. case "ping":
  79. message.reply('Pong!');
  80. break;
  81.  
  82. case 'website':
  83. message.channel.send('https://magicmushroomscanlations.weebly.com/')
  84. break;
  85.  
  86. case 'help':
  87. message.channel.send('This is a bot im working on/learning how to do, currently the prefix is "" and there are only 5 commands, Next, info, help, website, and ping. Please be patient as i add more features.')
  88. break;
  89.  
  90. case 'info':
  91. if (args[1] === 'ping'){
  92. message.channel.send('This will help tell you if the bot is alive and well');
  93. }else{
  94. message.channel.send('Unknown Command')
  95. }
  96.  
  97. case 'info':
  98. if (args[1] === 'website'){
  99. message.channel.send('This is our website, we release novels on it but only send updates about our releases there, maybe one day we will have a website');
  100. }else{
  101. message.channel.send('Unkown Command')
  102. }
  103. break;
  104. }
  105. });
  106.  
  107. function image(messages){
  108.  
  109. var options = {
  110. url: "http:results.dogpile.com/serp?qc=images&q=" + "cursed image",
  111. metho: "GET",
  112. headers: {
  113. "Accept": "text/html",
  114. "User-Agent": "Chrome"
  115. }
  116. };
  117.  
  118. bot.login(TOKEN);
  119.  
  120.  
  121. request(options, function(error, response, responseBody) {
  122. if (error) {
  123. return;
  124. }
  125.  
  126. $ = cheerio.load(responseBody);
  127.  
  128.  
  129. var links = $(".image a.link");
  130.  
  131. var urls = new Array(links.length).fill(0).map((v, i) => links.eq(i).attr("href"));
  132.  
  133. console.log(urls);
  134.  
  135. if (!urls.length) {
  136.  
  137. return;
  138. }
  139.  
  140. //Send result
  141. message.channel.send( urls[Math.floor(Math.random() * urls.length)]);
  142. });
Add Comment
Please, Sign In to add comment