Skip to content

Commit 5adf115

Browse files
committed
[REFACTOR] throws an error when a private chat is passed to getAdmsList
1 parent aed364a commit 5adf115

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/utils/chattools.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ async function getMembersList(chat) {
2929
* @returns {string[]} - Serialized phone numbers of all administrators.
3030
*/
3131
async function getAdmsList(chat) {
32+
if (!chat.isGroup) {
33+
throw new Error(`This chat isn't a group.`);
34+
}
35+
3236
const members = await chat.participants;
3337
const admsIdList = members.filter((id) => id.isAdmin);
3438
const admsSerialList = getSerialList(admsIdList);

0 commit comments

Comments
 (0)