Discord Connector¶
Overview¶
The Discord Connector allows you to attach Discord roles to Groups on the Krypted Platform. By doing this, users will automatically be assigned Discord roles whenever they are added to a Group on your website. In combination with other packages like EVE Group States and Group Requests, you’re able to create a powerful syncing platform that enhances security across your platforms.
Quick Setup¶
To set up the django_discord_connector
package:
- Install it (varies, Docker vs Development)
- (Recommended) Load the default schedule (
python3 manage.py loaddata discord_default_schedule
) - Create a Discord Application (https://discordapp.com/developers/applications)
- Create a Discord client in the Admin Panel (
http://<your_site>/admin
) - Input the
CLIENT ID
from your Discord application - Input the
CLIENT_SECRET
from your Discord application - Click
OAuth2
on your Discord application, set yourCALLBACK URL
(e.ghttp://<your_site>/discord/sso/callback
) - Click
Bot
on your Discord application, set yourTOKEN
- Create a non-expiry Discord invite link, input it
- Invite your Bot to the Discord server (use the
OAuth2
bot tool) - Select your new client in the Admin Panel and click the dropdown, sync your groups
Detailed Setup¶
1. Create a Discord Application¶
- Navigate to https://discordapp.com/developers/applications
- Click “New Application”
- Fill out a name, click create.
- Add an application icon, description, and customize your application.
- Copy the
CLIENT ID
value, save this for later. - Copy the
CLIENT SECRET
value, save this for later.
2. Get Bot Token¶
- Click the Bot section
- Add a Bot.
- Customize your bot, add an icon and username.
- Copy the
TOKEN
value, save this for later.
3. Inviting your Bot¶
- Click the OAuth2* section
- Add a Redirect URL,
https://<your_domain>/discord/sso/callback
((your_site
is your site domain). Save this value for later. - Under the Scopes section, check the bot box.
- Scroll down to Bot Permissions, check Administrator.
- Scroll back up to Scopes, copy the URL at the bottom and paste it in your browser.
- Use this URL to invite the bot to your server.
4. Get your Server ID¶
- Open your Discord settings
- Navigate to Appearance
- Enable Developer Mode
- Right click your Server icon in the Discord menu
- Copy ID. Save this for later.
5. Create a permanant invite link¶
- Navigate to your server, hover over a channel and create an invite link.
- Select no expiry, unlimited uses. Save this link for later.
4. Creating the Discord Client¶
- Navigate to your Admin Panel on the Krypted platform
- Select Discord Clients
- Create a new Discord client
- Input the CALLBACK URL from Step #3
- Input the SERVER ID from Step #4
- Input the CLIENT ID from Step #1
- Input the CLIENT SECRET from Step #1
- Input the BOT TOKEN from Step #2
- Input the INVITE LINK from Step #5
Tasks¶
There are a few tasks that you need to know about.
django_discord_connector.tasks.verify_all_discord_users_groups
is used to check that users have the groups they’re supposed to, and updates their groups based on what’s in the database. With theDISCORD_REMOTE_PRIORITY
setting set toTrue
, it will favor Discord groups over Krypted groups.django_discord_connector.tasks.sync_discord_users_accounts
This will update usernames and nicknames of all users.django_discord_connector.tasks.remote_sync_all_discord_users_groups
Sometimes, groups get out of sync. This is most common when someone adds a group to a user on the Discord server, instead of letting authentication handle it. By running this task, we do a hard sync on all users. This is an expensive task, don’t overuse it.- ‘django_discord_connector.tasks.enforce_discord_nicknames
This task takes an ARGUMENT
enforce_strategy, which can be on of the following:
EVE_ONLINE. This will enforce Discord nicknames (e.g in the case of
EVE_ONLINE`, primary character name). You must disable users’ ability to change their nickname for this to work cleanly.
Recommended Task Schedule¶
Command | Action | Interval |
---|---|---|
django_discord_connector.tasks.verify_all_discord_users_groups |
Verify groups | Every 5 minutes |
django_discord_connector.tasks.sync_discord_users_accounts |
Update nicknames | Every week |
django_discord_connector.tasks.remote_sync_all_discord_users_groups |
Verify groups with remote server | Every week |