I have a couple questions about your plugin. #61

Closed
opened 2024-08-08 19:26:13 +00:00 by k120F · 16 comments
k120F commented 2024-08-08 19:26:13 +00:00 (Migrated from github.com)

First of all, how can I update DiscordRPC.start_timestamp and DiscordRPC.details when restarting the room?
I tried typing DiscordRPC.refresh() but it didn't work.
Why doesn't Discord RPC disappear immediately after closing the game? I suspect that this might be why Discord doesn't recognize my game.
Maybe I did something wrong.
godot code:

func _ready() -> void:
	#discord
	DiscordRPC.app_id = ***************** # I don't think it's necessary to show this."
	DiscordRPC.details = "Developing"
	DiscordRPC.large_image = "discord_image"
	DiscordRPC.large_image_text = "Try it now!"
	DiscordRPC.small_image_text = "Fighting the end boss! D:"
	DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system())
	DiscordRPC.refresh()

func _process(delta: float) -> void:
	DiscordRPC.run_callbacks()
	DiscordRPC.state = "HP "+ str(global.hp)+ "/" + "92"
	DiscordRPC.refresh()
	if $HeartLayer/PlayerHeart.mode==1:
		DiscordRPC.small_image = "soul_red" 
		DiscordRPC.refresh()
	elif $HeartLayer/PlayerHeart.mode==2: 
		DiscordRPC.small_image = "soul_blue"
		DiscordRPC.refresh()
	if Input.is_action_pressed("F1"):
		get_tree().reload_current_scene()
First of all, how can I update DiscordRPC.start_timestamp and DiscordRPC.details when restarting the room? I tried typing DiscordRPC.refresh() but it didn't work. Why doesn't Discord RPC disappear immediately after closing the game? I suspect that this might be why Discord doesn't recognize my game. Maybe I did something wrong. godot code: ```gdscript func _ready() -> void: #discord DiscordRPC.app_id = ***************** # I don't think it's necessary to show this." DiscordRPC.details = "Developing" DiscordRPC.large_image = "discord_image" DiscordRPC.large_image_text = "Try it now!" DiscordRPC.small_image_text = "Fighting the end boss! D:" DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system()) DiscordRPC.refresh() func _process(delta: float) -> void: DiscordRPC.run_callbacks() DiscordRPC.state = "HP "+ str(global.hp)+ "/" + "92" DiscordRPC.refresh() if $HeartLayer/PlayerHeart.mode==1: DiscordRPC.small_image = "soul_red" DiscordRPC.refresh() elif $HeartLayer/PlayerHeart.mode==2: DiscordRPC.small_image = "soul_blue" DiscordRPC.refresh() if Input.is_action_pressed("F1"): get_tree().reload_current_scene() ```
k120F commented 2024-08-08 19:32:45 +00:00 (Migrated from github.com)

I forgot to mention that I even reinstalled Discord, but the plugin still might not always work, though Discord responds to other programs/games.

I forgot to mention that I even reinstalled Discord, but the plugin still might not always work, though Discord responds to other programs/games.
# to reset the time just set the current timestamp
DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system())
# and then refresh
DiscordRPC.refresh()

It does disappear directly for everyone who sees your Discord profile but may sometimes take a bit on client side.
And what do you mean by not recognizing your game when the Discord RPC appears (in order to dissappear like you said).

```gdscript # to reset the time just set the current timestamp DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system()) # and then refresh DiscordRPC.refresh() ``` It does disappear directly for everyone who sees your Discord profile but may sometimes take a bit on client side. And what do you mean by not recognizing your game when the Discord RPC appears (in order to dissappear like you said).

Also did you check Discord settings -> Activity Privacy ?

Also did you check Discord settings -> Activity Privacy ?

oh i see you spam refresh on _process never loop stuff that doesnt need to be looped it breaks most stuff or makes it laggy

oh i see you spam refresh on _process never loop stuff that doesnt need to be looped it breaks most stuff or makes it laggy
k120F commented 2024-08-08 19:57:49 +00:00 (Migrated from github.com)

Thank you very much for the quick response.

Okay, I removed the unnecessary DiscordRPC.refresh() calls; I just thought that every time something changes, I needed to keep calling DiscordRPC.refresh().

Next question about DiscordRPC.start_timestamp, I remember once I also did it and it worked but only for one time and it was not updated anymore.

Also, it's important for me to know how to update DiscordRPC.state = "HP " + str(global.hp) + "/" + "92" and DiscordRPC.small_image as well.

And yes, Discord does see when I launch program, or games.

