mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
WIP
This commit is contained in:
1 parent
949ea4ba4b
commit
e01fa0ab0a
16 files changed
+406
-231
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import PlayerService from '../players/player.service';
|
||||
import { clean } from './miscUtils';
|
||||
/**
|
||||
* Generate a profile name by the player's name and/or phone number
|
||||
* @param identifier - player's identifier
|
||||
* @param delimiter - What we split the profile name by, defaults to -
|
||||
*/
|
||||
export async function generateProfileName(
|
||||
identifier: string,
|
||||
delimiter: string = '_',
|
||||
): Promise<string | null> {
|
||||
const player = PlayerService.getPlayerFromIdentifier(identifier);
|
||||
|
||||
const firstname = clean(player.getFirstName());
|
||||
const lastname = clean(player.getLastName());
|
||||
const phone_number = clean(player.getPhoneNumber());
|
||||
|
||||
if (firstname && lastname) {
|
||||
return `${firstname}${delimiter}${lastname}`;
|
||||
} else if (firstname) {
|
||||
return firstname;
|
||||
} else if (lastname) {
|
||||
return lastname;
|
||||
} else if (phone_number) {
|
||||
return phone_number;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in new issue
Block a user