# Disconnect

`com.jsmacrosce.jsmacros.client.api.event.impl.world.EventDisconnect`

**Since:** 1.2.7

**Cancellable:** No. Calling `event.cancel()` throws `UnsupportedOperationException`.

Fires when the client disconnects, including when leaving without a disconnection screen. The
disconnection-screen reason is available as [message](#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventDisconnect_message) when present.  
```js
JsMacros.on("Disconnect", JavaWrapper.methodToJava(function (event) {
  Chat.log(`Left the world${event.message === null ? "" : ": " + event.message.getString()}`);  
}))
```

## Constructors

### new EventDisconnect {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventDisconnect_constructor-Component-}

```js
new EventDisconnect(Component message)
```

Wraps the disconnect reason when present and initializes the event with the client core.  
This does not itself perform a disconnect, kick, world leave, GUI change, or event dispatch.

**Parameters:**
- `message`: raw reason component to wrap; `null` produces a `null` message field

## Fields

### message {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventDisconnect_message}

```js
message: TextHelper
```

The disconnection-screen reason, or `null` when disconnecting without a disconnection
screen.

**Since:** 1.6.4

## Methods

### toString {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventDisconnect_toString-}

```js
toString(): String
```

Returns this event's name followed by the fixed empty-brace payload marker; it does not
include or inspect the disconnect reason, so it remains safe when `message` is null.

**Returns:** the event name followed by `:{}`; this diagnostic string is not the full reason
or serialized component JSON
