# Discord Sync: sync a Discourse forum with a Discord server

**URL:** https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864
**Category:** Plugin
**Tags:** unmaintained
**Created:** [January 12, 2021, 11:47am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864 "2021-01-12T11:47:26Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![barreeeiroo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/barreeeiroo/32/165264_2.png) [@barreeeiroo](https://meta.discourse.org/u/barreeeiroo)
#### Post date: [January 12, 2021, 11:47am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/1 "2021-01-12T11:47:26Z")

</div>

> ⚠ This plugin is automatic; it does not have any command. If you are looking for a generic discord bot framework please check @merefield’s [bot construction kit here](https://meta.discourse.org/t/discord-bot-run-one-on-your-discourse-server-keep-things-in-sync/122530) on which this plugin was based.

# Discord Sync Sync a Discourse forum with a Discord server :discourse:

This plugin allows syncing certain user-related stuff between a Discourse forum instance and a Discord server. It will create a Discord Bot to handle all permissions and trigger with some actions in the server.

[https://github.com/barreeeiroo/discourse-discord-sync](https://github.com/barreeeiroo/discourse-discord-sync)

## Features

- **Sync Discourse groups to Discord roles**  
It will automatically manage roles in the Discord server based in the groups that a user has access in Discourse.

- **Sync Discourse username to Discord nickname**  
If you want to recognize users by their forum username, you can force them to have the same Discord server nickname as the username they have in Discourse

### Triggers

The plugin will run a complete Discourse-to-Discord sync (nickname and roles) in the following cases:

- **Discourse**
  - User is added to a group
  - User is removed from a group
  - User profile is updated  
_Intended for username-nickname syncing_
  - User is authenticated  
_It will only run if the auth provider is Discord, to make sure a first sync is executed just right after linking accounts_

- **Discord**
  - User joins a Discord server  
_It will search in the database for an user with the given Discord ID, and then run the sync job_

## Installation

❗ This plugin depends on Discord OAuth2 to identify and link Discourse-Discord accounts. If you don’t want to allow users to login with Discord, but you wish to keep linking account, check [the solution to this topic](https://meta.discourse.org/t/partially-enable-login-option/175330/4).

### Prerrequisites

This plugin requires `libsodium` (required by the Discord Ruby gem). To install it, modify your `.yml` file and add the following code:

```plaintext
hooks:
    before_code:
       - exec:
              cmd:
                - apt-get update
                - apt-get install -y libsodium-dev

```

### Installation steps

1. Follow the standard guide at [How to install a plugin](https://meta.discourse.org/t/install-a-plugin/19157) with this repository URL: `https://github.com/barreeeiroo/discourse-discord-sync.git`
2. Follow [this guide](https://meta.discourse.org/t/configuring-discord-login-for-discourse/127129) to set up Login with Discord in your Discourse instance.
3. In the Discord Developer portal, go to Bot, and add it to your server. Make sure you grant him the highest possible role.
4. In Discourse, in Plugin Settings, set `discord sync token` with the Bot token that appears in the previous step.

## Configuration options

- **`discord sync enabled`** : Whether or not to enable the integration
- **`discord sync token`** : Bot token from Discord
- **`discord sync prefix`** : Prefix for commands (just `!ping` by now)
- **`discord sync admin channel id`** : Channel to post logging messages (nick changes, role changes)
- **`discord sync username`** : If true, it will sync all Discord server nicknames to their Discourse username
- **`discord sync verified role`** : Role to add to all users who have a Discourse account
- **`discord sync safe roles`** : List of roles that bot will ignore and will mark as manually granted in Discord

## How To

To link accounts, if you allow users to authenticate with Discord, they can just use that provider. If not, they will have to their **Account Preferences** , scroll down to _ **Associated Accounts** _ and hit _Connect_ in the Discord row.

### Live Demo

We are currently using this plugin in our Discourse instance at Kodular Community, with the Discord server at [kodul.ar/discord](https://kodul.ar/discord):

> **[Kodular Community](https://community.kodular.io)**
>
> A place for Koders to share and discuss their thoughts

## Acknowledgment

- [**Discourse Bot**](https://meta.discourse.org/t/discord-bot-run-one-on-your-discourse-server-keep-things-in-sync/122530), made by @merefield  
Thanks a lot to Robert for providing the skeleton of this plugin. It has certainly helped to set up the base of this entire plugin, allowing to run a Discord bot in a Discourse instance (and kudos for his trick on getting `libsodium` installed!).

- [**Discourse Discord Sync**](https://github.com/angusmcleod/discourse-discord-sync), made by @angus  
An alternative to sync trust levels into Discord roles without the need of any bot.

- [**Login with Discord**](https://meta.discourse.org/t/deprecated-discord-oauth2-plugin/67174), made by Discourse team  
This plugin wouldn’t be possible without the Discord OAuth2 integration (formerly a plugin), to link both Discourse and Discord accounts.

- [**discordrb**](https://github.com/discordrb/discordrb)  
This plugin relies on the `discordrb` gem, which allows connecting to the Discord API using Ruby.

---

<div class="post-metadata">

### Author: ![Bill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bill/32/159342_2.png) [@Bill](https://meta.discourse.org/u/Bill)
#### Post date: [January 13, 2021, 1:00am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/4 "2021-01-13T01:00:25Z")

</div>

This is really cool! I’m more of a Telegram fan myself, but Discord is great too! I feel like Telegram would pair well with Discourse, both being well known open-source projects focused on communication.

That would be cool if this had a cross-posting feature. If someone said something in the Discord chat, it would create a reply in a specific Discord thread known as the “chat room thread”. Thus giving your Discourse website an SEO boost because of all the new content within the chat thread.

---

<div class="post-metadata">

### Author: ![barreeeiroo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/barreeeiroo/32/165264_2.png) [@barreeeiroo](https://meta.discourse.org/u/barreeeiroo)
#### Post date: [January 13, 2021, 10:01am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/5 "2021-01-13T10:01:05Z")

</div>

I also like Telegram a lot, and we were using it with a public chat group. But a few days ago we switched to Discord, because we had over 1k members and it’s quite hard to moderate such a large group. It was easy to do it with Discord with their role system.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [January 15, 2021, 3:50am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/6 "2021-01-15T03:50:48Z")

</div>

Nice work 🙂

In addition to @merefield’s [Discord Bot](https://meta.discourse.org/t/discord-bot-run-one-on-your-discourse-server-keep-things-in-sync/122530/74), there’s also a pure OAuth2 (bot free) Discord role \<\> Discourse group sync plugin (e.g. sync trust level 3 with a Discord role) here

[https://github.com/angusmcleod/discourse-discord-sync](https://github.com/angusmcleod/discourse-discord-sync)

---

<div class="post-metadata">

### Author: ![JackALaing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jackalaing/32/189207_2.png) [@JackALaing](https://meta.discourse.org/u/JackALaing)
#### Post date: [January 17, 2021, 12:02pm UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/7 "2021-01-17T12:02:41Z")

</div>

This syncs Discourse → Discord. However, we rely more on our Discord roles than Discourse groups for identification of stakeholder types, so it would be great if this plugin could also do a Discord → Discourse sync, i.e. add Discourse users to groups based on their Discord roles, add badges to Discourse users based on their Discord roles, change the Discourse username to match the Discord username (not the other way around), etc.

---

<div class="post-metadata">

### Author: ![DiscoveryOV](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discoveryov/32/207098_2.png) [@DiscoveryOV](https://meta.discourse.org/u/DiscoveryOV)
#### Post date: [January 24, 2021, 9:32am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/10 "2021-01-24T09:32:50Z")

</div>

Would it be possible for you to make this so that it syncs in reverse? i.e. sync roles from Discord into Discourse groups, nicknames, etc.

We manage roles and such from Discord and would rather push them to Discourse.

---

<div class="post-metadata">

### Author: ![DiscoveryOV](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discoveryov/32/207098_2.png) [@DiscoveryOV](https://meta.discourse.org/u/DiscoveryOV)
#### Post date: [January 25, 2021, 1:13am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/11 "2021-01-25T01:13:02Z")

</div>

If you find anything like this please let me know.

---

<div class="post-metadata">

### Author: ![cookieman768](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cookieman768/32/118511_2.png) [@cookieman768](https://meta.discourse.org/u/cookieman768)
#### Post date: [February 10, 2021, 6:29am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/12 "2021-02-10T06:29:52Z")

</div>

This looks really cool. The only thing is, how does it match the group on Discord from Discourse? Is it purely by name? If so, could you make it to where we define what group goes to what role by using the role ID from Discord? If not that solution, do you think you could add a role whitelist? I have only a few roles that have groups on Discourse but utilize many roles on Discord.

---

<div class="post-metadata">

### Author: ![KungRaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kungraseri/32/199354_2.png) [@KungRaseri](https://meta.discourse.org/u/KungRaseri)
#### Post date: [February 24, 2021, 12:34am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/13 "2021-02-24T00:34:28Z")

</div>

This particular functionality is so important to us, since we manage all of our roles via Discord. It would be nice to have a way to sync up the groups from Discord to Discourse. Even if they’re only “synced” via name and permissions, etc. are configured after the fact.

@barreeeiroo : do you have any plans for something like this? or have any advice on where to go from here? The manual management of roles via “Safe Roles” is almost good enough. I have roles that have spaces in them and therefore cannot add these into the Safe Roles field. Instead of manually updating all of my roles in discord and adding them without spaces is there another route I can go with?

It would be _so nice_ to have the groups from discord “pushed” to the discourse groups instead, if possible.

Thanks for your work on this plugin!

Edit: The proposal to use Role IDs instead of names would solve a lot of issues on my end for sure.

---

<div class="post-metadata">

### Author: ![cookieman768](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cookieman768/32/118511_2.png) [@cookieman768](https://meta.discourse.org/u/cookieman768)
#### Post date: [March 31, 2021, 4:45am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/14 "2021-03-31T04:45:39Z")

</div>

I’m still having issues setting this up. For roles on Discord is it looking for an ID or name? Also, instead of a “protected roles” could you add it so I can synchronize only specific roles?

I don’t know ruby otherwise I’d offer up my assistance. I’ll probably learn the basics or just implement something via the API in Java.

---

<div class="post-metadata">

### Author: ![Wedgebert](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wedgebert/32/131690_2.png) [@Wedgebert](https://meta.discourse.org/u/Wedgebert)
#### Post date: [December 6, 2021, 2:49pm UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/16 "2021-12-06T14:49:38Z")

</div>

I found my issue, had the name of the admin channel instead of its id. Now I just gotta do some permission/role checking to see why nothing actually happens

---

<div class="post-metadata">

### Author: ![spirobel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spirobel/32/170908_2.png) [@spirobel](https://meta.discourse.org/u/spirobel)
#### Post date: [December 7, 2021, 8:21am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/17 "2021-12-07T08:21:06Z")

</div>

I just wanted to mention: I built the inverse of this plugin, which syncs discord roles to discourse groups: [https://www.youtube.com/watch?v=C5paAvTYty4](https://www.youtube.com/watch?v=C5paAvTYty4)

---

<div class="post-metadata">

### Author: ![Valdemar\_Birker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/valdemar_birker/32/244158_2.png) [@Valdemar\_Birker](https://meta.discourse.org/u/Valdemar_Birker)
#### Post date: [January 20, 2022, 8:05am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/19 "2022-01-20T08:05:09Z")

</div>

Is there any wat that you can sync the discord roles with discourse, instead of sync discourse roles with discord?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 20, 2022, 8:52am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/20 "2022-01-20T08:52:19Z")

</div>

That’s the point of this plugin? Is it broken? Also take a look at [my bot plugin](https://meta.discourse.org/t/discord-bot-run-one-on-your-discourse-server-keep-things-in-sync/122530) linked in the OP which performs discourse → discord (albeit using bot command)

---

<div class="post-metadata">

### Author: ![Valdemar\_Birker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/valdemar_birker/32/244158_2.png) [@Valdemar\_Birker](https://meta.discourse.org/u/Valdemar_Birker)
#### Post date: [January 20, 2022, 9:03am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/21 "2022-01-20T09:03:39Z")

</div>

All plugins here, gives you the roles you have on discourse to your discord account. It doesn’t gives you, your discord roles on your discourse account.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 20, 2022, 9:04am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/22 "2022-01-20T09:04:22Z")

</div>

That’s the opposite of your original question?

@spirobel ’s plugin does that I believe?

---

<div class="post-metadata">

### Author: ![Valdemar\_Birker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/valdemar_birker/32/244158_2.png) [@Valdemar\_Birker](https://meta.discourse.org/u/Valdemar_Birker)
#### Post date: [January 20, 2022, 10:51am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/23 "2022-01-20T10:51:08Z")

</div>

No, it does example if you have “Community Moderator” in Discourse, it will change your discord role.  
But if you have “Community Moderator” in Discord, it won’t change your role in Discourse

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 20, 2022, 11:06am UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/24 "2022-01-20T11:06:45Z")

</div>

I think you may have missed what I was referring to: [Discord Sync: sync a Discourse forum with a Discord server - #17 by spirobel](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/17)

Over to you @spirobel

---

<div class="post-metadata">

### Author: ![Valdemar\_Birker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/valdemar_birker/32/244158_2.png) [@Valdemar\_Birker](https://meta.discourse.org/u/Valdemar_Birker)
#### Post date: [January 20, 2022, 4:50pm UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/25 "2022-01-20T16:50:30Z")

</div>

I missed that, his plugin is a custom made plugin for 400 usd

---

<div class="post-metadata">

### Author: ![Nerd\_Alert](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nerd_alert/32/237766_2.png) [@Nerd\_Alert](https://meta.discourse.org/u/Nerd_Alert)
#### Post date: [January 20, 2022, 6:30pm UTC](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864/26 "2022-01-20T18:30:06Z")

</div>

is he actually selling that for 400$? that’s ridiculous.

[Next page](https://meta.discourse.org/t/discord-sync-sync-a-discourse-forum-with-a-discord-server/175864.md?page=2)
