From 7735d940b31e26d712085f40586f0c73e808c031 Mon Sep 17 00:00:00 2001 From: Toast <96593068+AnxietyisReal@users.noreply.github.com> Date: Sun, 8 Oct 2023 09:50:13 +1100 Subject: [PATCH] Fix parsed XML data not being stored properly in cache --- src/funcs/YTModule.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/funcs/YTModule.ts b/src/funcs/YTModule.ts index b7dbb1a..111ce92 100644 --- a/src/funcs/YTModule.ts +++ b/src/funcs/YTModule.ts @@ -19,19 +19,16 @@ export default async(client:TClient, YTChannelID:string, YTChannelName:string, D const cacheKey = `YTCache:${YTChannelID}`; const cachedVideoId = await CacheServer.get(cacheKey); if (!cachedVideoId) { - const videoId = Data.feed.entry[0]['yt:videoId']._text; - 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)); return; } - - if (Data.feed.entry[1]['yt:videoId']._text === cachedVideoId) { - const videoId = Data.feed.entry[0]['yt:videoId']._text; + if (Data.feed.entry[1]['yt:videoId'] === cachedVideoId) { 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({ - 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']}, }); }