# $onlyBotChannelPerms

The guard function `$onlyBotChannelPerms` checks if the **bot** has the specified permissions **in a given channel**. Unlike `$onlyBotPerms` which checks server-wide permissions, this function respects channel permission overwrites.

## Syntax

```
$onlyBotChannelPerms[channelID;permission1;permission2;...;errorMessage]
```

At least 3 arguments are required: the channel, at least one permission, and the error message (which may be empty).

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `channelID` | String | Required. ID of the channel to check. If empty, the current channel is used. An invalid ID raises `Invalid Discord ID.` |
| `permission1;permission2;...` | String[] | Required, at least one. Channel permissions that the bot must have in this channel. Separator `;`. An empty or unknown permission raises an error. |
| `errorMessage` | String | Required (the last argument, may be empty). The message output if the bot lacks any of the permissions. |

## Behavior

- Checks the effective permissions of the bot in the **channel given by `channelID`**.
- Takes channel overwrites into account (specific channel permissions modifying role inheritance); for a thread, the overwrites of its parent channel are used. The channel must be a server channel.
- The bot must be able to see the channel (`View Channel`) for any listed permission to count; permissions that depend on sending (`MentionEveryone`, `SendTTSMessages`, `AttachFiles`, `EmbedLinks`) also require `SendMessages` (`SendMessagesInThreads` in a thread), and in a voice or stage channel the voice-related permissions require `Connect`.
- The `Administrator` permission (and server ownership) passes every check.
- If any permission is missing, the command execution is halted and `errorMessage` is output.
- Works even if the bot has the permission server-wide, but the channel has a deny overwrite.

## Examples

### Checking embed creation capability

```bdfd
$onlyBotChannelPerms[$channelID;SendMessages;EmbedLinks;❌ I cannot post embeds in this channel.]
$title[Announcement]
$description[This is an important announcement.]
$color[#5865F2]
```

### Checking voice permissions

```bdfd
$onlyBotChannelPerms[123456789012345678;Connect;Speak;❌ I do not have access to this voice channel.]
$joinVoice[123456789012345678]
$sendMessage[Connecting to the voice channel...]
```

### File uploads

```bdfd
$onlyBotChannelPerms[$channelID;AttachFiles;❌ I cannot send files here.]
$addFile[https://example.com/report.pdf]
Here is the report.
```

## Notes

- `$onlyBotChannelPerms` checks **channel** permissions, while `$onlyBotPerms` checks **server** permissions.
- Permission names are case-insensitive and ignore non-alphanumeric characters, for example `SendMessages`, `EmbedLinks`, `AttachFiles`, `AddReactions`, `UseExternalEmojis`, `Connect`, `Speak`, `Stream`, `UseVAD`, `PrioritySpeaker`, `MuteMembers`, `DeafenMembers`, `MoveMembers`, `ViewChannel`, `ReadMessageHistory`, `SendTTSMessages`, `UseApplicationCommands`, `ManageMessages`, `ManageChannels`, `CreateInstantInvite`. An unknown name (for example `UseEmbeddedActivities`) raises `Invalid permission.`
- Combine with `$onlyBotPerms` for a complete check (server + channel).
