# $createInvite

Creates an invite to a channel and returns its code. This function is a Bot Creator extension: it does not exist in the official BibiScript wiki. It runs the same Discord logic as the matching block.

## Syntax

```
$createInvite[channelID;maxAgeSeconds;maxUses;temporary;(reason)]
```

## Parameters

| Parameter | Description |
|---|---|
| `channelID` | Channel ID (digits only). Optional: empty means the current channel. |
| `maxAgeSeconds` | Lifetime in seconds. Empty means 86400 (one day), `0` never expires. |
| `maxUses` | Number of uses. Empty or `0` means unlimited. |
| `temporary` | `true` to kick members who were not given a role when they leave. |
| `reason` | Optional. Reason recorded in the server's audit log (up to 512 characters). Empty, or absent, uses the reason set with `$auditLogReason`, if any. |

## Return Value

- **Type**: String
- The invite code. The link is `https://discord.gg/<code>`.

## Behavior

- All arguments are optional.
- The bot needs Create Invite in the guild.

## Examples

```bdfd
$sendMessage[https://discord.gg/$createInvite[$channelID;3600;1]]
```

## Audit log reason

The last, optional argument `reason` is the reason shown next to this action in the server's audit log (Discord's `X-Audit-Log-Reason`). Without it, the reason set earlier in the script with `$auditLogReason` is used; with neither, no reason is recorded.
