mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 12:21:00 -05:00
Fix parsed XML data not being stored properly in cache
This commit is contained in:
parent
3c8c0f3d76
commit
504277ed44
@ -19,19 +19,16 @@ export default async(client:TClient, YTChannelID:string, YTChannelName:string, D
|
|||||||
const cacheKey = `YTCache:${YTChannelID}`;
|
const cacheKey = `YTCache:${YTChannelID}`;
|
||||||
const cachedVideoId = await CacheServer.get(cacheKey);
|
const cachedVideoId = await CacheServer.get(cacheKey);
|
||||||
if (!cachedVideoId) {
|
if (!cachedVideoId) {
|
||||||
const videoId = Data.feed.entry[0]['yt:videoId']._text;
|
await CacheServer.set(cacheKey, Data.feed.entry[0]['yt:videoId']).then(async()=>await CacheServer.expiry(cacheKey, cacheExpiry));
|
||||||
await CacheServer.set(cacheKey, videoId).then(async()=>await CacheServer.expiry(cacheKey, cacheExpiry));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (Data.feed.entry[1]['yt:videoId'] === cachedVideoId) {
|
||||||
if (Data.feed.entry[1]['yt:videoId']._text === cachedVideoId) {
|
|
||||||
const videoId = Data.feed.entry[0]['yt:videoId']._text;
|
|
||||||
await CacheServer.delete(cacheKey).then(async()=>{
|
await CacheServer.delete(cacheKey).then(async()=>{
|
||||||
await CacheServer.set(cacheKey, videoId).then(async()=>await CacheServer.expiry(cacheKey, cacheExpiry))
|
await CacheServer.set(cacheKey, Data.feed.entry[0]['yt:videoId']).then(async()=>await CacheServer.expiry(cacheKey, cacheExpiry))
|
||||||
});
|
});
|
||||||
|
|
||||||
(client.channels.resolve(DiscordChannelID) as TextChannel).send({
|
(client.channels.resolve(DiscordChannelID) as TextChannel).send({
|
||||||
content: `${MessageTool.formatMention(DiscordRoleID, 'role')}\n**${YTChannelName}** just uploaded a video!\n${Data.feed.entry[0].link._attributes.href}`,
|
content: `${MessageTool.formatMention(DiscordRoleID, 'role')}\n**${YTChannelName}** just uploaded a video!\n${Data.feed.entry[0].link.href}`,
|
||||||
allowedMentions: {parse:['roles']},
|
allowedMentions: {parse:['roles']},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user