mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-02 22:17:39 +00:00
These changes are made in case source is not guranteed to remain the same Due to how JS should operate, this shouldn't be an issue but this just ensures that
33 lines
930 B
TypeScript
33 lines
930 B
TypeScript
import { pool } from './db';
|
|
import { ESX } from './server';
|
|
|
|
interface IPhoneNumber {
|
|
phone_number: string;
|
|
}
|
|
|
|
interface Identifier {
|
|
identifier: string;
|
|
}
|
|
|
|
export async function usePhoneNumber(identifier: string): Promise<string> {
|
|
const query = 'SELECT phone_number FROM users WHERE identifier = ?';
|
|
const [results] = await pool.query(query, [identifier]);
|
|
const phoneNumber = <IPhoneNumber[]>results;
|
|
return phoneNumber[0].phone_number;
|
|
}
|
|
|
|
export const getSource = () => (global as any).source;
|
|
|
|
export function getIdentifier(source: number): string {
|
|
return ESX.GetPlayerFromId(source).getIdentifier();
|
|
}
|
|
|
|
export async function getIdentifierByPhoneNumber(
|
|
phoneNumber: string
|
|
): Promise<string> {
|
|
const query = 'SELECT identifier FROM users WHERE phone_number = ?';
|
|
const [results] = await pool.query(query, [phoneNumber]);
|
|
const identifier = <Identifier[]>results;
|
|
return identifier[0].identifier;
|
|
}
|