File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,30 @@ export default {
2828 const seq = interaction . options . get ( "sequence" ) ?. value ;
2929 if ( ! seq ) return await interaction . editReply ( { content : await __ ( "errors.invalid_argument" ) ( interaction . guildId ) } ) ;
3030
31- const f = await fetch ( `https://oeis.org/search?q=${ seq } &fmt=json` ) ;
31+ const url = `https://oeis.org/search?q=${ seq } &fmt=json` ;
32+ console . log ( `[OEIS] Fetching: ${ url } ` ) ;
3233
33- console . log ( f ) ;
34+ const f = await fetch ( url , {
35+ headers : {
36+ "User-Agent" : "Arithmetica-Bot/1.0 (Discord Bot; +https://github.com/NullDev/Arithmetica-Bot)" ,
37+ Accept : "application/json" ,
38+ } ,
39+ } ) ;
40+
41+ console . log ( `[OEIS] Response status: ${ f . status } ` ) ;
42+ console . log ( "[OEIS] Response headers:" , Object . fromEntries ( f . headers . entries ( ) ) ) ;
43+
44+ const responseText = await f . text ( ) ;
45+ console . log ( "[OEIS] Response body (first 500 chars):" , responseText . substring ( 0 , 500 ) ) ;
3446
35- const results = await f . json ( ) ;
47+ let results ;
48+ try {
49+ results = JSON . parse ( responseText ) ;
50+ }
51+ catch {
52+ console . error ( "[OEIS] Failed to parse JSON. Full response body:" , responseText ) ;
53+ throw new Error ( `OEIS API returned non-JSON response. Status: ${ f . status } . Check logs for full HTML response.` ) ;
54+ }
3655
3756 if ( ! results || ! results . length ) return await interaction . editReply ( { content : "¯\\_(ツ)_/¯" } ) ;
3857
You can’t perform that action at this time.
0 commit comments