Thank you very much for the quick response. Okay, I removed the unnecessary DiscordRPC.refresh() calls; I just thought that every time something changes, I needed to keep calling DiscordRPC.refresh(). Next question about DiscordRPC.start_timestamp, I remember once I also did it and it worked but only for one time and it was not updated anymore. Also, it's important for me to know how to update DiscordRPC.state = "HP " + str(global.hp) + "/" + "92" and DiscordRPC.small_image as well. And yes, Discord does see when I launch program, or games.

Okay so you need to make a signal somehow in your game when your health changes: https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html#custom-signals
Also yeah you need to call it everytime you change something but you cant spam it or it breaks. Always try to loop as less as possible. And what do you mean the timestamp updated only once? Can you send me some new code?

Okay so you need to make a signal somehow in your game when your health changes: https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html#custom-signals Also yeah you need to call it everytime you change something but you cant spam it or it breaks. Always try to loop as less as possible. And what do you mean the timestamp updated only once? Can you send me some new code?
k120F commented 2024-08-08 20:29:54 +00:00 (Migrated from github.com)

I don't even spam the button, the timer update works once when I restart the room.
code:

extends Node2D

func _ready() -> void:
		#discord
	DiscordRPC.app_id = dont share your token# Application ID
	DiscordRPC.details = "Developing"
	DiscordRPC.large_image = "discord_image" # Image key from "Art Assets"
	DiscordRPC.large_image_text = "Try it now!"
	DiscordRPC.small_image_text = "Fighting the end boss! D:"
	DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system())
	DiscordRPC.refresh()
	func _process(delta: float) -> void:
	DiscordRPC.run_callbacks()
	if $HeartLayer/PlayerHeart.mode==1:
		DiscordRPC.small_image = "soul_red" 
	elif $HeartLayer/PlayerHeart.mode==2: 
		DiscordRPC.small_image = "soul_blue"
	if Input.is_action_pressed("F1"):
		get_tree().reload_current_scene()
		DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system())
		DiscordRPC.refresh()
I don't even spam the button, the timer update works once when I restart the room. code: ```gdscript extends Node2D func _ready() -> void: #discord DiscordRPC.app_id = dont share your token# Application ID DiscordRPC.details = "Developing" DiscordRPC.large_image = "discord_image" # Image key from "Art Assets" DiscordRPC.large_image_text = "Try it now!" DiscordRPC.small_image_text = "Fighting the end boss! D:" DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system()) DiscordRPC.refresh() func _process(delta: float) -> void: DiscordRPC.run_callbacks() if $HeartLayer/PlayerHeart.mode==1: DiscordRPC.small_image = "soul_red" elif $HeartLayer/PlayerHeart.mode==2: DiscordRPC.small_image = "soul_blue" if Input.is_action_pressed("F1"): get_tree().reload_current_scene() DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system()) DiscordRPC.refresh() ```

you do

func _process(delta: float) -> void:
	DiscordRPC.run_callbacks()

You spam this function every frame with process not any button i never mentioned

you do ```gdscript func _process(delta: float) -> void: DiscordRPC.run_callbacks() ``` You spam this function every frame with process not any button i never mentioned

also please use

```gdscript
# your code here
```

also please use \```gdscript \# your code here \```

So its fixed now?

So its fixed now?
k120F commented 2024-08-09 21:46:35 +00:00 (Migrated from github.com)

I don't even know how to work with this my hp completely freezes when I restart the room, although I even used the "state" function where there is interaction with hp.
Restarting the timer works once and sometimes discord-rpc can fail i'm only saved by rebooting discord to get my game to pop up.
I just don't know what I'm doing wrong Xd

I don't even know how to work with this my hp completely freezes when I restart the room, although I even used the "state" function where there is interaction with hp. Restarting the timer works once and sometimes discord-rpc can fail i'm only saved by rebooting discord to get my game to pop up. I just don't know what I'm doing wrong Xd
k120F commented 2024-08-09 21:48:50 +00:00 (Migrated from github.com)

It certainly displays well as I lose hp but after restarting my hp is not updated

It certainly displays well as I lose hp but after restarting my hp is not updated

Just never put a DiscordRPC.refresh in a _process function

Just never put a DiscordRPC.refresh in a _process function
k120F commented 2024-08-09 22:11:40 +00:00 (Migrated from github.com)

Okay, then in that case my hp will not be updated at all and will always be static for discord 😌.

Okay, then in that case my hp will not be updated at all and will always be static for discord 😌.

??? Just update it when the hp updates or do you use _process for everything? To use this plugin you must understand godot. Sorry if i sound rude

??? Just update it when the hp updates or do you use _process for everything? To use this plugin you must understand godot. Sorry if i sound rude
k120F commented 2024-08-15 17:25:10 +00:00 (Migrated from github.com)

Hello again.
I've fixed that problem :)

Hello again. I've fixed that problem :)
Sign in to join this conversation.
No description provided.