import { saveBotToStorage } from './data/bots/storageService' import fs from 'fs' import { Bot } from '../../schema' require('dotenv').config() fs.readdir('bots', (err, files) => { const botFilenames = files.filter(file => file.endsWith('.json')).filter(file => !!file) botFilenames.map(async botFilename => { const tree: Bot = JSON.parse(fs.readFileSync('bots/' + botFilename).toString()) try { await saveBotToStorage(tree) console.log('successfully migrated ' + botFilename) } catch (err) { console.error('failed to migrate ' + botFilename) console.error(err) } }) })