@@ -68,7 +68,7 @@ type LogOptions = boolean | { extended?: boolean; logger?: UserLogger };
6868
6969let listData = fallbackData as listDataType ;
7070let legacyIds = legacyIdsFallbackData as legacyIdDataType ;
71- const listAge = new Date ( ) ;
71+ const lastUpdatedListAt = new Date ( 1999 ) ; // some date that's definitely past
7272let extendedLogging = false ;
7373let useBotblockAPI = true ;
7474
@@ -111,7 +111,7 @@ function buildBotblockData(
111111 shards ?: Array < number > ,
112112) {
113113 return {
114- ...apiKeys ,
114+ ...convertLegacyIds ( apiKeys ) ,
115115 bot_id,
116116 server_count,
117117 shard_id,
@@ -134,10 +134,10 @@ async function postToAllLists(
134134) : Promise < Array < Response | { error : any } > > {
135135 // make sure we have all lists we can post to and their apis
136136 const currentDate = new Date ( ) ;
137- if ( ! listData || listAge < currentDate ) {
137+ if ( ! listData || lastUpdatedListAt < currentDate ) {
138138 // we try to update the listdata every day
139139 // in case new lists are added but the code is not restarted
140- listAge . setDate ( currentDate . getDate ( ) + 1 ) ;
140+ lastUpdatedListAt . setDate ( currentDate . getDate ( ) + 1 ) ;
141141 try {
142142 const tmpListData = await get < listDataType > (
143143 'https://botblock.org/api/lists?filter=true' ,
@@ -178,8 +178,10 @@ async function postToAllLists(
178178
179179 const posts : Array < Promise < Response | { error : any } > > = [ ] ;
180180
181+ const updatedApiKeys = convertLegacyIds ( apiKeys ) ;
182+
181183 Object . entries ( listData ) . forEach ( ( [ listname ] ) => {
182- if ( apiKeys [ listname ] && listData [ listname ] . api_post ) {
184+ if ( updatedApiKeys [ listname ] && listData [ listname ] . api_post ) {
183185 const list = listData [ listname ] ;
184186 if ( ! list . api_post || ! list . api_field ) {
185187 return ;
@@ -198,7 +200,7 @@ async function postToAllLists(
198200 }
199201
200202 posts . push (
201- post ( apiPath , apiKeys [ listname ] , sendObj , extendedLogging , log ) ,
203+ post ( apiPath , updatedApiKeys [ listname ] , sendObj , extendedLogging , log ) ,
202204 ) ;
203205 }
204206 } ) ;
@@ -340,7 +342,7 @@ export function handle(
340342) : Promise < void > {
341343 return handleInternal (
342344 discordClient ,
343- convertLegacyIds ( apiKeys ) ,
345+ apiKeys ,
344346 ! repeatInterval || repeatInterval < 1 ? 30 : repeatInterval ,
345347 ) ;
346348}
0 commit comments