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

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

This method will return either the `Tournament` object or undefined. A `Tournament` can be described by the following TypeScript Interface:
```ts
interface Tournament {
    /**
     * @generated from protobuf field: string guid = 1;
     */
    guid: string;
    /**
     * @generated from protobuf field: proto.models.Tournament.TournamentSettings settings = 2;
     */
    settings?: Tournament_TournamentSettings;
    /**
     * @generated from protobuf field: repeated proto.models.User users = 3;
     */
    users: User[];
    /**
     * @generated from protobuf field: repeated proto.models.Match matches = 4;
     */
    matches: Match[];
    /**
     * @generated from protobuf field: repeated proto.models.QualifierEvent qualifiers = 5;
     */
    qualifiers: QualifierEvent[];
    /**
     * @generated from protobuf field: proto.models.CoreServer server = 6;
     */
    server?: CoreServer;
}
```

- For the definition of a Tournament_TournamentSettings please look at the [Modals -> Tournament_TournamentSettings page](/documentation#Modals/4-Tournament_TournamentSettings)
- For the definition of a User please look at the [Modals -> User page](/documentation#Modals/4-User)
- For the definition of a Match please look at the [Modals -> Match page](/documentation#Modals/4-Match)
- For the definition of a QualifierEvent please look at the [Modals -> QualifierEvent page](/documentation#Modals/4-QualifierEvent)
- For the definition of a CoreServer please look at the [Modals -> CoreServer page](/documentation#Modals/4-CoreServer)

A direct implementation:
```ts
// Get the tournament data, and check if the current user is within the users that are currently in the touranament
if(!client.stateManager.getTournament(tournamentGuid)!.users.some(user => user.guid == client.stateManager.getSelfGuid())) {
    // If the user is not in the tournament, join it
    const joinResult = await client.joinTournament(tournamentGuid);
    // Check if the join was successful
    if (joinResult.details.oneofKind !== 'join' || joinResult.type === Response_ResponseType.Fail) {
        // Throw an error if not
        throw new Error('Could not join tournament');
    }
}
```
<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 qualifiers page. 
    </div>
</div>