---
name: "Net::Async::Matrix::Room::State"
section: "3pm"
platform: "linux"
package: "libnet-async-matrix-perl"
version: "0.19-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Net::Async::Matrix::Room::State"
---

# Net::Async::Matrix::Room::State(3pm)

represents the state events in a matrix room

## NAME

"Net::Async::Matrix::Room::State" - represents the state events in a matrix room

## DESCRIPTION

Instances of this class represent all of the known state events in a Net::Async::Matrix::Room at some instant in time. These objects are mutable so a "live" state object obtained from a room will change to keep track of newly received state events.

## METHODS

### get\_event

```
   $event = $state->get_event( $type, $state_key )
```

Returns a HASH reference containing the raw event stored for the given type name and optional state key.

### get\_events

```
   $events = $state->get_events( $type )
```

Returns a multi-level HASH reference mapping all of the known state keys for a given event type name to their raw stored events. Typically this is useful for `"m.room.member"` events as the state keys will be user IDs.

## CONVENIENCE ACCESSORS

The following accessors all fetch single values out of certain events, as they are commonly used.

### name

```
   $name = $state->name
```

Returns the `"name"` field of the `"m.room.name"` event, if it exists.

### join\_rule

```
   $join_rule = $state->join_rule
```

Returns the `"join_rule"` field of the `"m.room.join_rules"` event, if it exists.

### topic

```
   $topic = $state->topic
```

Returns the `"topic"` field of the `"m.room.topic"` event, if it exists.

### aliases

```
   @aliases = $state->aliases
```

Returns a list of the room alias from all the `"m.room.aliases"` events, in no particular order.

### members

```
   @members = $state->members
```

Returns a list of Member instances representing all of the members of the room from the `"m.room.member"` events whose membership state is not `"leave"`.

### all\_members

```
   @members = $state->members
```

Similar to "members" but even includes members in `"leave"` state. This is not normally what you want.

### member

```
   $member = $state->member( $user_id )
```

Returns a Member instance representing a room member of the given user ID, or `"undef"` if none exists.

### member\_level

```
   $level = $state->member_level( $user_id )
```

Returns a number indicating the power level that the given user ID would have according to room state, taken from the `"m.room.power_levels"` event. This takes into account the `"users_default"` field, if no specific level exists for the given user ID.

## AUTHOR

Paul Evans \<leonerd@leonerd.org.uk\>
