improved demo
This commit is contained in:
@@ -7,20 +7,13 @@ func _ready():
|
||||
discord_sdk.connect("activity_join_request",_on_activity_join_request)
|
||||
discord_sdk.connect("activity_join",_on_activity_join)
|
||||
discord_sdk.connect("activity_spectate",_on_activity_spectate)
|
||||
download_texture("https://cdn.discordapp.com/embed/avatars/1.png", "res://discord_pfp_cache/invitepfp.png")
|
||||
debug_text_update()
|
||||
print(discord_sdk.get_current_user())
|
||||
|
||||
func download_texture(url, file_name):
|
||||
$user_request_avatar/HTTPRequest.download_file = file_name
|
||||
invite_pfp = file_name
|
||||
$user_request_avatar/HTTPRequest.request(url)
|
||||
|
||||
func _on_http_request_request_completed(_result, _response_code, _headers, _body):
|
||||
var image = Image.new()
|
||||
image.load(str(invite_pfp))
|
||||
var texture = ImageTexture.create_from_image(image)
|
||||
$user_request_avatar.texture = texture
|
||||
func _process(_delta):
|
||||
if(discord_sdk.get_is_discord_working()):
|
||||
$AnimatedSprite2D.play("default")
|
||||
else:
|
||||
$AnimatedSprite2D.stop()
|
||||
$AnimatedSprite2D.animation = "gray"
|
||||
|
||||
func set_activity():
|
||||
discord_sdk.app_id = 1099618430065324082
|
||||
@@ -32,7 +25,6 @@ func set_activity():
|
||||
discord_sdk.small_image = "boss"
|
||||
discord_sdk.small_image_text = "Fighting the end boss! D:"
|
||||
discord_sdk.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
|
||||
print(discord_sdk.get_is_overlay_enabled())
|
||||
|
||||
# It is NOT recommended to manage secrets locally! It's meant to be a payload wich the server
|
||||
# understands and returns the other variables like current_party_size, party_id etc. Most of the values must differ from the others.
|
||||
@@ -50,17 +42,38 @@ func set_activity():
|
||||
discord_sdk.register_command("C:\\Users\\yanni\\Desktop\\demo\\discord_sdk.exe")
|
||||
#discord_sdk.register_steam(1389990)
|
||||
discord_sdk.refresh()
|
||||
debug_text_update()
|
||||
|
||||
func debug_text_update():
|
||||
$Info.text = $Info.text.replace("{ssecret}",discord_sdk.spectate_secret).replace("{jsecret}",discord_sdk.join_secret).replace("{msecret}",discord_sdk.match_secret).replace("{mpartysize}",str(discord_sdk.max_party_size)).replace("{cpartysize}",str(discord_sdk.current_party_size)).replace("{partyid}",discord_sdk.party_id).replace("{discordinfo}",str(discord_sdk.get_is_discord_working())).replace("{id}",str(discord_sdk.app_id)).replace("{details}",discord_sdk.details).replace("{state}",discord_sdk.state).replace("{lkey}",discord_sdk.large_image).replace("{ltext}",discord_sdk.large_image_text).replace("{skey}",discord_sdk.small_image).replace("{stext}",discord_sdk.small_image_text).replace("{stimestamp}",str(discord_sdk.start_timestamp)).replace("{etimestamp}",str(discord_sdk.end_timestamp))
|
||||
$Info.text = "Application ID : {id}
|
||||
Details: {details}
|
||||
State: {state}
|
||||
|
||||
Large image key: {lkey}
|
||||
Large image text: {ltext}
|
||||
Small image key: {skey}
|
||||
Small image text: {stext}
|
||||
|
||||
Start timestamp: {stimestamp}
|
||||
End timestamp: {etimestamp}
|
||||
|
||||
Party ID: {partyid}
|
||||
Current party size: {cpartysize}
|
||||
Max party size: {mpartysize}
|
||||
Match secret: {msecret}
|
||||
Join secret: {jsecret}
|
||||
Spectate secret: {ssecret}
|
||||
Is party public: {ppublic} (needs to be activated in Discord client settings)
|
||||
|
||||
Is instanced: {instanced}
|
||||
"
|
||||
$Info.text = $Info.text.replace("{ppublic}",str(discord_sdk.is_public_party)).replace("{instanced}",str(discord_sdk.instanced)).replace("{ssecret}",discord_sdk.spectate_secret).replace("{jsecret}",discord_sdk.join_secret).replace("{msecret}",discord_sdk.match_secret).replace("{mpartysize}",str(discord_sdk.max_party_size)).replace("{cpartysize}",str(discord_sdk.current_party_size)).replace("{partyid}",discord_sdk.party_id).replace("{id}",str(discord_sdk.app_id)).replace("{details}",discord_sdk.details).replace("{state}",discord_sdk.state).replace("{lkey}",discord_sdk.large_image).replace("{ltext}",discord_sdk.large_image_text).replace("{skey}",discord_sdk.small_image).replace("{stext}",discord_sdk.small_image_text).replace("{stimestamp}",str(discord_sdk.start_timestamp)).replace("{etimestamp}",str(discord_sdk.end_timestamp))
|
||||
|
||||
var user_request = {};
|
||||
|
||||
func _on_activity_join_request(user_requesting):
|
||||
print(user_requesting)
|
||||
user_request = user_requesting
|
||||
print(user_requesting.avatar_url)
|
||||
download_texture(user_requesting.avatar_url, "res://discord_pfp_cache/invitepfp.png")
|
||||
|
||||
func _on_activity_join(secret):
|
||||
if(discord_sdk.join_secret != secret):
|
||||
@@ -79,8 +92,10 @@ func _on_activity_spectate(secret):
|
||||
func _on_check_button_toggled(button_pressed):
|
||||
if(button_pressed):
|
||||
set_activity()
|
||||
debug_text_update()
|
||||
else:
|
||||
discord_sdk.clear()
|
||||
debug_text_update()
|
||||
|
||||
func _on_button_pressed():
|
||||
if(!user_request.is_empty()):
|
||||
@@ -88,13 +103,9 @@ func _on_button_pressed():
|
||||
|
||||
func _on_line_edit_text_submitted(new_text):
|
||||
discord_sdk.send_invite(int(new_text),true,"this is a test invite sent from godot")
|
||||
print(int(new_text))
|
||||
|
||||
|
||||
func _on_line_edit_2_text_submitted(new_text):
|
||||
discord_sdk.accept_invite(int(new_text))
|
||||
print(int(new_text))
|
||||
|
||||
|
||||
func _on_button_2_pressed():
|
||||
print(discord_sdk.get_current_user())
|
||||
|
Reference in New Issue
Block a user