0 Star 0 Fork 25

gulugulu/Yenai-Plugin

forked from 椰羊/Yenai-Plugin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.js 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
椰羊 提交于 2024-04-06 19:02 . 🐛 修复私聊群管
import Ver from "./components/Version.js"
import chalk from "chalk"
import Data from "./components/Data.js"
import fs from "fs"
logger.info(chalk.rgb(253, 235, 255)("----ヾ( ̄▽ ̄)Bye~Bye~----"))
logger.info(chalk.rgb(134, 142, 204)(`椰奶插件${Ver.ver}初始化~`))
logger.info(chalk.rgb(253, 235, 255)("-------------------------"))
global.ReplyError = class ReplyError extends Error {
constructor(message) {
super(message)
this.name = "ReplyError"
}
}
// 加载监听事件
const eventsPath = "./plugins/yenai-plugin/apps/events"
const events = fs.readdirSync(eventsPath)
.filter(file => file.endsWith(".js"))
for (const File of events) {
try {
logger.debug(`[Yenai-Plugin] 加载监听事件:${File}`)
await import(`./apps/events/${File}`)
} catch (e) {
logger.error(`[Yenai-Plugin] 监听事件错误:${File}`)
logger.error(e)
}
}
const appsPath = "./plugins/yenai-plugin/apps"
const jsFiles = Data.readDirRecursive(appsPath, "js", "events")
let ret = jsFiles.map(file => {
return import(`./apps/${file}`)
})
ret = await Promise.allSettled(ret)
let apps = {}
for (let i in jsFiles) {
let name = jsFiles[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 }
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/gulugulu111/yenai-plugin.git
[email protected]:gulugulu111/yenai-plugin.git
gulugulu111
yenai-plugin
Yenai-Plugin
master

搜索帮助