This repository provides a template for integrating a Playcanvas application within Discord Activities. By following the instructions below, you can easily set up your Playcanvas app to be displayed within Discord's Embedded Apps.
Follow these steps to set up the template for your Playcanvas application:
-
Clone the Repository: Clone this repository to your local machine.
git clone https://github.com/MushAsterion/playcanvas-discord-embedded-app.git
-
Set Environment Variables:
Open the
.env
file and update the following environment variables:NEXT_PUBLIC_DISCORD_APP_CLIENT_ID
: Set this to your Discord application's client ID.DISCORD_APP_CLIENT_SECRET
: Set this to your Discord application's client secret.NEXT_PUBLIC_DISCORD_AUTH_BACKGROUND
(Optional): Set this to change the background displayed until the user authorizes the game. Will default to#000
(plain black background).
-
Add Playcanvas Build:
- Build your Playcanvas application.
- Upload your build to the repository, except for the
index.html
file within thepublic
folder.
-
Update Index.html (Optional):
If your
index.html
file is different from the default one provided by Playcanvas Editor, update it withinsrc/pages/_document.jsx
file to match the content, except for the scripts__start__.js
and__loading__.js
that will be loaded after user is authenticated. -
Deploy the Application:
Deploy your application using your preferred method.
Once you've completed the setup, users can interact with your Playcanvas application directly within Discord Activities. Please refer to Discord's official documentation to use the SDK.
SDK is available directly from window.discordSdk
, and authentication is available directly from window.discordSdkAuth
.
Contributions are welcome! If you have any improvements or suggestions, feel free to open an issue or pull request.
This project is licensed under the MIT License.