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 on which this plugin was based.
Discord Sync Sync a Discourse forum with a Discord server
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.
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.-
Verified Role
You can add a “verified role” that will be granted to all Discord users who have linked a Discord account. -
Safe Roles
As this plugin will force having the same roles in Discord than groups in Discourse, you can set a list of roles that the bot will ignore and you can manually manage in the Discord server
-
-
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
- User joins a Discord server
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.
Prerrequisites
This plugin requires libsodium
(required by the Discord Ruby gem). To install it, modify your .yml
file and add the following code:
hooks:
before_code:
- exec:
cmd:
- apt-get update
- apt-get install -y libsodium-dev
Installation steps
- Follow the standard guide at How to install a plugin with this repository URL:
https://github.com/barreeeiroo/discourse-discord-sync.git
- Follow this guide to set up Login with Discord in your Discourse instance.
- In the Discord Developer portal, go to Bot, and add it to your server. Make sure you grant him the highest possible role.
- 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:
Acknowledgment
-
Discourse Bot, 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 gettinglibsodium
installed!). -
Discourse Discord Sync, made by @angus
An alternative to sync trust levels into Discord roles without the need of any bot. -
Login with Discord, 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.-
Partially enable login option, made by @Falco and @Roman_Rizzi
And thanks to Falco and Roman for providing an option to enable a login provider to just “link” accounts without actually enable the authentication option.
-
Partially enable login option, made by @Falco and @Roman_Rizzi
-
discordrb
This plugin relies on thediscordrb
gem, which allows connecting to the Discord API using Ruby.