UNPKG

node-mirai-fgo-gacha

Version:

node-mirai-sdk fgo gacha plugin

22 lines (18 loc) 601 B
const fs = require('fs'); const path = require('path'); let icons = null; const getGachaIcon = (conf = { type: 'svt', id: 1, }) => { if (!icons) icons = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), '.fgo-gacha/statics/icons.json'))); const { type, id } = conf; let img = ''; if (type === 'svt') img = icons.svtIcons[id - 1]; else img = icons.cftIcons[id - 1]; if (!img) { console.error('Icon path not found', conf); } return path.resolve(process.cwd(), '.fgo-gacha/statics/icons', img.replace('/images', '').replace(/\//g, '_')); }; module.exports = getGachaIcon;