#i'm a little confused, methods

6 messages · Page 1 of 1 (latest)

full helm
#

1: if i write js client.on('message', message => { console.log(groupChat.createdAt); });
it doesn't return anything.

2: i can't get js Chat.sendMessage("aa")
to work

celest scroll
#

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");
});
full helm
full helm
celest scroll
#

haha no problem 🙂

celest scroll
# full helm i have another question, for methods like groupChat that extend Chat, how do i i...

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);
    }
});