diff --git a/src/index.ts b/src/index.ts index b0dd681..829e27d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,7 +36,8 @@ const interval = 60 * 10; const processing = new Set(); const writing = { id: [0, 0] }; const idJSON = new json('id'); -let ids: Record, speakers: Record; +let ids: Record; +const speakers: Record = {}; const intervalIDs: Record = {}; const twitter = new TwitterWrap({ diff --git a/src/json.ts b/src/json.ts index 6ca5a21..8cf177b 100644 --- a/src/json.ts +++ b/src/json.ts @@ -7,9 +7,9 @@ export default class json { } public async read(): Promise> { const dict: Record = await fs - .access(this.filename + '.json') + .access('data/' + this.filename + '.json') .then(async () => - fs.readFile(this.filename + '.json', { encoding: 'utf-8' }) + fs.readFile('data/' + this.filename + '.json', { encoding: 'utf-8' }) ) .catch(() => '{}') .then((data) => JSON.parse(data) as Record); @@ -28,7 +28,7 @@ export default class json { writingThisFile[1] = 1; while (writingThisFile[0] && writingThisFile[0] > 0) { await fs - .writeFile(this.filename + '.json', JSON.stringify(dict)) + .writeFile('data/' + this.filename + '.json', JSON.stringify(dict)) .then(() => { writingThisFile[0] -= 1; });