function inject (bot) { const transactions = {} let transactionId = 0 function tabComplete (text) { return new Promise(resolve => { transactions[transactionId] = resolve bot._client.write('tab_complete', { transactionId, text }) transactionId = (transactionId + 1) % 256 }) } bot.on('packet.tab_complete', packet => { if (!transactions[packet.transactionId]) return transactions[packet.transactionId](packet) delete transactions[packet.transactionId] }) bot.tabComplete = tabComplete } module.exports = inject