Skip to content

Meme-Bros/revcord

Β 
Β 

Repository files navigation

revcord

πŸŒ‰ A cord to connect your Revolt and Discord servers

πŸ”— A bridge for Discord and Revolt with easy setup through commands, written in TypeScript using revolt.js.

Features | Setup | Configuration | Troubleshooting

πŸ“” Features

  • Bridge messages between platforms
  • Bridge categories automatically
    • Creating categories
    • Moving channels to categories
  • Bridge channels automatically 1
    • Automatically create channel (Discord <-> Revolt)
    • Automatically update channel (Discord <-> Revolt) 2
    • Automatically disconnect channel on delete (Discord <-> Revolt)
  • Bridge roles automatically (acts as a label only, permissions aren't synced!)
    • Create role
    • Update role
    • Delete role
    • Assign role
    • Unassign role
  • Bridge attachments
    • Automatically reupload attachments to Revolt
  • Bridge replies
  • Bridge message edit and delete
  • Bridge embeds
    • Include attachments
  • Bridge emoji 3
    • Automatically import emoji
    • Mapping Discord emoji to Revolt variants
  • Seamlessly display user information
  • Initial import of channels & roles

Important

While this bot should in theory work for multiple servers at a time, it has only been tested with 1 server (Discord + Revolt). If there are any compatibility issues, please let us know.

Screenshot - Revolt Screenshot - Discord

πŸ”© Setup

  1. Create a bot in Discord (Guide)

  2. Important! Make sure to select the following permissions in URL Generator when making an invite for your bot (Your bot in Discord Developers -> OAuth2 -> URL Generator) (or if you're lazy, just select Administrator) Note applications.commands!

permissions

  1. Enable the Message Content Intent under Bot -> Privileged Gateway Intents. If you forget to do this, the bot will crash with a Used disallowed intents message.

intent

  1. Create a bot in Revolt (Open user settings -> My Bots -> Create a bot)
  2. Important! make sure to add the bot to a role that has the Masquerade permission!

revolt permissions

  1. Invite the bot to to a Revolt and Discord server.
  2. Install & Start the bot using docker or node.

πŸ”© Running the Bot

Using Docker

To help you get started creating a container from this image you can either use docker-compose or the docker cli.

docker-compose (recommended)
services:
  revcord:
    image: ghcr.io/meme-bros/revcord:latest
    volumes:
      - /path/to/revcord.sqlite:/app/revcord.sqlite:rw
    environment:
      - DISCORD_TOKEN="INSERT_DISCORD_TOKEN_HERE"
      - REVOLT_TOKEN="INSERT_DISCORD_TOKEN_HERE"
    restart: unless-stopped

then run with docker compose up -d

docker cli
docker run -d \
  --name revcord \
  -v "/path/to/revcord.sqlite:/app/revcord.sqlite:rw" \
  -e DISCORD_TOKEN="INSERT_DISCORD_TOKEN_HERE" \
  -e REVOLT_TOKEN="INSERT_DISCORD_TOKEN_HERE" \
  --restart unless-stopped \
  ghcr.io/meme-bros/revcord:latest

Environment Variables

Environment Variables Description Required
DISCORD_TOKEN Discord bot token βœ…
REVOLT_TOKEN Revolt bot token βœ…
API_URL Revolt API URL for custom self-hosted instances ❌
REVOLT_ATTACHMENT_URL Revolt attachment URL for custom self-hosted instances ❌

Using Node

Note

If you use docker you can skip to Configuration

Important

Node v16.9+ is required!

  1. Clone this repository, install dependencies and build
git clone https://github.com/Meme-Bros/revcord.git
cd revcord
npm install
npm run build
  1. Place the relevant tokens in environment variables. The easiest way is to copy .env.example file and fill in the following information
DISCORD_TOKEN = ...
REVOLT_TOKEN = ...

Of course, replace ... with tokens.

If you are running a self-hosted instance of Revolt, additionally set the API_URL and REVOLT_ATTACHMENT_URL variable to your own host:

API_URL = https://example.com/api
REVOLT_ATTACHMENT_URL = https://example.com/autumn
  1. Start the bot using npm start

Note

it's recommended to use something like pm2 or nodemon to run the bot. Make sure to pass the --experimental-specifier-resolution=node flag to node manually, otherwise it will not run (it's included in the default start script).

πŸ”§ Configuration

with commands

You can use either slash commands on Discord or rc! prefix on Revolt (use rc!help to show all commands)

To use the commands, you need the Administrator permission on Discord. On Revolt, only the server owner can run them (for now).

Connecting Discord and Revolt channels

From Discord:

/connect <Revolt channel name or ID>

From Revolt:

rc!connect <Discord channel name or ID>

For example:

# From Discord
/connect lounge
/connect 01AB23BC34CD56DE78ZX90WWDB

# From Revolt
rc!connect general
rc!connect 591234567890123456

βœ”οΈ Send a message to see if it works. Try editing and deleting it.

Removing the connection

From Discord:

/disconnect

From Revolt:

rc!disconnect

You don't have to specify any channel. It will disconnect the channel the command is sent in.

Showing connections

From Discord:

/connections

From Revolt:

rc!connections

Toggling bots

You can toggle whether messages sent by bots should be forwarded. It's enabled by default (it's requied for NQN to work properly).

Use either rc!bots or /bots

πŸ”₯ Troubleshooting

npm install takes way too long, or Please install sqlite3 package manually (Raspberry Pi / 32-bit arm devices)

This is an issue with node-sqlite3 being a native module, but has no prebuilt binaries for 32-bit arm architectures available, therefore falling back to building from source.

However, a Raspberry Pi is usually too low powered to finish compiling it.

So, the only solution would be to use a more powerful device to cross-compile it to arm. For convenience, a prebuilt binary for armv7l architecture was provided here

You have to place it in node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm/node_sqlite3.node.

Alternatively, if your device supports it (Raspberry Pi 3 does), you can install a 64-bit distribution.

Messages sent to Discord have no content!

As in setup step 5, you need to enable the Message Content Intent in Discord bot settings. If this doesn't work, make sure the bot has permissions to read the messages in a channel.

intent

Bot doesn't have sufficient permissions in the channel. Please check if the Manage Webhooks permission isn't being overridden for the bot role in that specific channel.

Aside from server-wide permissions, there are also channel-specific permissions. This message means that at some point, the bot's permission to manage webhooks is being overridden on the channel level. The easiest fix is to change the override to allow it. Alternatively, you can grant the bot the Administrator permission which overrides all channel-specific permissions.

In channel settings -> Permissions:

override

Footnotes

  1. For this to function, you need to connect at least 1 channel manually. This is to create the initial link between the Discord Guild and Revolt Server. After this it will automatically create, update and disconnect channels at their corresponding events. ↩

  2. There is a cool-down timer on this to prevent bridged update loops, so very quick edits back-to-back might not be bridged. If your change was done too quickly and not synced, wait for a little while and then try to update it again, it should then sync everything properly. ↩

  3. Revolt to Discord works, but limited to 3 emojis displayed to stop bombing with links. Animated emojis from Revolt will convert to static due to limits on Revolt's image backend ↩

About

A bridge for Discord and Revolt with easy setup through commands

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • TypeScript 98.8%
  • Other 1.2%