# Discord Bridge

The Discord bridge is no longer available for purchase. This documentation is for existing customers of the bridge only.

## Setup

First, you need to register a Discord application for your bridge. Discord applications can be registered and managed in the <a href="https://discord.com/developers/applications/" target="_blank" rel="noopener noreferrer">Discord Developer Portal</a>.

1. Click on the `New Application` button in the upper right corner.
1. Give it a name (visible when authorizing the bridge), read Discord's Terms and click `Create`.
1. Note the Client ID. It's required for the bridge.
1. Navigate to the `Bot` tab. The navigation can be found on the left.
1. Click `Add Bot`. You may also need to click `Yes, do it!` to confirm your action.
1. Note the Bot Token. It's required for the bridge.

### Authorize your account

Before authorizing your Discord App, you first need to grant your account the following rights:
1. Manage Webhooks
1. Manage Server

[![Screenshot 2022-10-17 at 07.45.19.png](https://ems-docs.element.io/uploads/images/gallery/2022-10/scaled-1680-/screenshot-2022-10-17-at-07-45-19.png)](https://ems-docs.element.io/uploads/images/gallery/2022-10/screenshot-2022-10-17-at-07-45-19.png)

### Connect Discord server(s)

You need to authorize your Discord App to each Discord server you wish to bridge. Give the following URL to a Discord server admin, if you aren't the Discord server admin.

The authorization URL is `https://discordapp.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=607250432`. Replace `YOUR_CLIENT_ID` with your Client ID mentioned above.

## Usage

### Bridge a room

1. In a web browser, navigate to the Discord room you wish to bridge. The URL includes the server ID (also called guild ID) and the channel ID. The URL format is `https://discord.com/channels/GUILD_ID/CHANNEL_ID`.  
    [![](https://ems-docs.element.io/uploads/images/gallery/2023-12/scaled-1680-/image-1702384749669.png)](https://ems-docs.element.io/uploads/images/gallery/2023-12/image-1702384749669.png)
1. In a Matrix room you want to bridge, invite `@discord:example.ems.host` (replace the domain with the one of your homeserver).  
1. Post the message `!discord bridge GUILD_ID CHANNEL_ID` after replacing the two placeholders.  
    [![](https://ems-docs.element.io/uploads/images/gallery/2023-12/scaled-1680-/image-1702384759883.png)](https://ems-docs.element.io/uploads/images/gallery/2023-12/image-1702384759883.png)
1. A privileged Discord user will need to approve the bridge request by responding with `!matrix approve`  
    [![](https://ems-docs.element.io/uploads/images/gallery/2023-12/scaled-1680-/image-1702384768109.png)](https://ems-docs.element.io/uploads/images/gallery/2023-12/image-1702384768109.png)
1. Messages from Discord are now bridged to Matrix and vice versa.  
    [![](https://ems-docs.element.io/uploads/images/gallery/2023-12/scaled-1680-/image-1702384777081.png)](https://ems-docs.element.io/uploads/images/gallery/2023-12/image-1702384777081.png)

### Unbridge

To unbridge a room post `!discord unbridge` in the Matrix room.

### Private Chats

Currently, private chats are not supported by the EMS Discord bridge.