[Issue/Bug]: get_all_relationships() returning empty array #51

Closed
opened 2024-01-28 13:22:53 +00:00 by grossqx · 5 comments
grossqx commented 2024-01-28 13:22:53 +00:00 (Migrated from github.com)

What happened?

Hello! Wondering if this is a mistake on my part, intended behavior of Discord, an OS quirk or a bug.
get_all_relationships() method is returning an empty array. That is until status of one of my friends changes. When it does, updated_relationship signal gets called and all subsequent calls of get_all_relationships() that come after the signal now return a single member array with a friend who's status change was registered is that session. Once more friends update their statuses, they also become visible to get_all_relationships() calls and the array grows. If I relaunch the app, the array returns as empty again. I expected it to return the whole list of friends, including those that are offline.

Running discord and godot on linux. All other sdk features working great.

Version

1.1.0

Godot Version

4.2.1

Exact steps to reproduce this error

Downloaded addon from AssetLib. Restarted project 2 times, got rig of all errors. Created my own scene, added a script, launcher the scene. The scene is just two buttons. I'm marking the press events in the log.
I also tried running the Debug scene from the addon directory, which yielded same behavior regarding the issue.

GDScript

extends Control

func _ready():
	DiscordSDK.relationships_init.connect(_on_relationships_init)
	DiscordSDK.updated_relationship.connect(_on_updated_relationship)
	DiscordSDK.app_id = 1264226342176424345 ## this is random for privacy
	var is_discord = DiscordSDK.get_is_discord_working()
	print("Discord is working ", is_discord)
	DiscordSDK.refresh() # Always refresh after changing the values!


func  _process(_delta) -> void:
	DiscordSDK.run_callbacks()

func _on_relationships_init():
	print("Discord: _on_relationships_init")

func _on_updated_relationship(relationship: Dictionary):
	print("Discord: _on_updated_relationship: ", relationship)

func _on_print_user_button_pressed():
	var user = DiscordSDK.get_current_user()
	print("Discord user: ", user)

func _on_print_friends_button_pressed():
	print(DiscordSDK.get_all_relationships())

Godot output

Godot Engine v4.2.1.stable.official.b09f793f5 - https://godotengine.org

Discord is working true
Discord: _on_relationships_init
## Button press print_user
Discord user: { "avatar": "4ddfg42sa", "is_bot": false, "discriminator": "1111", "id": 6579423421954243, "username": "my_username", "avatar_url": "https://cdn.discordapp.com/avatars/6579423421954243/fghfg7h6f8gh7fgh87fghf8g7h.png" }
## Button press print_friends
[]
## Button press print_friends
[]
## Friend becomes online and immediately logs out
Discord: _on_updated_relationship: { "type": "Friend", "user": { "avatar": "", "is_bot": false, "discriminator": "1111", "id": 23423423423234, "username": "BestFriend", "avatar_url": "https://cdn.discordapp.com/embed/avatars/1.png" }, "presence": { "status": "Online", "activity": { "application_id": 0, "name": "", "state": "", "details": "", "large_image": "", "large_text": "", "small_image": "", "small_text": "", "timestamps_start": 0, "timestamps_end": 0, "instance": false, "party_id": "", "current_party_size": 0, "max_party_size": 0, "join_secret": "", "spectate_secret": "", "match_secret": "" } } }
Discord: _on_updated_relationship: { "type": "Friend", "user": { "avatar": "", "is_bot": false, "discriminator": "1111", "id": 23423423423234, "username": "BestFriend", "avatar_url": "https://cdn.discordapp.com/embed/avatars/1.png" }, "presence": { "status": "Offline", "activity": { "application_id": 0, "name": "", "state": "", "details": "", "large_image": "", "large_text": "", "small_image": "", "small_text": "", "timestamps_start": 0, "timestamps_end": 0, "instance": false, "party_id": "", "current_party_size": 0, "max_party_size": 0, "join_secret": "", "spectate_secret": "", "match_secret": "" } } }
## Button press print_friends
[{ "type": "Friend", "user": { "avatar": "", "is_bot": false, "discriminator": "1111", "id": 23423423423234, "username": "BestFriend", "avatar_url": "https://cdn.discordapp.com/embed/avatars/1.png" }, "presence": { "status": "Offline", "activity": { "application_id": 0, "name": "", "state": "", "details": "", "large_image": "", "large_text": "", "small_image": "", "small_text": "", "timestamps_start": 0, "timestamps_end": 0, "instance": false, "party_id": "", "current_party_size": 0, "max_party_size": 0, "join_secret": "", "spectate_secret": "", "match_secret": "" } } }]
## Button press print_friends
[{ "type": "Friend", "user": { "avatar": "", "is_bot": false, "discriminator": "1111", "id": 23423423423234, "username": "BestFriend", "avatar_url": "https://cdn.discordapp.com/embed/avatars/1.png" }, "presence": { "status": "Offline", "activity": { "application_id": 0, "name": "", "state": "", "details": "", "large_image": "", "large_text": "", "small_image": "", "small_text": "", "timestamps_start": 0, "timestamps_end": 0, "instance": false, "party_id": "", "current_party_size": 0, "max_party_size": 0, "join_secret": "", "spectate_secret": "", "match_secret": "" } } }]

