const { literal, argument, greedyString } = require('brigadier-commands') const colorsys = require('colorsys') module.exports = { register (dispatcher) { const node = dispatcher.register( literal('rainbowify') .then( argument('message', greedyString()) .executes(this.rainbowifyCommand) ) ) node.description = 'Makes text rainbow' node.permissionLevel = 0 }, rainbowifyCommand (context) { const source = context.source const message = context.getArgument('message') 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) }) source.sendFeedback(result, false) } }