diff --git a/controller/home.js b/controller/home.js index 3f05e1c..c38be9a 100644 --- a/controller/home.js +++ b/controller/home.js @@ -4,4 +4,8 @@ exports.home = (io)=> { res.render('home') } +} +exports.addtodiscord = (req, res)=> +{ + return res.redirect('https://discord.com/oauth2/authorize?client_id=356104008366030863&permissions=8&scope=bot') } \ No newline at end of file diff --git a/lib.js b/lib.js index 6b69ac4..1ab41bc 100644 --- a/lib.js +++ b/lib.js @@ -212,6 +212,7 @@ class _Client extends Client if(!res) return false; const channel = this.channels.cache.get(feed.ChannelId); if(!channel) return false; + var aux = res; const lastSentMessage= await channel.messages.fetch().then(res=> { for(var item of res) @@ -222,15 +223,16 @@ class _Client extends Client { var fields = item[1].embeds[0].fields.filter(x=>x.name === 'PublishedTimeStamp'); var isFeed = fields.length>0; - if(isFeed) return item[1].embeds[0]; + if(isFeed && item[1].embeds[0].title == aux.author.name) return item[1].embeds[0]; } } } }) - const lastSentMessagePublished = lastSentMessage.fields[0].value; - const lastSentMessageChannelURL = lastSentMessage.data.url + if(!lastSentMessage) return sendMessage(res, feed, channel); + const lastSentMessagePublished = lastSentMessage.fields.filter(x=>x.name === 'PublishedTimeStamp')[0].value; + console.log(lastSentMessagePublished != res.published , 'lastSentPublished',lastSentMessagePublished,'published', res.published) if(!lastSentMessagePublished) sendMessage(res, feed, channel) - else if(lastSentMessagePublished != res.published && lastSentMessageChannelURL == res.author.url) sendMessage(res, feed, channel); + else if(lastSentMessagePublished != res.published) sendMessage(res, feed, channel); })(feed); } function sendMessage(res, feed, channel) @@ -244,7 +246,8 @@ class _Client extends Client embed.setTitle(res.author.name); embed.setImage(`https://i3.ytimg.com/vi/${res.image}/maxresdefault.jpg`) embed.setDescription(feed.CostumMessage); - embed.addFields({name:'PublishedTimeStamp', value:res.published}, + embed.addFields({name:res.title, value:' '}, + {name:'PublishedTimeStamp', value:res.published}, {name:'Link:', value:res.link}); channel.send({embeds:[embed]}); } diff --git a/routes/routes.js b/routes/routes.js index c7f088a..f080b1d 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -20,14 +20,17 @@ module.exports = (io, bot)=> router.route('/api/deleteRule').post(api.deleteRule); router.route('/dashboard').get(dash.get(io)) .post(dash.post(io)); - router.route('/getMessage').get(api.getMessage(bot)) - router.route('/leagues').get(api.getTournamentPage) - router.route('/league/:league').get(api.getLeaguePage) - router.route('/leagueListener').get(api.getTournamentListenerPage) + router.route('/getMessage').get(api.getMessage(bot)); + router.route('/leagues').get(api.getTournamentPage); + router.route('/league/:league').get(api.getLeaguePage); + router.route('/leagueListener').get(api.getTournamentListenerPage); + router.route('/game').get(api.getGame); + router.route('/api/getGameData').get(api.getGameData); router.route('/api/RegisterGame').post(api.registerGame); router.route('/api/getAllLeagues').get(api.getAllLeagues); router.route('/api/getLeague').get(api.getLeague); router.route('/createLeague').get(api.createLeaguePage) router.route('/api/createLeague').post(api.createLeague) + router.route('/addtodiscord').get(homeController.addtodiscord) return router; }; \ No newline at end of file