> For the complete documentation index, see [llms.txt](https://wiki.incredibleplugins.com/discordbridge/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.incredibleplugins.com/discordbridge/setup/bot.md).

# Bot

## Usage

Runs the Discord bot and registers Discord slash commands.

The bot module is required for Discord-side features such as `/config`, `/online`, chat forwarding, tickets, events, and Lands Discord channels.

## Setup

You can click on the images to make them larger.

1. Create an application in your [Discord developer portal](https://discord.com/developers/applications).
2. Required privileged gateway intents: Server Members Intent, Message Content Intent\
   ![Intents](https://i.imgur.com/GhPA0So.png)
3. Required scopes: `applications.command, bot`\
   ![Scopes](https://i.imgur.com/N7UdnBY.png)
4. The bot needs the following bot permissions: Manage Channels, Manage Webhooks, Read Messages/View Channels, Send Messages, Manage Messages, Embed Links, Attach Files, Read Message History, Add Reactions\
   ![Permissions](https://i.imgur.com/RjCCYCK.png)\
   Alternatively you can use the following URL to add the bot with the required permissions. Replace `CLIENT_ID` with your bot's client ID: [Invite Link](https://discord.com/api/oauth2/authorize?client_id=CLIENT_ID\&permissions=2684480592\&scope=bot+applications.commands)
5. Copy the bot token and paste it at the `token` option in DiscordBridge/Modules/bot.yml.
6. Restart the server. Slash commands are registered after the bot logs in.

## Multiple Servers

In a Redis setup, only the master DiscordBridge instance should run the bot module. Set `database.redis.master: true` on the bot instance and keep the Bot module disabled on non-bot instances.

Without Redis, each server can run its own bot instance.

## Discord Commands

| Command   | What it does                                                      |
| --------- | ----------------------------------------------------------------- |
| `/config` | Configures DiscordBridge settings for the current Discord server. |
| `/online` | Shows online Minecraft players.                                   |

## Ingame Commands

`/discordbridge invite`\
Get the Discord server invite. Only available if `invite-url` is configured in the module config.\
*Permission: discordbridge.command.invite*

## PlaceholderAPI Placeholders

Requires [PlaceholderAPI](https://www.spigotmc.org/resources/placeholderapi.6245/) to be installed.

### Format

The format is always as follows: `%discordbridge_module_bot_server_<server>_<placeholder>`\
You need to replace `<server>` with the ID of the server. You can retrieve the server ID by enabling the developer mode in Discord. You can use `total` as the server ID to display information for all servers combined, such as the user count on all servers combined. The `<placeholder>` argument needs to be replaced with the specific placeholder.

`%discordbridge_module_bot_server_<server>_members_amount%`\
Returns the amount of members. Example usage:

* `%discordbridge_module_bot_server_total_members_amount%` -> Returns the combined amount of members on all servers.
* `%discordbridge_module_bot_server_1234567891012131415_members_amount%` -> Returns the amount of members on the server with the ID `1234567891012131415`.

`%discordbridge_module_bot_server_<server>_boosters_amount%`\
Returns the amount of guild boosters.

`%discordbridge_module_bot_server_<server>_boosters_contains_<userId>%`\
Returns whether user with the ID `<userId>` has boosted the server or any server if `<server>` equals `total`.

`%discordbridge_module_bot_server_<server>_boosters_contains_<userId>_bool%`\
Returns `true`, if the user with the ID `<userId>` has boosted the server or any server if `<server>` equals `total`. Otherwise, returns `false`.
