kateonbxsh / DiscordPresency

Discord Rich Presence Extension for GameMaker
0 stars 0 forks source link

Discord presence doesn't update #1

Open JohnMX1 opened 1 month ago

JohnMX1 commented 1 month ago

If needed here is the code:

discord_step();

var presence = new DiscordPresence();
presence.setText(details, text);
presence.setTimestamp(DISCORDTIMESTAMP.startTime, discord_timestamp_now());
presence.setImageInfo("largeimg", "largeimg", "Game Icon", "Also Game Icon");
presence.setSecrets("Do not join", "You Can't", "...");
presence.setAutoUpdate(true);
JohnMX1 commented 1 month ago

The code provided is in the step event

kateonbxsh commented 1 month ago

Did you make sure to call discord_initialize ?

JohnMX1 commented 1 month ago

Did you make sure to call discord_initialize ?

Yes it is on create event

JohnMX1 commented 1 month ago

Here is the create event

discord_create();
discord_initialize("1271977845178241045");

global.language = os_get_language();

text = "Basic Text";//Will be changed on room start event.
details = "Basic Text too";//Will be changed on room start event.
kateonbxsh commented 1 month ago

so your code here

var presence = new DiscordPresence();
presence.setText(details, text);
presence.setTimestamp(DISCORDTIMESTAMP.startTime, discord_timestamp_now());
presence.setImageInfo("largeimg", "largeimg", "Game Icon", "Also Game Icon");
presence.setSecrets("Do not join", "You Can't", "...");
presence.setAutoUpdate(true);

creates a presence, but doesn't push it to discord, even if you're setting auto update, because you're only setting the auto update AFTER making the changes the ideal thing is to create the presence and right away set auto update to true, only then, any changes to your presence will be pushed to Discord

another thing is, updating the presence unconditionally in the step event is not recommended (unless you want it to be dynamic), you're sending the presence every frame, and in your code you're setting the startTime to discord_get_timestamp_now(), which will keep setting the start time of the "Elapsed" functionallity to the current time, every frame. the "elapsed" functionality only needs WHEN the elapsing started, and doesn't need to be updated every frame

for now, just to make sure it all works, you can keep it in the step event, but change it to:

var presence = new DiscordPresence();
presence.setAutoUpdate(true);
presence.setText(details, text);
presence.setTimestamp(DISCORDTIMESTAMP.startTime, discord_timestamp_now());
presence.setImageInfo("largeimg", "largeimg", "Game Icon", "Also Game Icon");
presence.setSecrets("Do not join", "You Can't", "...");
JohnMX1 commented 1 month ago

so your code here

var presence = new DiscordPresence();
presence.setText(details, text);
presence.setTimestamp(DISCORDTIMESTAMP.startTime, discord_timestamp_now());
presence.setImageInfo("largeimg", "largeimg", "Game Icon", "Also Game Icon");
presence.setSecrets("Do not join", "You Can't", "...");
presence.setAutoUpdate(true);

creates a presence, but doesn't push it to discord, even if you're setting auto update, because you're only setting the auto update AFTER making the changes the ideal thing is to create the presence and right away set auto update to true, only then, any changes to your presence will be pushed to Discord

another thing is, updating the presence unconditionally in the step event is not recommended (unless you want it to be dynamic), you're sending the presence every frame, and in your code you're setting the startTime to discord_get_timestamp_now(), which will keep setting the start time of the "Elapsed" functionallity to the current time, every frame. the "elapsed" functionality only needs WHEN the elapsing started, and doesn't need to be updated every frame

for now, just to make sure it all works, you can keep it in the step event, but change it to:

var presence = new DiscordPresence();
presence.setAutoUpdate(true);
presence.setText(details, text);
presence.setTimestamp(DISCORDTIMESTAMP.startTime, discord_timestamp_now());
presence.setImageInfo("largeimg", "largeimg", "Game Icon", "Also Game Icon");
presence.setSecrets("Do not join", "You Can't", "...");

Thank you very much! I will try it right now