kuylar / discord-embedded-godot

Godot library/plugin to use the Discord Embedded App SDK in Godot apps
MIT License
25 stars 2 forks source link

[4.3beta2] "Not in a JavaScript environment. Discord SDK will not work." error #3

Open cyberaspect opened 5 days ago

cyberaspect commented 5 days ago

First off, this is really great work you've done here for us Godot devs. Hats off to you! But, I couldn't get this working on my machine (Windows 11)

When running the sample project (godot-4 branch of the repo) in Godot 4.3beta2 I got this output:

Godot Engine v4.3.beta2.official.b75f0485b - https://godotengine.org
Vulkan 1.3.215 - Forward+ - Using Device #0: Intel - Intel(R) UHD Graphics

Not in a JavaScript environment. Discord SDK will not work.
Not in a JavaScript environment. Ignoring call to init()

and the debug window is stuck on "Waiting for ready()."

I have edited debug.gd to use my application's id but that is all

# ...
var clientID = "1255664010825695242"
        # ...
    discord.init(clientID)
    text.text += "\nWaiting for ready()"
        # ...
    text.text += "\nGetting access token from server"
        # ...
    var token_res = hreq.request(
        "https://"+clientID+".discordsays.com/api/auth",
        ["Content-Type: application/x-www-form-urlencoded"],
        HTTPClient.METHOD_POST,
        "code=" + auth["code"]
    )

I could be doing something wrong, so please let me know if you believe it's a user-issue.

kuylar commented 5 days ago

Looks like the environment check is failing (havent tested this on newer betas 😅). For now, you can edit DiscordSDK.gd line 87 to be true.

It was added so if you were working outside Discord, the debugger wouldn't stop there. It's safe to make it always be true

cyberaspect commented 4 days ago

Thanks for the info! I'm still getting a few null instance errors though, so may I ask what version of 4.3 you tested this on?

kuylar commented 3 days ago

Just tested the code again Godot v4.3.beta2.official [b75f0485b] and didn't encounter any null reference errors during my tests in the debug scene, can you tell which functions were throwing the exceptions? Also,