http({ url }, (error, response) => { if (!error && response.statusCode === 200) { if (response.headers['x-gg-state'] === 'cached') { config.dmuse.date.remain++ noon.save(CFILE, config) if (config.usage) console.log('Cached response, not decrementing usage.') } const resp = JSON.parse(response.body) spinner.stop() spinner.clear() for (let i = 0; i <= resp.length - 1; i++) { const item = resp[i] themes.label(theme, 'right', 'Match', `${item.word} `) tofile[[`match${i}`]] = item.word if (item.tags !== undefined && item.tags !== []) { themes.label(theme, 'right', 'Tag') for (let j = 0; j <= item.tags.length - 1; j++) { if (j === item.tags.length - 1) { process.stdout.write(ctstyle(`${tags[item.tags[j]]}`)) tofile[[`tags${j}`]] = tags[item.tags[j]] } else process.stdout.write(ctstyle(`${tags[item.tags[j]]}, `)) } console.log('') } } if (argv.o) tools.outFile(argv.o, argv.f, tofile) if (config.usage) reset ? console.log(`Timestamp expired, reset usage limits.\n${config.dmuse.date.remain}/${config.dmuse.date.limit} requests remaining today.`) : console.log(`${config.dmuse.date.remain}/${config.dmuse.date.limit} requests remaining today, will reset in ${23 - hours} hours, ${59 - minutes} minutes.`) } else throw new Error(`HTTP ${error.statusCode}: ${error.reponse.body}`) })