Chat Events

Events

chat

Fired when a new chat is sent.

Examples

Prevent any chat message with capital letters

1
this.api.getEventManager()
2
.on("chat", async (event: ChatEvent) => {
3
const message = event.getChat().getMessage();
4
const sender = event.getChat().getSender();
5
6
if (!/[A-Z]/.test(message)) return;
7
8
await sender.sendMessage("Messages can not have capital letters!");
9
event.preventDefault();
10
});
Copied!
Last modified 8mo ago