forked from https://github.com/matrix-org/matrix-appservice-discord in order to fix NPM package deprecated usage of unauthenticated git:// port 9418
Find a file
2022-06-24 20:27:23 -05:00
.github Update contributing guide (#794) 2022-06-17 08:40:13 -04:00
changelog.d Update contributing guide (#794) 2022-06-17 08:40:13 -04:00
config Make invalid token message configurable 2021-11-12 16:08:02 +01:00
docs Merge branch 'no-discordapp' of https://github.com/auscompgeek/matrix-appservice-discord into develop 2021-01-02 13:35:04 +01:00
scripts Add towncrier (#787) 2022-06-09 11:38:20 -04:00
src start working on cleaning up logging 2022-06-24 20:27:23 -05:00
test Fix some test failures 2022-06-06 13:55:50 -04:00
tools Update typescript-eslint to fix parse errors, chase camelcase deprecation 2021-11-22 18:14:38 +01:00
.dockerignore Remove tools from dockerignore 2018-07-28 12:19:01 -05:00
.eslintrc Update typescript-eslint to fix parse errors, chase camelcase deprecation 2021-11-22 18:14:38 +01:00
.gitignore add why-is-node-running 2018-11-07 14:55:43 +01:00
.mocharc.yml Update mocha to use config file 2020-06-18 11:23:15 +01:00
.nycrc Add .nycrc 2019-05-16 16:59:24 +01:00
CONTRIBUTING.md Update contributing guide (#794) 2022-06-17 08:40:13 -04:00
Dockerfile Use yarn in Dockerfile for predictable builds 2021-10-15 12:11:11 +02:00
LICENSE Initial commit 2016-06-19 00:09:33 +01:00
package-lock.json blah that appeared to be un-needed 2022-06-24 15:31:40 -05:00
package.json blah that appeared to be un-needed 2022-06-24 15:31:40 -05:00
pyproject.toml Add towncrier (#787) 2022-06-09 11:38:20 -04:00
README.md more setup instructions 2022-06-24 20:27:13 -05:00
screenshot.png Update screenshot 2018-11-06 15:26:28 +00:00
tsconfig.json Implement RMAU tracking and optionally blocking the bridge after a RMAU limit is reached 2021-10-12 14:43:32 +02:00
yarn.lock blah that appeared to be un-needed 2022-06-24 15:31:40 -05:00

Matrix Discord Bridge

A bridge between Matrix and Discord. Currently the bridge is in Beta and quite usable for everyday bridging, with one or two bugs cropping up.

Screenshot of Element and Discord working together

Helping out

Build Status Docker Automated build #discord:half-shot.uk

PRs

PRs are graciously accepted, so please come talk to us in #discord-bridge:matrix.org about any neat ideas you might have. If you are going to make a change, please merge it with the develop branch :).

Issues

You can also file bug reports/ feature requests on Github Issues which also helps a ton. Please remember to include logs. Please also be aware that this is an unoffical project worked on in our spare time.

Setting up

The bridge has been tested against the Synapse homeserver, although any homeserver that implements the AS API should work with this bridge.

The bridge supports any version of Node.js >= v12.X, including all current releases.

NOTE: npm install appears to be broken right now for node versions less than v16.x

Set up the bridge

  • Run npm install to grab the dependencies. npm may complain about peer dependencies, but you can safely ignore these.

  • Run npm run build to build the typescript into javascript.

  • Copy config/config.sample.yaml to config.yaml and edit it to reflect your setup.

    • Note that you are expected to set domain and homeserverURL to your public host name. While localhost would work, it does not resolve correctly with Webhooks/Avatars. Please note that a self-signed SSL certificate won't work, either.
    bridge:
        domain: "example.com"
        homeserverUrl: "https://example.com"
    
  • Run node build/src/discordas.js -r -u "http://localhost:9005" -c config.yaml

  • Modify your HSs appservices config so that it includes the generated file.

    • e.g. On synapse, adding to app_service_config_files array in homeserver.yaml
    app_service_config_files:
      - "discord-registration.yaml"
    
    • Copy discord-registration.yaml to your Synapse's directory.

Docker

Following the instructions above, generate a registration file. The file may also be hand-crafted if you're familiar with the layout. You'll need this file to use the Docker image.

# Create the volume where we'll keep the bridge's files
mkdir -p /matrix-appservice-discord

# Create the configuration file. Use the sample configuration file as a template.
# Be sure to set the database paths to something like this:
#  database:
#    filename: "/data/discord.db"
#    userStorePath: "/data/user-store.db"
#    roomStorePath: "/data/room-store.db"
nano /matrix-appservice-discord/config.yaml

# Copy the registration file to the volume
cp discord-registration.yaml /matrix-appservice-discord/discord-registration.yaml

# Optional: Build the container yourself (requires a git clone, and to be in the root of the project)
docker build -t halfshot/matrix-appservice-discord .

# Run the container
docker run -v /matrix-appservice-discord:/data -p 9005:9005 halfshot/matrix-appservice-discord

Metrics

The bridge supports reporting metrics via Prometheus. You can configure metrics support in the config file. The metrics will be reported under the URL provided in the registration file, on the /metrics endpoint.

3PID Protocol Support

This bridge support searching for rooms within networks via the 3pid system used in clients like Element. Any new servers/guilds you bridge should show up in the network list on Element and other clients.

Setting up Discord

  • Create a new application via https://discordapp.com/developers/applications
  • Make sure to create a bot user. Fill in config.yaml
    • Copy the application id from the "OAuth2" section of the Discord Bot Developer Panel and paste it into config.yaml as the "clientID" under "auth"
    • Click "Reset Token" in the "Bot" section of the Discord Bot Developer Panel and paste the resulting bot token into config.yaml as the "botToken" under "auth"
  • Run npm run addbot to get a authorisation link.
  • Give this link to owners of the guilds you plan to bridge.
  • Finally, you can join a room with #_discord_guildid_channelid
    • These can be taken from the url ("/$GUILDID/$CHANNELID") when you are in a channel.
    • Element (and other clients with third party protocol support) users can directly join channels from the room directory.
  • You can use Webhooks to make messages relayed by the bridge not nested by the bot user. This will also display the avatar of the user speaking on matrix with their messages.
    • The bot should create this automatically, but if not perform the following:
      • Enable Manage Webhooks on the role added by the bot.
      • Add the _matrix Webhook for each channel you'd like to enable this feature on.

Running the Bridge

  • For the bot to appear online on Discord you need to run the bridge itself.
  • npm start
  • Particular configuration keys can be overridden by defining corresponding environment variables. For instance, auth.botToken can be set with APPSERVICE_DISCORD_AUTH_BOT_TOKEN.

Howto

End User Documentation

Bridging a Room

You must get an authorization link from bridge owner. You must be a server admin or get help from server admin on Discord side.

  • Invite the Matrix side bot to your room and wait for it to join.
  • On Discord side use the authorization link to invite bot to Discord server.
  • Find out a serverid and channelid for your server/channel you want to bridge. Search the web for instructions.
  • In Matrix room give command !discord bridge ServerID ChannelID
  • The bridge will ask for confirmation from the Discord server admins to complete the bridge. Once approved, you're all set.

Unbridging a Room

  • In Matrix room give command !discord unbridge

Features and Roadmap

In a vague order of what is coming up next

  • Matrix -> Discord
    • Text content
    • Image content
    • Audio/Video content
    • Typing notifs (Not supported, requires syncing)
    • User Profiles
  • Discord -> Matrix
    • Text content
    • Image content
    • Audio/Video content
    • Typing notifs
    • User Profiles
    • Presence
    • Per-guild display names.
  • Group messages
  • Third Party Lookup
    • Rooms
    • Users
  • Puppet a user's real Discord account.
    • Sending messages
    • Direct messages
    • UI for setup
  • Rooms react to Discord updates
  • Integrate Discord into existing rooms
    • Feature
    • UI
  • Manage channel from Matrix (possibly)
    • Authorise admin rights from Discord to Matrix users
    • Topic
    • Room Name
  • Provisioning API
  • Webhooks (allows for prettier messages to discord)
  • VOIP (Hard | Unlikely to be finished anytime soon)

Contact

My Matrix ID: @Half-Shot:half-shot.uk