chipmunkbot3/commands/rainbowify.js

25 lines
640 B
JavaScript
Raw Normal View History

2024-02-11 21:23:41 -05:00
const name = 'rainbowify'
const description = 'Makes text rainbow'
const usages = ['<message...>']
const aliases = ['rainbowify']
const enabled = true
const permLevel = 0
const colorsys = require('colorsys')
function execute (bot, cmd, player, args, handler) {
const message = args.join(' ')
const result = []
let hue = 0
message.split('').forEach((char) => {
result.push({ text: char, color: colorsys.hsv2Hex(hue, 100, 100) })
hue += 355 / Math.max(message.length, 20)
})
bot.core.run(`/tellraw @a ${JSON.stringify(result)}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }