Godot
Welcome to your fresh Robo.js project!
Build, deploy, and maintain your Discord Activities with ease. With Robo.js as your guide, you'll experience a seamless, file-based setup, an integrated database, TypeScript support, and a rich ecosystem.
Ready to embark on this adventure?
Getting Startedโ
Create a project with this template, replacing <project-name>
with your desired name:
npx create-robo --template discord-activities/godot --name <project-name>
Then navigate into your project directory:
cd <project-name>
Run development mode:
npm run dev
๏ธ App Developmentโ
You can find your client-side code in the /src/app
folder. This is where you can build your web app using React, Vue, or any other front-end framework.
Things are powered by Vite under the hood, so you get the latest ES modules, hot module reloading, and more! โก
Try editing the main
file to get started! (Activity.tsx
if you're using React)
๐ฎ Connecting your Godot gameโ
- Open your Godot project and add/select the Web export template.
- Configure the export settings for your Godot project.
- Note if using Godot 4, you must disable
Thread Support
- Note if using Godot 4, you must disable
- Export your Godot project as a Web build and locate the generated files. (Recommended to disable
Export With Debug
) - Copy/Move generated files to the
/public
folder- Feel free to delete
Game/Testing
(it's just a demo) - only
.js
,.wasm
, and.pck
files required .html
not needed; (You can find file sizes inconst GODOT_CONFIG =
)
- Feel free to delete
- update
useGodot
hook insrc/app/Activity.tsx
to point to your Godot project. example: Say my game is inpublic/Game/
and namedTesting
;file sizes are optional, but needed if you want progress percentageconst { startGame, loading } = useGodot('/Game/Testing', { pck: 1779104, wasm: 43016933 })
๐งต Accessing discord sdk in Godotโ
In React you pass the discord sdk to window for use in Godot
const { discordSdk, status, accessToken, session } = useDiscordSdk()
useEffect(() => {
window.discord = {
sdk: discordSdk,
accessToken,
session,
status
}
}, [discordSdk, status, accessToken, session])
In Godot, you can access the discord sdk via the JavaScriptBridge singleton
var discord = JavaScriptBridge.get_interface("discord")
๐ Authenticationโ
The React template makes it easy to authenticate your activity with Discord. The <DiscordProvider>
components in App.tsx
accepts authenticate
and scope
props.
<DiscordContextProvider authenticate scope={['identify', 'guilds']}>
<Activity />
</DiscordContextProvider>
You can then get the SDK and other goodies from the useDiscordSdk
hook!