1+ import { bold , hyperlink } from '@discordjs/builders' ;
12import type { Response } from 'polka' ;
2- import { prepareResponse } from '../util/respond.js' ;
3- import { noCodeLines , resolveResourceFromGuideUrl } from '../util/djsguide.js' ;
3+ import { EMOJI_ID_GUIDE } from '../util/constants.js' ;
44import { findRelevantDocsSection } from '../util/discordDocs.js' ;
5+ import { noCodeLines , resolveResourceFromGuideUrl } from '../util/djsguide.js' ;
6+ import { prepareResponse } from '../util/respond.js' ;
57import { truncate } from '../util/truncate.js' ;
6- import { bold , hyperlink } from '@discordjs/builders' ;
7- import { EMOJI_ID_GUIDE } from '../util/constants.js' ;
88
99type GuideCacheEntry = {
1010 page : string ;
@@ -16,14 +16,11 @@ const cache = new Map<string, GuideCacheEntry>();
1616async function getPage ( url : string ) {
1717 const cacheEntry = cache . get ( url ) ;
1818
19- if ( cacheEntry ) {
20- if ( cacheEntry . timestamp < Date . now ( ) - 1_000 * 60 * 60 ) {
21- console . log ( `Cache hit: ${ url } ` ) ;
22- return cacheEntry . page ;
23- }
19+ if ( cacheEntry && cacheEntry . timestamp < Date . now ( ) - 1_000 * 60 * 60 ) {
20+ return cacheEntry . page ;
2421 }
2522
26- const page = await fetch ( url ) . then ( ( res ) => res . text ( ) ) ;
23+ const page = await fetch ( url ) . then ( async ( res ) => res . text ( ) ) ;
2724 cache . set ( url , { page, timestamp : Date . now ( ) } ) ;
2825
2926 return page ;
0 commit comments