const defaults = { amnesicCommandBlocks: false, commandNamespaces: false, commandSpy: false } function inject (bot, options) { if (options.features) { bot.features = { ...defaults, ...options.features } return } bot.features = { ...defaults } bot.on('packet.declare_commands', packet => { const rootNode = packet.nodes[0] if (!rootNode) return for (const nodeIdx of rootNode.children) { const node = packet.nodes[nodeIdx] if (!node) continue const name = node.extraNodeData.name if (name) { const seperatorIdx = name.indexOf(':') if (seperatorIdx !== -1) { bot.features.commandNamespaces = true const namespace = name.substring(0, seperatorIdx) switch (namespace) { case 'extras': bot.features.amnesicCommandBlocks = true break case 'commandspy': bot.features.commandSpy = true break } } } } }) } module.exports = inject