This repository has been archived on 2026-06-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

31 lines
654 B
JavaScript

const fs = require('fs/promises')
function inject (bot) {
function tellraw (text, target = '@a') {
bot.core.run(`minecraft:tellraw ${target} ${JSON.stringify(text)}`)
}
async function listFiles (filepath, styling = {}) {
const list = await fs.readdir(filepath)
const msg = []
list.forEach((filename, idx) => {
if (idx !== 0) msg.push(' ')
const highlighting = !(idx & 1) ? bot.styles.secondary : bot.styles.primary
msg.push({
text: filename,
...highlighting,
...styling
})
})
return msg
}
bot.tellraw = tellraw
bot.listFiles = listFiles
}
module.exports = inject