mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
feat(resources): set number as keytype for Players map
This commit is contained in:
1 parent
a424a67f05
commit
de53b12763
2 files changed
+3
-9
No files matched your search
@@ -2,10 +2,6 @@ import { IPlayer } from '../typings/players';
|
||||
import { pool } from './db';
|
||||
import { Players } from './sv_main';
|
||||
|
||||
interface IPhoneNumber {
|
||||
phone_number: string;
|
||||
}
|
||||
|
||||
interface Identifier {
|
||||
identifier: string;
|
||||
}
|
||||
@@ -49,7 +45,7 @@ export async function getIdentifierByPhoneNumber(phoneNumber: string): Promise<s
|
||||
return identifier[0].identifier;
|
||||
}
|
||||
|
||||
export const getPlayerBySource = (source: any) => {
|
||||
export const getPlayerBySource = (source: number) => {
|
||||
return Players.get(source);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ interface Credentials {
|
||||
phone_number: string;
|
||||
}
|
||||
|
||||
export const Players = new Map<string, IPlayer>();
|
||||
export const Players = new Map<number, IPlayer>();
|
||||
|
||||
// gets the identifers
|
||||
on('playerJoining', async () => {
|
||||
@@ -29,8 +29,6 @@ on('playerJoining', async () => {
|
||||
const identifers = getPlayerIdentifiers(pSource);
|
||||
identifier = identifers[1].split(':')[1];
|
||||
|
||||
console.log('PHONE IS READY: ', identifier);
|
||||
|
||||
if (!identifier) {
|
||||
throw new Error('Identifier could not be found.');
|
||||
}
|
||||
@@ -60,7 +58,7 @@ function getRandomPhoneNumber() {
|
||||
} else {
|
||||
randomNumber = Math.floor(Math.random() * 10000000)
|
||||
.toString()
|
||||
.replace(/(\d{3})(\d{4})/, '$1-$2'); // ;
|
||||
.replace(/(\d{3})(\d{4})/, '$1-$2');
|
||||
// The numbers inside {} in replace() can be changed to how many digits you want on each side of the dash.
|
||||
// Example: 123-4567
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user