Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client.on('ready', () => {
- console.log('Bot is ready!')
- checkLiveUpdating();
- });
- function checkLiveUpdating() {
- if(config.Server.AutoRefresh.Enabled == true) {
- const guild = client.guilds.get(config.Server.GuildId);
- if(guild) {
- const channel = guild.channels.find("name", config.Server.AutoRefresh.ChannelName);
- if(channel) {
- liveUpdating(channel);
- } else {
- console.log("Valid channel not found! Please check your settings and the bot's permissions.");
- }
- } else {
- console.log("Guild not found! Please check the id and make sure the bot is joined to the guild.");
- }
- }
- }
- async function liveUpdating(Channel) {
- var LatestMessage = "";
- while(true) {
- request('https://' + config.Logger.Subdomain + "." + activitylink, function (error, response, html) {
- if (!error && response.statusCode == 200) {
- var $ = cheerio.load(html);
- $('.activity-type-edit').each(function(i, element) {
- if($("strong a", element).text().indexOf("User:") === -1 && done == false) {
- var whatWasEdited = $("table tbody tr td em", element).text();
- if(whatWasEdited !== "") {} else {whatWasEdited = "Page";}
- var Message = $("strong a", element).text() + " - " + $("cite span", element).text() + ". Edited: " + whatWasEdited;
- if(LatestMessage !== Message) {
- Channel.send(`New edit on the wikia:n${Message}`);
- LatestMessage = Message;
- done = true;
- }
- }
- });
- }
- });
- await delay(1000)
- done = false;
- }
- }
- New edit on the wikia:
- Red Counter - edited by TomurA5 10 minutes ago. Edited: Added photo
- New edit on the wikia:
- Eijiro Kirishima - edited by TomurA5 12 minutes ago. Edited: Summary
Add Comment
Please, Sign In to add comment