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:
parent
b28c34878b
commit
740cf4f5e7
3 changed files with 18 additions and 12 deletions
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue