1
0
Fork 0
mirror of https://github.com/muerwre/vk-tg-bot.git synced 2025-04-25 06:56:40 +07:00

made safe getUserById for handlers

This commit is contained in:
Fedor Katurov 2021-05-31 11:08:04 +07:00
parent b28c34878b
commit 740cf4f5e7
3 changed files with 18 additions and 12 deletions

View file

@ -36,12 +36,16 @@ export class VkEventHandler<
* @param id
*/
protected getUserByID = async (id: string) => {
const users = await this.instance.api.users.get({
user_ids: [id],
fields: ["sex"],
});
try {
const users = await this.instance.api.users.get({
user_ids: [id],
fields: ["sex"],
});
return users[0];
return users[0];
} catch (e) {
return undefined;
}
};
/**