alexagame / utils /getName.js
hansaka01's picture
Upload 39 files
3655d67 verified
Raw
History Blame Contribute Delete
440 Bytes
/**
* Get display name for a user ID.
* Tries TG client first, falls back to DB username, then generic.
*/
async function getName(client, userId) {
try {
if (client) {
const ent = await client.getEntity(userId);
return ent.firstName || ent.username || `User${userId.toString().slice(-4)}`;
}
} catch (e) {}
return `User${userId.toString().slice(-4)}`;
}
module.exports = { getName };