mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 07:38:00 -05:00
custom chat code parsing thingy
This commit is contained in:
parent
666cc2491f
commit
894f4a16ca
1 changed files with 9 additions and 1 deletions
|
@ -6,6 +6,14 @@ function inject (bot, client, target) {
|
|||
!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',
|
||||
|
@ -22,7 +30,7 @@ function inject (bot, client, target) {
|
|||
text: client.username,
|
||||
color: 'green'
|
||||
},
|
||||
MessageBuilder.fromString('&7' + data.message)
|
||||
MessageBuilder.fromString('&7' + codeParsedMessage)
|
||||
]
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue