#i'm a little confused, methods
6 messages · Page 1 of 1 (latest)
All the methods/functions in this library are async so you have to use async/await to get the response. For example to access the current chat you have to do something like this:
client.on('message', async message => {
const chat = await message.getChat();
chat.sendMessage("aa");
});
thank you. you gave me the answer for the nirvana. ok really thank you
i have another question, for methods like groupChat that extend Chat, how do i implement them? like chat,groupChat().name
haha no problem 🙂
If you are trying to know if a chat is a group chat there is a boolean variable in the chat that we got in the prev code. You can do something like this:
client.on('message', async message => {
const chat = await message.getChat();
if(chat.isGroup) {
// In this case the const chat it will be an intance of GroupChat. So if you what to know what is the name of the group
// You can access directly to the name. For example:
const groupName = chat.name;
chat.sendMessage('hey! Thank you for let me in in ' + groupName);
}
});