Fix links not being properly cached with camo integration
This commit is contained in:
parent
a64c3eeefb
commit
78eec753f1
11
app/index.js
11
app/index.js
|
@ -24,13 +24,12 @@ client.on("message", message => {
|
|||
|
||||
client.guildDataModel.findOne({ guildID: message.guild.id })
|
||||
.then(guildData => {
|
||||
if (guildData)
|
||||
guildData.feeds.forEach(feedData => {
|
||||
if (message.channel.id === feedData.channelID)
|
||||
feedData.cachedLinks.push(...GetUrls(message.content));
|
||||
});
|
||||
if (guildData) {
|
||||
guildData.feeds.forEach(feedData =>
|
||||
message.channel.id === feedData.channelID && feedData.cache(...GetUrls(message.content)));
|
||||
guildData.save();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
client.bootstrap();
|
||||
|
|
|
@ -41,7 +41,7 @@ module.exports = class FeedData extends Camo.EmbeddedDocument {
|
|||
.then(messages => {
|
||||
/* we want to push the links in oldest first, but discord.js returns messages newest first, so we need to reverse them
|
||||
* discord.js returns a map, and maps don't have .reverse methods, hence needing to spread the elements into an array first */
|
||||
[...messages.values()].reverse().forEach(m => this.cachedLinks.push(...GetUrls(m.content)));
|
||||
[...messages.values()].reverse().forEach(m => this.cache(...GetUrls(m.content)));
|
||||
resolve();
|
||||
})
|
||||
.catch(reject);
|
||||
|
@ -72,8 +72,6 @@ module.exports = class FeedData extends Camo.EmbeddedDocument {
|
|||
const latest = normaliseUrl(articles[0].link);
|
||||
|
||||
if (!this.cachedLinks.includes(latest)) {
|
||||
this.cachedLinks.push(latest);
|
||||
|
||||
const channel = guild.channels.get(this.channelID),
|
||||
role = guild.roles.get(this.roleID);
|
||||
|
||||
|
|
Loading…
Reference in New Issue