Additional information

I'll be happy to provide more information if I missed something.

Checks

### What happened? Hello! Wondering if this is a mistake on my part, intended behavior of Discord, an OS quirk or a bug. get_all_relationships() method is returning an empty array. That is until status of one of my friends changes. When it does, updated_relationship signal gets called and all subsequent calls of get_all_relationships() that come after the signal now return a single member array with a friend who's status change was registered is that session. Once more friends update their statuses, they also become visible to get_all_relationships() calls and the array grows. If I relaunch the app, the array returns as empty again. I expected it to return the whole list of friends, including those that are offline. Running discord and godot on linux. All other sdk features working great. ### Version 1.1.0 ### Godot Version 4.2.1 ### Exact steps to reproduce this error Downloaded addon from AssetLib. Restarted project 2 times, got rig of all errors. Created my own scene, added a script, launcher the scene. The scene is just two buttons. I'm marking the press events in the log. I also tried running the Debug scene from the addon directory, which yielded same behavior regarding the issue. ### GDScript ```gdscript extends Control func _ready(): DiscordSDK.relationships_init.connect(_on_relationships_init) DiscordSDK.updated_relationship.connect(_on_updated_relationship) DiscordSDK.app_id = 1264226342176424345 ## this is random for privacy var is_discord = DiscordSDK.get_is_discord_working() print("Discord is working ", is_discord) DiscordSDK.refresh() # Always refresh after changing the values! func _process(_delta) -> void: DiscordSDK.run_callbacks() func _on_relationships_init(): print("Discord: _on_relationships_init") func _on_updated_relationship(relationship: Dictionary): print("Discord: _on_updated_relationship: ", relationship) func _on_print_user_button_pressed(): var user = DiscordSDK.get_current_user() print("Discord user: ", user) func _on_print_friends_button_pressed(): print(DiscordSDK.get_all_relationships()) ``` ### Godot output ```shell Godot Engine v4.2.1.stable.official.b09f793f5 - https://godotengine.org Discord is working true Discord: _on_relationships_init ## Button press print_user Discord user: { "avatar": "4ddfg42sa", "is_bot": false, "discriminator": "1111", "id": 6579423421954243, "username": "my_username", "avatar_url": "https://cdn.discordapp.com/avatars/6579423421954243/fghfg7h6f8gh7fgh87fghf8g7h.png" } ## Button press print_friends [] ## Button press print_friends [] ## Friend becomes online and immediately logs out Discord: _on_updated_relationship: { "type": "Friend", "user": { "avatar": "", "is_bot": false, "discriminator": "1111", "id": 23423423423234, "username": "BestFriend", "avatar_url": "https://cdn.discordapp.com/embed/avatars/1.png" }, "presence": { "status": "Online", "activity": { "application_id": 0, "name": "", "state": "", "details": "", "large_image": "", "large_text": "", "small_image": "", "small_text": "", "timestamps_start": 0, "timestamps_end": 0, "instance": false, "party_id": "", "current_party_size": 0, "max_party_size": 0, "join_secret": "", "spectate_secret": "", "match_secret": "" } } } Discord: _on_updated_relationship: { "type": "Friend", "user": { "avatar": "", "is_bot": false, "discriminator": "1111", "id": 23423423423234, "username": "BestFriend", "avatar_url": "https://cdn.discordapp.com/embed/avatars/1.png" }, "presence": { "status": "Offline", "activity": { "application_id": 0, "name": "", "state": "", "details": "", "large_image": "", "large_text": "", "small_image": "", "small_text": "", "timestamps_start": 0, "timestamps_end": 0, "instance": false, "party_id": "", "current_party_size": 0, "max_party_size": 0, "join_secret": "", "spectate_secret": "", "match_secret": "" } } } ## Button press print_friends [{ "type": "Friend", "user": { "avatar": "", "is_bot": false, "discriminator": "1111", "id": 23423423423234, "username": "BestFriend", "avatar_url": "https://cdn.discordapp.com/embed/avatars/1.png" }, "presence": { "status": "Offline", "activity": { "application_id": 0, "name": "", "state": "", "details": "", "large_image": "", "large_text": "", "small_image": "", "small_text": "", "timestamps_start": 0, "timestamps_end": 0, "instance": false, "party_id": "", "current_party_size": 0, "max_party_size": 0, "join_secret": "", "spectate_secret": "", "match_secret": "" } } }] ## Button press print_friends [{ "type": "Friend", "user": { "avatar": "", "is_bot": false, "discriminator": "1111", "id": 23423423423234, "username": "BestFriend", "avatar_url": "https://cdn.discordapp.com/embed/avatars/1.png" }, "presence": { "status": "Offline", "activity": { "application_id": 0, "name": "", "state": "", "details": "", "large_image": "", "large_text": "", "small_image": "", "small_text": "", "timestamps_start": 0, "timestamps_end": 0, "instance": false, "party_id": "", "current_party_size": 0, "max_party_size": 0, "join_secret": "", "spectate_secret": "", "match_secret": "" } } }] ``` ### Additional information I'll be happy to provide more information if I missed something. ### Checks - [X] I tried reinstalling the addon or tried to fix it myself with other methods. - [X] I tried restarting Discord and Godot completely. - [X] I did read the documentation https://github.com/vaporvee/discord-sdk-godot/wiki

