implemented rich presences and better naming

This commit is contained in:
2025-03-27 15:22:43 +01:00
parent bd7a102d3d
commit 98a4b4783c
12 changed files with 209 additions and 217 deletions

View File

@@ -1,17 +1,16 @@
extends DiscordConnector
func _on_user_connected(access_token: String, refresh_token: String, expires_in: int) -> void:
@onready var discord_activity: DiscordActivity = $DiscordActivity
func _on_authenticated(access_token: String, refresh_token: String, expires_in: int) -> void:
print_debug("Access token: %s \nRefresh Token: %s \nExpires in: %s" % [access_token, refresh_token, expires_in])
func _on_user_connection_failed(error: String) -> void:
push_error("User connection failed! Error: " + error)
func _on_user_update_failed(error: String) -> void:
push_error("User update failed! Error: " + error)
func _on_connection_ready() -> void:
print_debug("CONNECTION READY")
$DiscordLobby.create_or_join_lobby("beanis")
func _on_authentication_failed(error: String) -> void:
push_error("Auth failed! Error: " + error)
func _on_connection_error(error: String) -> void:
push_error(error)
func _on_connection_ready() -> void:
print_debug("CONNECTION READY")
discord_activity.update_rich_presence()

View File

@@ -1,9 +1,17 @@
[gd_scene load_steps=4 format=3 uid="uid://dyc3kseph4el7"]
[gd_scene load_steps=5 format=3 uid="uid://dyc3kseph4el7"]
[ext_resource type="Texture2D" uid="uid://b3qm246m7pnsx" path="res://assets/Logo_V2.png" id="2_gd222"]
[ext_resource type="Script" uid="uid://kmubk5a6i385" path="res://discord_connector.gd" id="3_h2yge"]
[ext_resource type="Script" uid="uid://46tue7u6crd6" path="res://addons/discord-rpc-gd/nodes/debug.gd" id="6_ujijw"]
[sub_resource type="RichPresence" id="RichPresence_h2yge"]
state = "Inside a Node"
details = "Godot -> Discord Social SDK"
large_image = &"example_game"
large_text = "Example"
small_image = &"boss"
small_text = "Fighting the boss D:"
[node name="Node" type="Node"]
[node name="ColorRect" type="ColorRect" parent="."]
@@ -45,10 +53,10 @@ script = ExtResource("6_ujijw")
[node name="DiscordConnector" type="DiscordConnector" parent="."]
app_id = 1099618430065324082
auto_connect = true
auto_token_manage = true
script = ExtResource("3_h2yge")
[node name="DiscordActivity" type="DiscordActivity" parent="DiscordConnector"]
rich_presence = SubResource("RichPresence_h2yge")
root_connector = NodePath("..")
[node name="DiscordLobby" type="DiscordLobby" parent="DiscordConnector"]
@@ -58,8 +66,7 @@ root_connector = NodePath("..")
position = Vector2(789, 330.5)
scale = Vector2(0.408203, 0.408203)
[connection signal="authenticated" from="DiscordConnector" to="DiscordConnector" method="_on_authenticated"]
[connection signal="authentication_failed" from="DiscordConnector" to="DiscordConnector" method="_on_authentication_failed"]
[connection signal="connection_error" from="DiscordConnector" to="DiscordConnector" method="_on_connection_error"]
[connection signal="connection_ready" from="DiscordConnector" to="DiscordConnector" method="_on_connection_ready"]
[connection signal="user_connected" from="DiscordConnector" to="DiscordConnector" method="_on_user_connected"]
[connection signal="user_connection_failed" from="DiscordConnector" to="DiscordConnector" method="_on_user_connection_failed"]
[connection signal="user_update_failed" from="DiscordConnector" to="DiscordConnector" method="_on_user_update_failed"]