Guest User

Untitled

a guest
Aug 14th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. client.on('ready', () => {
  2. console.log('Bot is ready!')
  3. checkLiveUpdating();
  4. });
  5.  
  6. function checkLiveUpdating() {
  7. if(config.Server.AutoRefresh.Enabled == true) {
  8. const guild = client.guilds.get(config.Server.GuildId);
  9. if(guild) {
  10. const channel = guild.channels.find("name", config.Server.AutoRefresh.ChannelName);
  11. if(channel) {
  12. liveUpdating(channel);
  13. } else {
  14. console.log("Valid channel not found! Please check your settings and the bot's permissions.");
  15. }
  16. } else {
  17. console.log("Guild not found! Please check the id and make sure the bot is joined to the guild.");
  18. }
  19. }
  20. }
  21.  
  22. async function liveUpdating(Channel) {
  23. var LatestMessage = "";
  24. while(true) {
  25. request('https://' + config.Logger.Subdomain + "." + activitylink, function (error, response, html) {
  26. if (!error && response.statusCode == 200) {
  27. var $ = cheerio.load(html);
  28. $('.activity-type-edit').each(function(i, element) {
  29. if($("strong a", element).text().indexOf("User:") === -1 && done == false) {
  30. var whatWasEdited = $("table tbody tr td em", element).text();
  31. if(whatWasEdited !== "") {} else {whatWasEdited = "Page";}
  32. var Message = $("strong a", element).text() + " - " + $("cite span", element).text() + ". Edited: " + whatWasEdited;
  33. if(LatestMessage !== Message) {
  34. Channel.send(`New edit on the wikia:n${Message}`);
  35. LatestMessage = Message;
  36. done = true;
  37. }
  38. }
  39. });
  40. }
  41. });
  42. await delay(1000)
  43. done = false;
  44. }
  45. }
  46.  
  47. New edit on the wikia:
  48. Red Counter - edited by TomurA5 10 minutes ago. Edited: Added photo
  49. New edit on the wikia:
  50. Eijiro Kirishima - edited by TomurA5 12 minutes ago. Edited: Summary
Add Comment
Please, Sign In to add comment