Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NewMessage

Occurs whenever a new text message or a message with media arrives.

example
async function eventPrint(event: NewMessageEvent) {
const message = event.message;

// Checks if it's a private message (from user or bot)
if (event.isPrivate){
// prints sender id
console.log(message.senderId);
// read message
if (message.text == "hello"){
const sender = await message.getSender();
console.log("sender is",sender);
await client.sendMessage(sender,{
message:`hi your id is ${message.senderId}`
});
}
}
}
// adds an event handler for new messages
client.addEventHandler(eventPrint, new NewMessage({}));

Hierarchy

Index

Properties

func?: ((event: NewMessageEvent) => boolean)

Type declaration

incoming?: boolean
outgoing?: boolean
fromUsers?: EntityLike[]
forwards?: boolean
pattern?: RegExp
chats?: string[]
blacklistChats: boolean
resolved: boolean

Constructors

Methods

  • addAttributes(update: any): void

Generated using TypeDoc