Discord Integration Sample¶
This demo, showcases how you can use the Unreal SDK and Beamable Microservices to integrate with Discord for community management tools.
Introduction¶
Aside from our BeamableCore Plugin, here's what the sample contains:
BEAMPROJ_DiscordDemoUnreal Plugin.: Contains the UE implementation for the client.Microservices/services/DiscordDemoMicroservice: Microservice containing code that implements IFederatedLogin and aDiscordBotintegration.
To set up this sample you'll need a few things:
- A Beamable Account and a Realm.
- A Discord Developer Account.
To configure the sample, run dotnet beam unreal select-sample BEAMPROJ_DiscordDemo.
Assumptions
Instructions below assume that you already have the Discord server that you want to use for integration. If that is not the case create one first. Make sure that you have the admin access to the Discord server of choice.
Setting Discord Application¶
Since this sample requires several resources, we do not host it ourselves. So, in order to access the sample we'll go set up a Discord account and setup the sample Discord bot:
- Log into your Discord.dev account.
- Create an App. Set aside its
AppIdin a notepad for future use.- Fill out General Information about your app.
- No need for providing any of the URLs at the bottom of the General Information page.
- Go to App
Settings->OAuth2and set the Redirects Url:http://127.0.0.1. Make sure that changes are saved. - Go to App
Settings->Bot.- Set a Bot username.
- Set as true all Privileged Gateway Intents, especially the Server Members Intent.
- Press the
Reset Tokenbutton and set it aside (it will be required later on).
- Go to App
Settings->Installation.- In
Install LinkselectDiscord Provided Link, copy and paste it into browser. - In
Default Install Settingsaddbotto theScopesfield andAdministratorto thePermissionsfield - Install the App into your Discord server of choice.
- In
- Now open the Discord application.
- Open
Settings->Advancedand enable theDeveloper Modeso that we can copy various Ids by right-clicking things in the UI. - Right click on the server icon and select the option
Copy server IDand set it aside. - Right click on the server icon and select
Settings->Roles. - Create a
enabled-matchmakingrole. - Right click on the role and select the option
Copy Role IDand set it aside. - Pick any text channel. Right click on the channel select the option
Copy Channel IDand set it aside.
- Open
Setting up Beamable¶
Now, you'll need to configure a Beamable realm so you can use it.
- Go to the Beamable Portal and create a new Beamable realm called
discord-demo. - On the Portal open the Realm Config page of the
discord-demorealm (Operate -> Config). - Hit the
Add Configbutton. - Set the following key-value pairs for the namespace
discord_integration:matchmaking_roles_whitelist -> Your copied Role Id, can be multiple separated by commabot_token -> Your Bot Tokenguild_id -> Your Discord Server IDnotify_channel -> Optional- Discord channel ID that bot will notify about status changes
- Open the
Plugins/BEAMPROJ_DiscordDemo/Overrides/Config/DefaultGame.ini.- Replace the
DiscordAppIdin it withYour App Id. - Regenerate project files.
- Replace the
- Compile and open the
BeamableUnrealeditor (it'll be configured as theBEAMPROJ_DiscordDemo) project.
Now, you are ready to sign into a game using Discord.
Playing the sample in Editor¶
In order to test the sample:
- Open the
BeamableUnrealin the Unreal Editor - Sign into your Beamable account in the
Beamable Windowand go to thediscord-demorealm. - Go to the
Microservicesand run theDiscordSampleMSmicroservice. - Start game.
- Press the
Sign In with Discordbutton following instructions (discord will ask for permission). - After logging in, you should see information about being able to participate in matchmaking.
- Adding and/or removing the role to the signed in user on Discord Server.
- Observe the text on the UI changing to reflect your ability to participate in matchmaking.
- Also, if
notify_channelwas specified correctly in configuration bot should inform about status change:
In order to actually gate matchmaking you'll need to set up a rule in your GameType content that excludes people from the queue that do not have the role. This is not shown on this demo.
Can I use it as a Template?¶
This sample is not meant to be used as a template directly, however, its components are free for you to copy and use in your own project. Here's what these are:
- The
DiscordDemoMicroservice. - Beamable code inside
BEAMPROJ_DiscordDemoexcept code inside aThirdPartydirectory. - Content inside the
BEAMPROJ_DiscordDemoexcept things inside aThirdPartydirectory.
Why don't we provide a client build?¶
Because clients must be pointed at your discord-demo realm. As such, you'd need to generate the build yourself, which you can do by packaging it normally for any of our supported platforms.
