# The stateManager.getUser() method
This documents the `stateManager.getUser()` method.

This method has input parameters. The function could easily be defined as:
```ts
function getUser(tournamentGuid: string, userGuid: string): User | undefined {
    // backend logic
}
```
## General usage:
```ts
const user: User | undefined = taClient.stateManager.getUser(tournamentGuid, userGuid);
```

This method will return either the `User` object or undefined. A `User` can be described by the following TypeScript Interface:
```ts
interface User {
    /**
     * @generated from protobuf field: string guid = 1;
     */
    guid: string;
    /**
     * @generated from protobuf field: string name = 2;
     */
    name: string;
    /**
     * @generated from protobuf field: string platform_id = 3;
     */
    platformId: string;
    /**
     * @generated from protobuf field: proto.models.User.ClientTypes client_type = 4;
     */
    clientType: User_ClientTypes;
    /**
     * @generated from protobuf field: string team_id = 5;
     */
    teamId: string;
    /**
     * @generated from protobuf field: proto.models.User.PlayStates play_state = 6;
     */
    playState: User_PlayStates;
    /**
     * @generated from protobuf field: proto.models.User.DownloadStates download_state = 7;
     */
    downloadState: User_DownloadStates;
    /**
     * @generated from protobuf field: repeated string mod_list = 8;
     */
    modList: string[];
    /**
     * @generated from protobuf field: proto.models.User.Point stream_screen_coordinates = 9;
     */
    streamScreenCoordinates?: User_Point;
    /**
     * @generated from protobuf field: int64 stream_delay_ms = 10;
     */
    streamDelayMs: bigint;
    /**
     * @generated from protobuf field: int64 stream_sync_start_ms = 11;
     */
    streamSyncStartMs: bigint;
    /**
     * @generated from protobuf field: proto.models.User.DiscordInfo discord_info = 12;
     */
    discordInfo?: User_DiscordInfo;
    /**
     * @generated from protobuf field: bytes user_image = 13;
     */
    userImage: Uint8Array;
    /**
     * @generated from protobuf field: proto.models.Permissions permissions = 14;
     */
    permissions: Permissions;
}
```

- For the definition of a User_ClientTypes please look at the [Enums -> User_ClientTypes page](/documentation#Enums/5-User_ClientTypes)
- For the definition of a User_PlayStates please look at the [Enums -> User_PlayStates page](/documentation#Enums/5-User_PlayStates)
- For the definition of a User_DownloadStates please look at the [Enums -> User_DownloadStates page](/documentation#Enums/5-User_DownloadStates)
- For the definition of a User_Point please look at the [Modals -> User_Point page](/documentation#Modals/4-User_Point)
- For the definition of a User_DiscordInfo please look at the [Modals -> User_DiscordInfo page](/documentation#Modals/4-User_DiscordInfo)
- For the definition of a Permissions please look at the [Enums -> Permissions page](/documentation#Enums/5-Permissions)

A direct implementation:
```ts
async function refreshMatchDetails(match: Match) {
    // Get match players
    // Fetch each of the players in the match my using map on the associated users array which contains the connected user's guid
    matchPlayers = match.associatedUsers
        .map(userGuid => client.stateManager.getUser(tournamentGuid, userGuid))
        // Make sure that the client is a player(0) and not a websocket or REST connection (1 or 2)
        .filter(user => user && user.clientType === 0) as User[];

    // Remaining logic in the function
    // Get current song if available
    currentSong = match.selectedMap?.gameplayParameters || null;
    if(currentSong) {
        try {
            // Fetch the map beatsaver data
            const tempMapData = await fetchMapByLevelId(currentSong.beatmap.levelId);

            if(tempMapData) {
                currentSongData = tempMapData;
            }
        } catch (error) {
            console.log('Current song beatsaver data fetch failed');
        }
    }
}
```
<div class="info-box">
    <span class="material-icons">info</span>
    <div>
        <strong>Example:</strong> This is an example from the page of ShyyTAUI within the match cordination page. 
    </div>
</div>