Discord Demo
This demo, showcases how you can use the Unreal SDK and Beamable Microservices to integrate with Discord for community management tools.
Aside from our BeamableCore
Plugin, here's what the sample contains:
BEAMPROJ_DiscordDemo
Unreal Plugin.: Contains the UE implementation for the client.Microservices/services/DiscordDemo
Microservice: Microservice containing code that implements IFederatedLogin and aDiscordBot
integration.
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, set the BeamProjOverride.txt
to BEAMPROJ_DiscordDemo
, re-generate your project files and run the BeamableUnreal
project (it'll be configured as the BEAMPROJ_DiscordDemo
sample).
Setting up Beamable & Discord Application¶
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.
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
AppId
in 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->OAuth2
and 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 Token
button and set it aside (it will be required later on).
- Go to App
Settings->Installation
.- In
Install Link
selectDiscord Provided Link
, copy and paste it into browser. - Install the App into your Discord server of choice.
- In
- Now open the Discord application.
- Open
Settings->Advanced
and enable theDeveloper Mode
so 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 ID
and set it aside. - Right click on the server icon and select
Settings->Roles
. - Create a
enabled-matchmaking
role. - Right click on the role and select the option
Copy Role ID
and set it aside. - Pick any text channel. Right click on the channel select the option
Copy Channel ID
and set it aside.
- Open
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
. - Go to the Portal (
Account
) and set aside your Customer Id (CID). - Go to the Portal and set aside your realm's PID and Realm Secret (
Games -> YourGame -> discord-demo
). - On the Portal open the Realm Config page of the
discord-demo
realm (Operate -> Config
). - Hit the
Add Config
button. - Set the following key-value pairs for the namespace
discord_integration
: matchmaking_roles_whitelist -> Your copied Role Id, can be multiple separated by comma
bot_token -> Your Bot Token
guild_id -> Your Discord Server ID
notify_channel -> Optional- Discord channel ID that bot will notify about status changes
- Open the
Plugins/BEAMPROJ_DiscordDemo/Overrides/Config/DefaultGame.ini
.- Replace the
DiscordAppId
in it withYour App Id
. - Regenerate project files.
- Replace the
- Compile and open the
BeamableUnreal
editor (it'll be configured as theBEAMPROJ_DiscordDemo
) project. - Sign into your Beamable account and go to the
discord-demo
realm.- Hit
Apply to Build
.
- Hit
- Open a bash terminal at the
BeamableUnreal
root directory. - Run
dotnet beam project enable --with-group BEAMPROJ_DiscordDemo
- Run
dotnet beam project disable --without-group BEAMPROJ_DiscordDemo
- Run
dotnet beam deploy plan
.- This tells you details about the services you would deploy given your project's local state.
- Run
dotnet beam deploy release --latest-plan
.- This deploys the services outlined by the generated plan in the previous command.
- Go to the Portal (
Operate -> Microservices
) and verify that the microservices have initialized.
Now, you are ready to sign into a game using Discord.
Playing the sample through PIE¶
In order to test the sample:
- Start game.
- Press the
Sign In with Discord
button 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_channel
was 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.
What can you do with this sample?¶
This sample is NOT a template you can start your own repository from.
However, its Beamable code components are free for you to copy and use in your own project. Here's what these are:
- The
DiscordDemo
Microservice. - Beamable code inside
BEAMPROJ_DiscordDemo
except code inside aThirdParty
directory. - Content inside the
BEAMPROJ_DiscordDemo
except things inside aThirdParty
directory.
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.