#How to block a number?
11 messages · Page 1 of 1 (latest)
You need to create an record like which number sent how many message in a day and block it on the basis of it or adding it in an ignore list.
Blocking works like this:
//get contact
const contact = await msg.getContact();
//block contact
await contact.block();
I was trying like this const contact = await Client.getContactById(id)
await contact.block(); , but nothing happened
Something like if(msg.body === '!blocknumber '){ let number = msg.body.slice(16); const contact = await client.getContactById(number); await contact.block(); }
can you share how are you adding number?
i mean the full command you used
like this !blocknumber [email protected]
you need to make some changes, i made a code that may help you
if(msg.body.startsWith('!blocknumber')) {
//change msg.body to array
var arr = msg.body.split(" ");
//get the number
var number = arr[1];
const contact = await client.getContactById(number);
await contact.block();
}
this will work for you. Make sure you send number correctly.
let me know if you face any issue in this code