An open API service indexing awesome lists of open source software.

https://github.com/tenequm/discord-relay

Relay Discord messages between channels on different servers automatically
https://github.com/tenequm/discord-relay

automation deno discord discord-bot docker relay typescript

Last synced: 2 months ago
JSON representation

Relay Discord messages between channels on different servers automatically

Awesome Lists containing this project

README

          

# discord-relay

Automatically copies messages from source Discord channels to target channels.

## Disclaimer

This tool is provided for educational and personal use only. By using this
software:

- You are responsible for complying with Discord's Terms of Service
- You must have permission to access and read from source channels
- You must use your own tokens and credentials
- The authors are not liable for any misuse or violations

Use at your own risk and responsibility.

## Prerequisites

- Docker and Docker Compose
- Discord bot token
- Discord user tokens
- Channel IDs

## Important: Understanding Tokens

This tool uses two different types of Discord tokens:

### Bot Token (`bot_token` in config)
- This is for the Discord bot that **POSTS** messages to your target channels
- You must create a bot application and invite it to your server
- The bot needs "Send Messages" and "Embed Links" permissions
- Messages appear as sent by your bot, not your personal account
- [Create a bot here](https://discord.com/developers/applications)

### User Tokens (`tokens` array in config)
- These are for **READING** messages from source channels
- Can be your personal Discord account or alt accounts
- Must have access to the source channels you want to monitor
- Used only by DiscordChatExporter to export messages

**Why both?** User tokens read from source channels, bot token posts to target channels. This separation ensures proper Discord compliance - the bot posts messages on its own behalf, not impersonating users.

## Setup

1. Clone repository:

```bash
git clone https://github.com/tenequm/discord-relay.git
cd discord-relay
```

2. Configure:

```bash
cp config.example.yml config.yml
# Edit config.yml with your tokens and channel IDs
```

[Get tokens and IDs guide](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)

3. Run:

```bash
docker compose up --build -d
```

## Commands

```bash
docker compose ps # Check status
docker compose logs -f # View logs
docker compose down # Stop
docker compose restart # Restart
```

## Running Without Docker

If you prefer to run the bot directly with Deno, use tmux for session management:

```bash
# Install Deno if not already installed
curl -fsSL https://deno.land/install.sh | sh

# Start bot in a tmux session with auto-restart
tmux new -s discord-bot -d 'while true; do deno run --allow-all export.ts; sleep 2; done'

# Attach to view output
tmux attach -t discord-bot

# Detach from session: Ctrl+B then D
# List sessions: tmux ls
# Kill session: tmux kill-session -t discord-bot
```

This keeps the bot running in the background and automatically restarts if it crashes.

## Credits

This project wouldn't be possible without [DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter) by Tyrrrz, which handles the message extraction from Discord channels. Huge thanks to the DiscordChatExporter project for making Discord data exports accessible and reliable.

## Development

### Releasing New Versions

To release a new version:

1. Update version in `deno.jsonc`
2. Commit your changes
3. Create release with auto-generated notes:

```bash
gh release create v1.1.0 --generate-notes
```

Or with custom notes:

```bash
gh release create v1.1.0 --notes "Description of changes"
```

The release command automatically creates the git tag and publishes to GitHub.