started working on the docs sidebar

This commit is contained in:
2024-02-05 14:53:57 +01:00
parent 73d849325f
commit e5d78baad2
11 changed files with 319 additions and 7 deletions

View File

@@ -0,0 +1,99 @@
---
layout: ../../../layouts/DocsLayout.astro
repo: discord-sdk-godot
title: Activities
draft: true
---
# Variables
Anything of course begins with `DiscordSDK.` e.g. `DiscordSDK.app_id = <your Application ID>`
### Rich presence
| Name | Type | Description |
| --- | --- | --- |
| app_id | int | The Application ID you need to get to make anything in the SDK → https://discord.com/developers/applications |
| details | String | The first text line visible in the Activity (after the app name) |
| state | String | The second text line visible in the Activity |
| large_image | String | Key for the large image you set while uploading an image to the "Rich Presence" → "Art Assets" tab in your online Discord dev panel |
| large_image_text | String | Text wich shows when you hover over the large image |
| small_image | String | Key for the small image you set while uploading an image to the "Rich Presence" → "Art Assets" tab in your online Discord dev panel |
| small_image_text | String | Text wich shows when you hover over the small image |
| start_timestamp | int | The "02:46 elapsed" timestamp in the presence. Get the current time with Godot's `int(Time.get_unix_time_from_system())` and Discord counts in seconds from it |
| end_timestamp | int | The "59:59 elapsed" timestamp in the presence. Get it with Godot's `int(Time.get_unix_time_from_system())` and add seconds as int e.g. `+ 3600` → + 1 Hour |
### Invite system
The values can be pretty anything since there is no lobby system in the SDK anymore. You should already have a custom lobby system wich can compute the secret and change the values. After an invite every value should be the same as the other player.
| Name | Type | Description |
| --- | --- | --- |
| party_id | String | Unique identifier for the party |
| current_party_size | int | The current playercount in the party |
| max_party_size | int | Maximum allowed playercount in the party |
| match_secret | String | Unique hash for the given match context |
| join_secret | String | Unique hash for chat invites and Ask to Join |
| spectate_secret | String | Unique hash for Spectate button |
| is_public_party | bool | Turn it to `true` if you want people to join the party without asking. This needs to be enabled in the Discord user settings |
| instanced | bool | Whether this activity is an instanced context, like a match |
# Signals
### Invite system
### Activity join request
**Connect it with:**
```gdscript
DiscordSDK.connect("activity_join_request",_on_activity_join_request)
```
**Add it in your gdscript as function:**
```gdscript
func _on_activity_join_request(user_requesting):
```
The Signal fires when someone requests to join your Activity via an request join button in Discord.<br/>
**Given variable:** [`Dictionary user_requesting`](https://github.com/vaporvee/discord-sdk-godot/wiki/Users#get-current-user)
<br/>
<br/>
### Activity join
**Connect it with:**
```gdscript
DiscordSDK.connect("activity_join",_on_activity_join)
```
**Add it in your gdscript as function:**
```gdscript
func _on_activity_join(secret):
```
The Signal fires when someone joins your Activity via an invite or join button in Discord.<br/>
**Given variable:** `String secret`<br/>
Send the secret to your custom system to generate the other party values and make them the same as the target user.
<br/>
<br/>
### Activity spectate
**Connect it with:**
```gdscript
DiscordSDK.connect("activity_spectate",_on_activity_spectate)
```
**Add it in your gdscript as function:**
```gdscript
func _on_activity_spectate(secret):
```
The Signal fires when someone spectates your Activity via an invite or spectate button in Discord.<br/>
**Given variable:** `String secret` <br/>
Send the secret to your custom system to generate the other party values and make them the same as the target user.
# Methods
### Refresh
After setting any variables you have to reload the SDK with this method
```gdscript
DiscordSDK.refresh()
```
### Clear
Disables the Activity.
```gdscript
DiscordSDK.clear(reset_values)
```
**Taken variable:** `bool reset_values` **Standard value:** `false`<br/>
When turning `reset_values` to `true` it completely clears the whole activity with its app_id and other values.
### Unclear
Reenables the before cleared Activity. Only works with `DiscordSDK.clear(reset_values = false)`(default).
```gdscript
DiscordSDK.unclear()
```