add welcome message

This commit is contained in:
1e99 2025-07-22 19:07:10 +02:00
parent c67cd50ff1
commit e94b9d1d34

View file

@ -80,7 +80,10 @@ class Bot {
this.#chat = new Chat(this.#client)
this.#chat.addPattern("chat", new RegExp(`^<([a-zA-Z0-9_]+)> (.+)$`))
this.#chat.addPattern("whisper", new RegExp(`^\\[([a-zA-Z0-9_]+) -> me\\] (.+)$`))
this.#chat.addPattern("player-join", new RegExp(`^([a-zA-Z0-9_]+) joined the game$`))
this.#chat.addPattern("player-leave", new RegExp(`^([a-zA-Z0-9_]+) left the game$`))
this.#chat.addListener("chat", this.#onChat.bind(this))
this.#chat.addListener("chat:player-join", this.#onChatPlayerJoin.bind(this))
this.#death = new Death(this.#client)
this.#death.addListener("death", this.#onDeath.bind(this))
@ -110,6 +113,14 @@ class Bot {
console.log(`Chat: ${message}`)
}
#onChatPlayerJoin(username) {
if (username === this.#client.username) {
return
}
this.#chat.chat(`/w ${username} Hello ${username}! I'm a bot that adds chat based commands. Please use ${this.#prefix}help to get a list of all commands.`)
}
#onDeath() {
console.log("Client died")
this.#death.respawn()