yeah its a known issue. began to happen at one day without changing this function in the code so i assume the way I'm getting it from the discord game sdk isn't working anymore since an discord update or something. but when i have more time i will try fix it if it's possible.

yeah its a known issue. began to happen at one day without changing this function in the code so i assume the way I'm getting it from the discord game sdk isn't working anymore since an discord update or something. but when i have more time i will try fix it if it's possible.
grossqx commented 2024-01-28 19:49:52 +00:00 (Migrated from github.com)

Thank you for promptly confirming this. Feel free to ping me if I can help with further testing. Thanks!

Thank you for promptly confirming this. Feel free to ping me if I can help with further testing. Thanks!

okay so i assume its really discord fault. even their example can't access the full friendslist anymore. when i found further information I'll let you know

okay so i assume its really discord fault. even their example can't access the full friendslist anymore. when i found further information I'll let you know
grossqx commented 2024-05-06 11:17:20 +00:00 (Migrated from github.com)

Revisiting the addon. Now testing on 4.2.2 and plugin version 1.3.1. Right now relationships don't get updated at all, even if a friend logs in while the app is running.

Revisiting the addon. Now testing on 4.2.2 and plugin version 1.3.1. Right now relationships don't get updated at all, even if a friend logs in while the app is running.

Oh I heard about that I think I'm deprecating the feature until Discord ever makes an update. Please consider using OAuth2 instead. I use https://github.com/disgoorg/disgo for example but there are enough libraries for other languages too.

Oh I heard about that I think I'm deprecating the feature until Discord ever makes an update. Please consider using OAuth2 instead. I use https://github.com/disgoorg/disgo for example but there are enough libraries for other languages too.
Sign in to join this conversation.
No description provided.