Functions Reference
Godot 4 · GDScript · Friends
send_friend_invite
Sends a friend invitation to a player by key, with an optional message.
Asynchronous (result via signal)
Signature
send_friend_invite(player_key: String, message: String = "") -> voidWhat it does
POSTs /friends/invite. On success invite_sent carries the created invitation; on failure error_code is one of self_invite / already_friends / duplicate_pending / reverse_pending / not_found / internal (reverse_pending means they already invited you; accept their pending invite instead).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| player_key | String | required | The target player's key (e.g. from a leaderboard row, search result, or profile). |
| message | String | "" | Optional note attached to the invite (sanitized, max 200 chars). |
How to call it
Connect invite_sent first, then call send_friend_invite(). No-op with error_code internal when there is no active session.
Result signal: invite_sent(success: bool, error_code: String, invitation: Dictionary)
Example
Gamdato.invite_sent.connect(_on_invited)
Gamdato.send_friend_invite(player_key, "Let's play!")
func _on_invited(ok: bool, error_code: String, invitation: Dictionary) -> void:
if ok: print("invited")
else: print("failed: %s" % error_code)Use cases
- Add-friend button on a player's profile.
- Invite someone you saw on a leaderboard or in search results.