[Issue/Bug]: DiscordRPC.refresh() only refreshes once, not everytime the scene is loaded #75

Closed
opened 2024-11-15 10:18:02 +00:00 by martimcabral · 6 comments
martimcabral commented 2024-11-15 10:18:02 +00:00 (Migrated from github.com)

What happened?

Every time the world_generation.gd is loaded, the only time that works is the first time. After that DiscordRPC.refresh() never refreshes. Which means for me DiscordRPC.refresh() only works once per scene.

Version

1.3.1

Godot Version

4.3

Exact steps to reproduce this error

Downloaded with the Godot AssetLib
Just having a scene that creates a new word for the RichPresence everytime that is loaded.

GDScript

# world_generation.gd
if DiscordRPC.get_is_discord_working():
		DiscordRPC.small_image = "diamond-512"
		DiscordRPC.small_image_text = "Debt: 4 528 913 301 674$"
		DiscordRPC.details = "🌑: " + asteroid_name + " at " + asteroid_field + " Field"
		DiscordRPC.refresh()
	else:
		print("[world_generation.gd] Discord isn't running or wasn't detected, skipping rich presence.")
# Everytime this scene is loaded a new asteroid_name and asteroid_field is created and it only shows the first one

Godot output

No response

Additional information

No response

Checks

### What happened? Every time the world_generation.gd is loaded, the only time that works is the first time. After that DiscordRPC.refresh() never refreshes. Which means for me DiscordRPC.refresh() only works once per scene. ### Version 1.3.1 ### Godot Version 4.3 ### Exact steps to reproduce this error Downloaded with the Godot AssetLib Just having a scene that creates a new word for the RichPresence everytime that is loaded. ### GDScript ```gdscript # world_generation.gd if DiscordRPC.get_is_discord_working(): DiscordRPC.small_image = "diamond-512" DiscordRPC.small_image_text = "Debt: 4 528 913 301 674$" DiscordRPC.details = "🌑: " + asteroid_name + " at " + asteroid_field + " Field" DiscordRPC.refresh() else: print("[world_generation.gd] Discord isn't running or wasn't detected, skipping rich presence.") # Everytime this scene is loaded a new asteroid_name and asteroid_field is created and it only shows the first one ``` ### Godot output _No response_ ### Additional information _No response_ ### 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://vaporvee.com/docs/discord-rpc-godot/

Can you provide more code/context? Where is it called when?

Can you provide more code/context? Where is it called when?
martimcabral commented 2024-11-15 11:23:32 +00:00 (Migrated from github.com)

var consoantes = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']
var vogais = ['a', 'e', 'i', 'o', 'u']
var AsteroidField = ["Delta", "Gamma", "Omega", "Lambda", "Sigma", "Yotta"]

var asteroid_name
var asteroid_field

func _ready():
asteroid_name = create_asteroid_name()
asteroid_field = AsteroidField[randi() % AsteroidField.size()]

if DiscordRPC.get_is_discord_working():
	DiscordRPC.small_image = "diamond-512"
	DiscordRPC.small_image_text = "Debt: 4 528 913 301 674$"
	DiscordRPC.details = "🌑: " + asteroid_name + " at " + asteroid_field + " Field" # <---
	DiscordRPC.refresh() # After loading this scene again it will not refresh with the new asteroid name.
else:
	print("[world_generation.gd] Discord isn't running or wasn't detected, skipping rich presence.")

func create_asteroid_name():
# a bunch of code here to create a random word (it works)

var consoantes = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'] var vogais = ['a', 'e', 'i', 'o', 'u'] var AsteroidField = ["Delta", "Gamma", "Omega", "Lambda", "Sigma", "Yotta"] var asteroid_name var asteroid_field func _ready(): asteroid_name = create_asteroid_name() asteroid_field = AsteroidField[randi() % AsteroidField.size()] if DiscordRPC.get_is_discord_working(): DiscordRPC.small_image = "diamond-512" DiscordRPC.small_image_text = "Debt: 4 528 913 301 674$" DiscordRPC.details = "🌑: " + asteroid_name + " at " + asteroid_field + " Field" # <--- DiscordRPC.refresh() # After loading this scene again it will not refresh with the new asteroid name. else: print("[world_generation.gd] Discord isn't running or wasn't detected, skipping rich presence.") func create_asteroid_name(): # a bunch of code here to create a random word (it works)
martimcabral commented 2024-11-15 12:15:58 +00:00 (Migrated from github.com)

After a lot of testing I fixed by adding the script to the Autoload and adding as a node:
image

After a lot of testing I fixed by adding the script to the Autoload and adding as a node: ![image](https://github.com/user-attachments/assets/3a642d90-d68b-4f58-94dc-446343136705)

Huh thats weird where did you attach it before? Are you sure you called refresh with the new values every time they change? Looks like you pnly called it once on ready

Huh thats weird where did you attach it before? Are you sure you called refresh with the new values every time they change? Looks like you pnly called it once on ready
martimcabral commented 2024-11-15 20:00:45 +00:00 (Migrated from github.com)

Well the problem is already fixed, and yes I am sure that refresh() was called every time values changed, but I think the problem was something to have to do with the _ready() function due to when the code it was in the _process() function it would work, changing constantly.

Well the problem is already fixed, and yes I am sure that refresh() was called every time values changed, but I think the problem was something to have to do with the _ready() function due to when the code it was in the _process() function it would work, changing constantly.

Maybe some weird thing with godot or your code but glad it worked

Maybe some weird thing with godot or your code but glad it worked
Sign in to join this conversation.
No description provided.