Skip to content

Commit

Permalink
fix: fix chat handler on newer versions
Browse files Browse the repository at this point in the history
zardoy committed Jun 13, 2024
1 parent 0048c12 commit 348cd00
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/modules/chat.ts
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ export const server = function (serv: Server) {
}

export const player = function (player: Player, serv: Server) {
player._client.on('chat', ({ message } = {}) => {
const chatHandler = ({ message }: { message: string }) => {
if (message[0] === '/') {
player.behavior('command', { command: message.slice(1) }, ({ command }) => player.handleCommand(command))
serv.info(`${player.username} issued command: ${message.split(' ')[0]}`)
@@ -149,6 +149,12 @@ export const player = function (player: Player, serv: Server) {
})
})
}
}
player._client.on('chat', chatHandler)
player._client.on('chat_message', chatHandler)
player._client.on('chat_command', ({ command }: { command: string }) => {
// serv.info(`${player.username} issued command: ${command}`)
chatHandler({ message: `/${command}` })
})

player.chat = message => {

0 comments on commit 348cd00

Please sign in to comment.