Miao-Yunzai/plugins/genshin/index.js

25 lines
540 B
JavaScript
Raw Normal View History

2023-03-04 14:30:13 +08:00
import fs from 'node:fs'
const files = fs.readdirSync('./plugins/genshin/apps').filter(file => file.endsWith('.js'))
let ret = []
files.forEach((file) => {
ret.push(import(`./apps/${file}`))
})
ret = await Promise.allSettled(ret)
let apps = {}
for (let i in files) {
let name = files[i].replace('.js', '')
if (ret[i].status != 'fulfilled') {
logger.error(`载入插件错误:${logger.red(name)}`)
logger.error(ret[i].reason)
continue
}
apps[name] = ret[i].value[Object.keys(ret[i].value)[0]]
}
export { apps }