mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-12-01 14:45:43 -05:00
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
class command_spy {
|
|
constructor (context) {
|
|
const bot = context.bot
|
|
|
|
bot.on('system_chat', (message) => {
|
|
try {
|
|
const child = message.extra
|
|
const sender = bot.players.find((e) => e?.profile?.name === message.text)?.profile?.name === message.text
|
|
if (!child || !message.text || !message.color || !sender) return
|
|
const command = child[1].text.substring('/'.length)
|
|
|
|
if (
|
|
(
|
|
message.color === 'yellow'
|
|
&&
|
|
child[0].text === ': '
|
|
&&
|
|
child[1].text === `/${command}`
|
|
&&
|
|
sender
|
|
)
|
|
||
|
|
(
|
|
message.color === 'aqua'
|
|
&&
|
|
child[0].text === ': '
|
|
&&
|
|
child[1].text === `/${command}`
|
|
&&
|
|
sender
|
|
)
|
|
) bot.emit('parsed_message', {
|
|
sender: bot.players.find((e) => e.profile.name === message.text),
|
|
contents: { text: command },
|
|
type: "minecraft:chat",
|
|
chatType: "command_spy",
|
|
displayName: bot.players.find((e) => e.profile.name === message.text).displayName
|
|
})
|
|
} catch (e) {
|
|
console.log(e.stack)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = command_spy; |