mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 18:54:55 -05:00
40 lines
1,004 B
JavaScript
40 lines
1,004 B
JavaScript
|
|
function inject (bot, client, target) {
|
|
const { MessageBuilder } = require('prismarine-chat')(bot.version)
|
|
client.on('packet', (data, meta) => {
|
|
if (meta.name === 'chat' &&
|
|
!data.message?.startsWith('/') &&
|
|
!data.message?.startsWith('.')
|
|
) {
|
|
const codeParsedMessage = data.message.replace(/%[^%]+%/g, (code) => {
|
|
try {
|
|
// eslint-disable-next-line no-eval
|
|
return eval(code.substring(1).slice(0, -1))
|
|
} catch (e) {
|
|
return code
|
|
}
|
|
})
|
|
bot.tellraw('@a', {
|
|
color: 'dark_gray',
|
|
translate: '[%s] [%s] %s \u203a %s',
|
|
with: [
|
|
{
|
|
text: 'Chat',
|
|
color: 'gray'
|
|
},
|
|
{
|
|
text: 'Proxy',
|
|
color: 'gray'
|
|
},
|
|
{
|
|
text: client.username,
|
|
color: 'green'
|
|
},
|
|
MessageBuilder.fromString('&7' + codeParsedMessage)
|
|
]
|
|
})
|
|
}
|
|
})
|
|
};
|
|
|
|
module.exports = { inject }
|