renamed discord_sdk to DiscordSDK to match the engines naming

This commit is contained in:
2023-12-15 16:00:15 +01:00
parent 899f8f4b02
commit 5cac6404b0
11 changed files with 125 additions and 125 deletions

View File

@@ -11,27 +11,27 @@ extends Node
## [codeblock] ## [codeblock]
## func _ready(): ## func _ready():
## # Application ID ## # Application ID
## discord_sdk.app_id = 1099618430065324082 ## DiscordSDK.app_id = 1099618430065324082
## # this is boolean if everything worked ## # this is boolean if everything worked
## print("Discord working: " + str(discord_sdk.get_is_discord_working())) ## print("Discord working: " + str(DiscordSDK.get_is_discord_working()))
## # Set the first custom text row of the activity here ## # Set the first custom text row of the activity here
## discord_sdk.details = "A demo activity by vaporvee#1231" ## DiscordSDK.details = "A demo activity by vaporvee#1231"
## # Set the second custom text row of the activity here ## # Set the second custom text row of the activity here
## discord_sdk.state = "Checkpoint 23/23" ## DiscordSDK.state = "Checkpoint 23/23"
## # Image key for small image from "Art Assets" from the Discord Developer website ## # Image key for small image from "Art Assets" from the Discord Developer website
## discord_sdk.large_image = "game" ## DiscordSDK.large_image = "game"
## # Tooltip text for the large image ## # Tooltip text for the large image
## discord_sdk.large_image_text = "Try it now!" ## DiscordSDK.large_image_text = "Try it now!"
## # Image key for large image from "Art Assets" from the Discord Developer website ## # Image key for large image from "Art Assets" from the Discord Developer website
## discord_sdk.small_image = "boss" ## DiscordSDK.small_image = "boss"
## # Tooltip text for the small image ## # Tooltip text for the small image
## discord_sdk.small_image_text = "Fighting the end boss! D:" ## DiscordSDK.small_image_text = "Fighting the end boss! D:"
## # "02:41 elapsed" timestamp for the activity ## # "02:41 elapsed" timestamp for the activity
## discord_sdk.start_timestamp = int(Time.get_unix_time_from_system()) ## DiscordSDK.start_timestamp = int(Time.get_unix_time_from_system())
## # "59:59 remaining" timestamp for the activity ## # "59:59 remaining" timestamp for the activity
## discord_sdk.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 ## DiscordSDK.end_timestamp = int(Time.get_unix_time_from_system()) + 3600
## # Always refresh after changing the values! ## # Always refresh after changing the values!
## discord_sdk.refresh() ## DiscordSDK.refresh()
## [/codeblock] ## [/codeblock]
## ##
## @tutorial(More information here): https://github.com/vaporvee/discord-sdk-godot/wiki/Quick-start ## @tutorial(More information here): https://github.com/vaporvee/discord-sdk-godot/wiki/Quick-start

View File

@@ -9,10 +9,10 @@ resource_name = "Debug"
script/source = "extends Node script/source = "extends Node
func _ready(): func _ready():
discord_sdk.connect(\"activity_join_request\",_on_activity_join_request) DiscordSDK.connect(\"activity_join_request\",_on_activity_join_request)
func _process(_delta): func _process(_delta):
if(discord_sdk.get_is_discord_working()): if(DiscordSDK.get_is_discord_working()):
$Panel/TextureRect.self_modulate = Color(\"#3eff8d\") $Panel/TextureRect.self_modulate = Color(\"#3eff8d\")
$Panel/TextureRect/AnimationPlayer.play(\"pulsate\") $Panel/TextureRect/AnimationPlayer.play(\"pulsate\")
debug_text_update() debug_text_update()
@@ -45,7 +45,7 @@ Is party public: {ppublic} (needs to be activated in Discord client settings)
Is instanced: {instanced} Is instanced: {instanced}
\" \"
$Panel/Info.text = $Panel/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)) $Panel/Info.text = $Panel/Info.text.replace(\"{ppublic}\",str(DiscordSDK.is_public_party)).replace(\"{instanced}\",str(DiscordSDK.instanced)).replace(\"{ssecret}\",DiscordSDK.spectate_secret).replace(\"{jsecret}\",DiscordSDK.join_secret).replace(\"{msecret}\",DiscordSDK.match_secret).replace(\"{mpartysize}\",str(DiscordSDK.max_party_size)).replace(\"{cpartysize}\",str(DiscordSDK.current_party_size)).replace(\"{partyid}\",DiscordSDK.party_id).replace(\"{id}\",str(DiscordSDK.app_id)).replace(\"{details}\",DiscordSDK.details).replace(\"{state}\",DiscordSDK.state).replace(\"{lkey}\",DiscordSDK.large_image).replace(\"{ltext}\",DiscordSDK.large_image_text).replace(\"{skey}\",DiscordSDK.small_image).replace(\"{stext}\",DiscordSDK.small_image_text).replace(\"{stimestamp}\",str(DiscordSDK.start_timestamp)).replace(\"{etimestamp}\",str(DiscordSDK.end_timestamp))
var user_request = {}; var user_request = {};
@@ -55,25 +55,25 @@ func _on_activity_join_request(user_requesting):
func _on_accept_join_request_pressed(): func _on_accept_join_request_pressed():
if(!user_request.is_empty()): if(!user_request.is_empty()):
discord_sdk.accept_join_request(user_request.id) DiscordSDK.accept_join_request(user_request.id)
func _on_invite_with_user_id_text_submitted(new_text): func _on_invite_with_user_id_text_submitted(new_text):
discord_sdk.send_invite(int(new_text),true,\"this is a test invite sent from godot\") DiscordSDK.send_invite(int(new_text),true,\"this is a test invite sent from godot\")
func _on_accept_with_user_id_text_submitted(new_text): func _on_accept_with_user_id_text_submitted(new_text):
discord_sdk.accept_invite(int(new_text)) DiscordSDK.accept_invite(int(new_text))
func _on_print_current_user_on_console_pressed(): func _on_print_current_user_on_console_pressed():
print(discord_sdk.get_current_user()) print(DiscordSDK.get_current_user())
func _on_toggle_sdk_toggled(button_pressed): func _on_toggle_sdk_toggled(button_pressed):
if(button_pressed): if(button_pressed):
discord_sdk.unclear() DiscordSDK.unclear()
else: else:
discord_sdk.clear(false) DiscordSDK.clear(false)
func _on_print_friends_pressed(): func _on_print_friends_pressed():
print(discord_sdk.get_all_relationships()) print(DiscordSDK.get_all_relationships())
" "
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8abo6"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8abo6"]

View File

@@ -1,7 +1,7 @@
## This is a GDscript Node wich gets automatically added as Autoload while installing the addon. ## This is a GDscript Node wich gets automatically added as Autoload while installing the addon.
## ##
## It can run in the background to comunicate with Discord. ## It can run in the background to comunicate with Discord.
## You don't need to use it unless you are using EditorPresence. If you remove it make sure to run [code]discord_sdk.run_callbacks()[/code] in a [code]_process[/code] function. ## You don't need to use it unless you are using EditorPresence. If you remove it make sure to run [code]DiscordSDK.run_callbacks()[/code] in a [code]_process[/code] function.
## ##
## @tutorial: https://github.com/vaporvee/discord-sdk-godot/wiki ## @tutorial: https://github.com/vaporvee/discord-sdk-godot/wiki
@tool @tool
@@ -11,13 +11,13 @@ class_name DiscordSDKLoaderAutoload
func _process(_delta) -> void: func _process(_delta) -> void:
if GDExtensionManager.get_loaded_extensions().has("res://addons/discord-sdk-gd/bin/discord-rpc-gd.gdextension"): if GDExtensionManager.get_loaded_extensions().has("res://addons/discord-sdk-gd/bin/discord-rpc-gd.gdextension"):
if ProjectSettings.get_setting("DiscordSDK/EditorPresence/enabled",false) && Engine.is_editor_hint(): if ProjectSettings.get_setting("DiscordSDK/EditorPresence/enabled",false) && Engine.is_editor_hint():
if discord_sdk.app_id != 1108142249990176808: if DiscordSDK.app_id != 1108142249990176808:
discord_sdk.app_id = 1108142249990176808 DiscordSDK.app_id = 1108142249990176808
discord_sdk.details = ProjectSettings.get_setting("application/config/name") DiscordSDK.details = ProjectSettings.get_setting("application/config/name")
discord_sdk.state = "Editing: \""+ str(get_tree().edited_scene_root.scene_file_path).replace("res://","") +"\"" DiscordSDK.state = "Editing: \""+ str(get_tree().edited_scene_root.scene_file_path).replace("res://","") +"\""
discord_sdk.large_image = "godot" DiscordSDK.large_image = "godot"
discord_sdk.large_image_text = str(Engine.get_version_info().string) DiscordSDK.large_image_text = str(Engine.get_version_info().string)
discord_sdk.start_timestamp = int(Time.get_unix_time_from_system()) DiscordSDK.start_timestamp = int(Time.get_unix_time_from_system())
discord_sdk.refresh() DiscordSDK.refresh()
if discord_sdk.app_id == 1108142249990176808 || !Engine.is_editor_hint(): if DiscordSDK.app_id == 1108142249990176808 || !Engine.is_editor_hint():
discord_sdk.run_callbacks() DiscordSDK.run_callbacks()

View File

@@ -25,7 +25,7 @@ func _on_confirmed():
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5vqdt"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5vqdt"]
[sub_resource type="Image" id="Image_3lxeh"] [sub_resource type="Image" id="Image_3se7o"]
data = { data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 168, 224, 224, 224, 233, 224, 224, 224, 236, 224, 224, 224, 170, 231, 231, 231, 31, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 234, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 239, 230, 230, 230, 30, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 168, 224, 224, 224, 255, 224, 224, 224, 186, 224, 224, 224, 32, 224, 224, 224, 33, 224, 224, 224, 187, 224, 224, 224, 255, 225, 225, 225, 167, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 237, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 255, 224, 224, 224, 234, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 237, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 229, 229, 229, 38, 224, 224, 224, 255, 224, 224, 224, 229, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 164, 224, 224, 224, 255, 224, 224, 224, 187, 225, 225, 225, 34, 227, 227, 227, 36, 224, 224, 224, 192, 224, 224, 224, 255, 224, 224, 224, 162, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 24, 225, 225, 225, 215, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 229, 224, 224, 224, 32, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 24, 224, 224, 224, 216, 224, 224, 224, 255, 224, 224, 224, 210, 224, 224, 224, 161, 224, 224, 224, 232, 224, 224, 224, 231, 225, 225, 225, 159, 230, 230, 230, 30, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 107, 224, 224, 224, 255, 224, 224, 224, 210, 230, 230, 230, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 105, 230, 230, 230, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 221, 224, 224, 224, 130, 255, 255, 255, 1, 255, 255, 255, 1, 225, 225, 225, 134, 224, 224, 224, 224, 225, 225, 225, 223, 224, 224, 224, 132, 255, 255, 255, 1, 255, 255, 255, 6, 224, 224, 224, 137, 224, 224, 224, 231, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 130, 225, 225, 225, 133, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 129, 224, 224, 224, 137, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 65, 224, 224, 224, 255, 224, 224, 224, 220, 225, 225, 225, 223, 224, 224, 224, 255, 226, 226, 226, 61, 224, 224, 224, 65, 224, 224, 224, 255, 224, 224, 224, 222, 224, 224, 224, 231, 224, 224, 224, 255, 227, 227, 227, 62, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 67, 224, 224, 224, 255, 224, 224, 224, 219, 224, 224, 224, 222, 224, 224, 224, 255, 227, 227, 227, 63, 225, 225, 225, 67, 224, 224, 224, 255, 224, 224, 224, 219, 224, 224, 224, 230, 224, 224, 224, 255, 227, 227, 227, 63, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 127, 224, 224, 224, 129, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 126, 225, 225, 225, 135, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 221, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 1, 224, 224, 224, 128, 224, 224, 224, 220, 224, 224, 224, 219, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 5, 225, 225, 225, 134, 224, 224, 224, 229, 224, 224, 224, 255, 255, 255, 255, 0), "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 168, 224, 224, 224, 233, 224, 224, 224, 236, 224, 224, 224, 170, 231, 231, 231, 31, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 234, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 239, 230, 230, 230, 30, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 168, 224, 224, 224, 255, 224, 224, 224, 186, 224, 224, 224, 32, 224, 224, 224, 33, 224, 224, 224, 187, 224, 224, 224, 255, 225, 225, 225, 167, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 237, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 255, 224, 224, 224, 234, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 237, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 229, 229, 229, 38, 224, 224, 224, 255, 224, 224, 224, 229, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 164, 224, 224, 224, 255, 224, 224, 224, 187, 225, 225, 225, 34, 227, 227, 227, 36, 224, 224, 224, 192, 224, 224, 224, 255, 224, 224, 224, 162, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 24, 225, 225, 225, 215, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 229, 224, 224, 224, 32, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 24, 224, 224, 224, 216, 224, 224, 224, 255, 224, 224, 224, 210, 224, 224, 224, 161, 224, 224, 224, 232, 224, 224, 224, 231, 225, 225, 225, 159, 230, 230, 230, 30, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 107, 224, 224, 224, 255, 224, 224, 224, 210, 230, 230, 230, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 105, 230, 230, 230, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 221, 224, 224, 224, 130, 255, 255, 255, 1, 255, 255, 255, 1, 225, 225, 225, 134, 224, 224, 224, 224, 225, 225, 225, 223, 224, 224, 224, 132, 255, 255, 255, 1, 255, 255, 255, 6, 224, 224, 224, 137, 224, 224, 224, 231, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 130, 225, 225, 225, 133, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 129, 224, 224, 224, 137, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 65, 224, 224, 224, 255, 224, 224, 224, 220, 225, 225, 225, 223, 224, 224, 224, 255, 226, 226, 226, 61, 224, 224, 224, 65, 224, 224, 224, 255, 224, 224, 224, 222, 224, 224, 224, 231, 224, 224, 224, 255, 227, 227, 227, 62, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 67, 224, 224, 224, 255, 224, 224, 224, 219, 224, 224, 224, 222, 224, 224, 224, 255, 227, 227, 227, 63, 225, 225, 225, 67, 224, 224, 224, 255, 224, 224, 224, 219, 224, 224, 224, 230, 224, 224, 224, 255, 227, 227, 227, 63, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 127, 224, 224, 224, 129, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 126, 225, 225, 225, 135, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 221, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 1, 224, 224, 224, 128, 224, 224, 224, 220, 224, 224, 224, 219, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 5, 225, 225, 225, 134, 224, 224, 224, 229, 224, 224, 224, 255, 255, 255, 255, 0),
"format": "RGBA8", "format": "RGBA8",
@@ -35,7 +35,7 @@ data = {
} }
[sub_resource type="ImageTexture" id="ImageTexture_gdtpn"] [sub_resource type="ImageTexture" id="ImageTexture_gdtpn"]
image = SubResource("Image_3lxeh") image = SubResource("Image_3se7o")
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_7v0rg"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_7v0rg"]

View File

@@ -2,40 +2,40 @@ extends Node
func _ready() -> void: func _ready() -> void:
set_activity() set_activity()
discord_sdk.connect("activity_join_request",_on_activity_join_request) DiscordSDK.connect("activity_join_request",_on_activity_join_request)
discord_sdk.connect("activity_join",_on_activity_join) DiscordSDK.connect("activity_join",_on_activity_join)
discord_sdk.connect("activity_spectate",_on_activity_spectate) DiscordSDK.connect("activity_spectate",_on_activity_spectate)
discord_sdk.connect("relationships_init",_on_relationship_init) DiscordSDK.connect("relationships_init",_on_relationship_init)
discord_sdk.connect("updated_relationship", _on_updated_relationship) DiscordSDK.connect("updated_relationship", _on_updated_relationship)
func set_activity() -> void: func set_activity() -> void:
discord_sdk.clear(false) DiscordSDK.clear(false)
discord_sdk.app_id = 1099618430065324082 DiscordSDK.app_id = 1099618430065324082
discord_sdk.details = "A demo activity by vaporvee#1231" DiscordSDK.details = "A demo activity by vaporvee#1231"
discord_sdk.state = "Checkpoint 23/23" DiscordSDK.state = "Checkpoint 23/23"
discord_sdk.large_image = "example_game" DiscordSDK.large_image = "example_game"
discord_sdk.large_image_text = "Try it now!" DiscordSDK.large_image_text = "Try it now!"
discord_sdk.small_image = "boss" DiscordSDK.small_image = "boss"
discord_sdk.small_image_text = "Fighting the end boss! D:" DiscordSDK.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 DiscordSDK.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
# It is NOT recommended to manage secrets locally! It's meant to be a payload wich the server understands and # 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. # returns the other variables like current_party_size, party_id etc. Most of the values must differ from the others.
var my_secret: String = str(randi_range(0,999999)) var my_secret: String = str(randi_range(0,999999))
discord_sdk.party_id = "mylobbycanbeeverything_" + my_secret DiscordSDK.party_id = "mylobbycanbeeverything_" + my_secret
discord_sdk.current_party_size = 1 DiscordSDK.current_party_size = 1
discord_sdk.max_party_size = 4 DiscordSDK.max_party_size = 4
discord_sdk.match_secret = "m_" + my_secret #better use seeds with 1 to 1 range instead of just chars DiscordSDK.match_secret = "m_" + my_secret #better use seeds with 1 to 1 range instead of just chars
discord_sdk.join_secret = "j_" + my_secret DiscordSDK.join_secret = "j_" + my_secret
discord_sdk.spectate_secret = "s_" + my_secret DiscordSDK.spectate_secret = "s_" + my_secret
discord_sdk.is_public_party = true DiscordSDK.is_public_party = true
discord_sdk.instanced = true #required for spectate DiscordSDK.instanced = true #required for spectate
#discord_sdk.start_timestamp = int(Time.get_unix_time_from_system()) #DiscordSDK.start_timestamp = int(Time.get_unix_time_from_system())
discord_sdk.register_command(r"C:\Users\yanni\Desktop\demo\discord_sdk.exe") DiscordSDK.register_command(r"C:\Users\yanni\Desktop\demo\DiscordSDK.exe")
#discord_sdk.register_steam(1389990) #DiscordSDK.register_steam(1389990)
discord_sdk.refresh() DiscordSDK.refresh()
var user_request: Dictionary; var user_request: Dictionary;
@@ -44,13 +44,13 @@ func _on_activity_join_request(user_requesting) -> void:
user_request = user_requesting user_request = user_requesting
func _on_activity_join(secret) -> void: func _on_activity_join(secret) -> void:
if(discord_sdk.join_secret != secret): if(DiscordSDK.join_secret != secret):
discord_sdk.current_party_size = clamp(int(secret) + 1, 0, discord_sdk.max_party_size) DiscordSDK.current_party_size = clamp(int(secret) + 1, 0, DiscordSDK.max_party_size)
discord_sdk.party_id = secret.replace("j_","mylobbycanbeeverything_") DiscordSDK.party_id = secret.replace("j_","mylobbycanbeeverything_")
discord_sdk.match_secret = secret.replace("j_","m_") DiscordSDK.match_secret = secret.replace("j_","m_")
discord_sdk.join_secret = secret DiscordSDK.join_secret = secret
discord_sdk.spectate_secret = secret.replace("j_","s_") DiscordSDK.spectate_secret = secret.replace("j_","s_")
discord_sdk.refresh() DiscordSDK.refresh()
func _on_activity_spectate(secret) -> void: func _on_activity_spectate(secret) -> void:
print(secret) print(secret)

View File

@@ -3,27 +3,27 @@
#include <godot_cpp/core/class_db.hpp> #include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/variant/utility_functions.hpp> #include <godot_cpp/variant/utility_functions.hpp>
#define BIND_METHOD(method, ...) godot::ClassDB::bind_method(D_METHOD(#method, ##__VA_ARGS__), &discord_sdk::method) #define BIND_METHOD(method, ...) godot::ClassDB::bind_method(D_METHOD(#method, ##__VA_ARGS__), &DiscordSDK::method)
#define BIND_SET_GET(property_name, variant_type) \ #define BIND_SET_GET(property_name, variant_type) \
godot::ClassDB::bind_method(D_METHOD("get_" #property_name), &discord_sdk::get_##property_name); \ godot::ClassDB::bind_method(D_METHOD("get_" #property_name), &DiscordSDK::get_##property_name); \
godot::ClassDB::bind_method(D_METHOD("set_" #property_name, #variant_type), &discord_sdk::set_##property_name); \ godot::ClassDB::bind_method(D_METHOD("set_" #property_name, #variant_type), &DiscordSDK::set_##property_name); \
godot::ClassDB::add_property(get_class_static(), PropertyInfo(variant_type, #property_name), "set_" #property_name, "get_" #property_name) godot::ClassDB::add_property(get_class_static(), PropertyInfo(variant_type, #property_name), "set_" #property_name, "get_" #property_name)
#define BIND_SIGNAL(signal_name, ...) godot::ClassDB::add_signal(get_class_static(), MethodInfo(#signal_name, ##__VA_ARGS__)) #define BIND_SIGNAL(signal_name, ...) godot::ClassDB::add_signal(get_class_static(), MethodInfo(#signal_name, ##__VA_ARGS__))
#define SET_GET(variable, setter, ...) /*getter isn't mandatory for this project*/ \ #define SET_GET(variable, setter, ...) /*getter isn't mandatory for this project*/ \
decltype(discord_sdk::variable) discord_sdk::get_##variable() { return variable; } \ decltype(DiscordSDK::variable) DiscordSDK::get_##variable() { return variable; } \
void discord_sdk::set_##variable(decltype(discord_sdk::variable) value) \ void DiscordSDK::set_##variable(decltype(DiscordSDK::variable) value) \
{ \ { \
variable = value; \ variable = value; \
setter; \ setter; \
} }
discord_sdk *discord_sdk::singleton = nullptr; DiscordSDK *DiscordSDK::singleton = nullptr;
discord::Core *core{}; discord::Core *core{};
discord::Result result; discord::Result result;
discord::Activity activity{}; discord::Activity activity{};
discord::User user{}; discord::User user{};
void discord_sdk::_bind_methods() void DiscordSDK::_bind_methods()
{ {
BIND_SET_GET(app_id, Variant::INT); BIND_SET_GET(app_id, Variant::INT);
BIND_SET_GET(state, Variant::STRING); BIND_SET_GET(state, Variant::STRING);
@@ -51,7 +51,7 @@ void discord_sdk::_bind_methods()
BIND_METHOD(debug); BIND_METHOD(debug);
BIND_METHOD(run_callbacks); BIND_METHOD(run_callbacks);
BIND_METHOD(refresh); BIND_METHOD(refresh);
ClassDB::bind_method(D_METHOD("clear", "reset_values"), &discord_sdk::clear, DEFVAL(false)); ClassDB::bind_method(D_METHOD("clear", "reset_values"), &DiscordSDK::clear, DEFVAL(false));
BIND_METHOD(unclear); BIND_METHOD(unclear);
BIND_METHOD(register_command, "command"); BIND_METHOD(register_command, "command");
BIND_METHOD(register_steam, "steam_id"); BIND_METHOD(register_steam, "steam_id");
@@ -85,29 +85,29 @@ SET_GET(spectate_secret, activity.GetSecrets().SetSpectate(value.utf8().get_data
SET_GET(instanced, activity.SetInstance(value)) SET_GET(instanced, activity.SetInstance(value))
SET_GET(is_public_party, activity.GetParty().SetPrivacy(static_cast<discord::ActivityPartyPrivacy>(value))) SET_GET(is_public_party, activity.GetParty().SetPrivacy(static_cast<discord::ActivityPartyPrivacy>(value)))
discord_sdk::discord_sdk() DiscordSDK::DiscordSDK()
{ {
singleton = this; singleton = this;
} }
discord_sdk::~discord_sdk() DiscordSDK::~DiscordSDK()
{ {
singleton = nullptr; singleton = nullptr;
delete core; // couldn't use destructor because it would not compile on linux delete core; // couldn't use destructor because it would not compile on linux
core = nullptr; core = nullptr;
} }
discord_sdk *discord_sdk::get_singleton() DiscordSDK *DiscordSDK::get_singleton()
{ {
return singleton; return singleton;
} }
void discord_sdk::run_callbacks() void DiscordSDK::run_callbacks()
{ {
if (result == discord::Result::Ok && app_id > 0) if (result == discord::Result::Ok && app_id > 0)
::core->RunCallbacks(); ::core->RunCallbacks();
} }
void discord_sdk::debug() void DiscordSDK::debug()
{ {
result = discord::Core::Create(1080224638845591692, DiscordCreateFlags_NoRequireDiscord, &core); result = discord::Core::Create(1080224638845591692, DiscordCreateFlags_NoRequireDiscord, &core);
activity.SetState("Test from Godot!"); activity.SetState("Test from Godot!");
@@ -125,7 +125,7 @@ void discord_sdk::debug()
UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!"); UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!");
} }
void discord_sdk::set_app_id(int64_t value) void DiscordSDK::set_app_id(int64_t value)
{ {
app_id = value; app_id = value;
if (app_id > 0) if (app_id > 0)
@@ -140,34 +140,34 @@ void discord_sdk::set_app_id(int64_t value)
core->UserManager().GetCurrentUser(&user); }); core->UserManager().GetCurrentUser(&user); });
// signals // signals
core->ActivityManager().OnActivityJoin.Connect([](const char *secret) core->ActivityManager().OnActivityJoin.Connect([](const char *secret)
{ discord_sdk::get_singleton() { DiscordSDK::get_singleton()
->emit_signal("activity_join", secret); }); ->emit_signal("activity_join", secret); });
core->ActivityManager().OnActivitySpectate.Connect([](const char *secret) core->ActivityManager().OnActivitySpectate.Connect([](const char *secret)
{ discord_sdk::get_singleton() { DiscordSDK::get_singleton()
->emit_signal("activity_spectate", secret); }); ->emit_signal("activity_spectate", secret); });
core->ActivityManager().OnActivityJoinRequest.Connect([this](discord::User const &user) core->ActivityManager().OnActivityJoinRequest.Connect([this](discord::User const &user)
{ discord_sdk::get_singleton() { DiscordSDK::get_singleton()
->emit_signal("activity_join_request", user2dict(user)); }); ->emit_signal("activity_join_request", user2dict(user)); });
core->OverlayManager().OnToggle.Connect([](bool is_locked) core->OverlayManager().OnToggle.Connect([](bool is_locked)
{ discord_sdk::get_singleton() { DiscordSDK::get_singleton()
->emit_signal("overlay_toggle", is_locked); }); ->emit_signal("overlay_toggle", is_locked); });
core->RelationshipManager().OnRefresh.Connect([&]() core->RelationshipManager().OnRefresh.Connect([&]()
{ discord_sdk::get_singleton() { DiscordSDK::get_singleton()
->emit_signal("relationships_init"); }); ->emit_signal("relationships_init"); });
core->RelationshipManager().OnRelationshipUpdate.Connect([&](discord::Relationship const &relationship) core->RelationshipManager().OnRelationshipUpdate.Connect([&](discord::Relationship const &relationship)
{ discord_sdk::get_singleton() { DiscordSDK::get_singleton()
->emit_signal("updated_relationship", relationship2dict(relationship)); }); ->emit_signal("updated_relationship", relationship2dict(relationship)); });
} }
} }
} }
int64_t discord_sdk::get_app_id() int64_t DiscordSDK::get_app_id()
{ {
if (app_id != 0) if (app_id != 0)
return app_id; return app_id;
return old_app_id; return old_app_id;
} }
void discord_sdk::refresh() void DiscordSDK::refresh()
{ {
if (get_is_discord_working()) if (get_is_discord_working())
{ {
@@ -179,7 +179,7 @@ void discord_sdk::refresh()
UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!"); UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!");
} }
void discord_sdk::clear(bool reset_values = false) void DiscordSDK::clear(bool reset_values = false)
{ {
if (get_is_discord_working()) if (get_is_discord_working())
{ {
@@ -212,7 +212,7 @@ void discord_sdk::clear(bool reset_values = false)
} }
} }
void discord_sdk::unclear() void DiscordSDK::unclear()
{ {
if (old_app_id > 0) if (old_app_id > 0)
{ {
@@ -224,69 +224,69 @@ void discord_sdk::unclear()
UtilityFunctions::push_warning("Discord Activity couldn't be uncleared. Maybe it didn't get cleared before?"); UtilityFunctions::push_warning("Discord Activity couldn't be uncleared. Maybe it didn't get cleared before?");
} }
bool discord_sdk::get_is_overlay_enabled() bool DiscordSDK::get_is_overlay_enabled()
{ {
bool ie; bool ie;
if (get_is_discord_working()) if (get_is_discord_working())
core->OverlayManager().IsEnabled(&ie); core->OverlayManager().IsEnabled(&ie);
return ie; return ie;
} }
bool discord_sdk::get_is_overlay_locked() bool DiscordSDK::get_is_overlay_locked()
{ {
bool il; bool il;
if (get_is_discord_working()) if (get_is_discord_working())
core->OverlayManager().IsLocked(&il); core->OverlayManager().IsLocked(&il);
return il; return il;
} }
void discord_sdk::set_is_overlay_locked(bool value) void DiscordSDK::set_is_overlay_locked(bool value)
{ {
is_overlay_locked = value; is_overlay_locked = value;
if (get_is_discord_working()) if (get_is_discord_working())
core->OverlayManager().SetLocked(value, {}); core->OverlayManager().SetLocked(value, {});
} }
void discord_sdk::open_invite_overlay(bool is_spectate) void DiscordSDK::open_invite_overlay(bool is_spectate)
{ {
if (get_is_discord_working()) if (get_is_discord_working())
core->OverlayManager().OpenActivityInvite(static_cast<discord::ActivityActionType>(is_spectate + 1), {}); core->OverlayManager().OpenActivityInvite(static_cast<discord::ActivityActionType>(is_spectate + 1), {});
} }
void discord_sdk::open_server_invite_overlay(String invite_code) void DiscordSDK::open_server_invite_overlay(String invite_code)
{ {
if (get_is_discord_working()) if (get_is_discord_working())
core->OverlayManager().OpenGuildInvite(invite_code.utf8().get_data(), {}); core->OverlayManager().OpenGuildInvite(invite_code.utf8().get_data(), {});
} }
void discord_sdk::open_voice_settings() void DiscordSDK::open_voice_settings()
{ {
if (get_is_discord_working()) if (get_is_discord_working())
core->OverlayManager().OpenVoiceSettings({}); core->OverlayManager().OpenVoiceSettings({});
} }
void discord_sdk::accept_join_request(int64_t user_id) void DiscordSDK::accept_join_request(int64_t user_id)
{ {
if (get_is_discord_working()) if (get_is_discord_working())
core->ActivityManager().SendRequestReply(user_id, static_cast<discord::ActivityJoinRequestReply>(1), {}); core->ActivityManager().SendRequestReply(user_id, static_cast<discord::ActivityJoinRequestReply>(1), {});
} }
void discord_sdk::send_invite(int64_t user_id, bool is_spectate = false, String message_content = "") void DiscordSDK::send_invite(int64_t user_id, bool is_spectate = false, String message_content = "")
{ {
if (get_is_discord_working()) if (get_is_discord_working())
core->ActivityManager().SendInvite(user_id, static_cast<discord::ActivityActionType>(is_spectate + 1), message_content.utf8().get_data(), {}); core->ActivityManager().SendInvite(user_id, static_cast<discord::ActivityActionType>(is_spectate + 1), message_content.utf8().get_data(), {});
} }
void discord_sdk::accept_invite(int64_t user_id) void DiscordSDK::accept_invite(int64_t user_id)
{ {
if (get_is_discord_working()) if (get_is_discord_working())
core->ActivityManager().AcceptInvite(user_id, {}); core->ActivityManager().AcceptInvite(user_id, {});
} }
void discord_sdk::register_command(String value) void DiscordSDK::register_command(String value)
{ {
if (get_is_discord_working()) if (get_is_discord_working())
core->ActivityManager().RegisterCommand(value.utf8().get_data()); core->ActivityManager().RegisterCommand(value.utf8().get_data());
} }
void discord_sdk::register_steam(int32_t value) void DiscordSDK::register_steam(int32_t value)
{ {
if (get_is_discord_working()) if (get_is_discord_working())
core->ActivityManager().RegisterSteam(value); core->ActivityManager().RegisterSteam(value);
} }
Dictionary discord_sdk::get_current_user() Dictionary DiscordSDK::get_current_user()
{ {
Dictionary userdict; Dictionary userdict;
if (get_is_discord_working()) if (get_is_discord_working())
@@ -298,7 +298,7 @@ Dictionary discord_sdk::get_current_user()
return userdict; return userdict;
} }
Dictionary discord_sdk::get_relationship(int64_t user_id) Dictionary DiscordSDK::get_relationship(int64_t user_id)
{ {
if (get_is_discord_working()) if (get_is_discord_working())
{ {
@@ -310,7 +310,7 @@ Dictionary discord_sdk::get_relationship(int64_t user_id)
return dict; return dict;
} }
Array discord_sdk::get_all_relationships() Array DiscordSDK::get_all_relationships()
{ {
Array all_relationships; Array all_relationships;
core->RelationshipManager().Filter( core->RelationshipManager().Filter(
@@ -327,12 +327,12 @@ Array discord_sdk::get_all_relationships()
return all_relationships; return all_relationships;
} }
int discord_sdk::get_result_int() int DiscordSDK::get_result_int()
{ {
return static_cast<int>(result); return static_cast<int>(result);
} }
Dictionary discord_sdk::user2dict(discord::User user) Dictionary DiscordSDK::user2dict(discord::User user)
{ {
Dictionary userdict; Dictionary userdict;
userdict["avatar"] = user.GetAvatar(); // can be empty when user has no avatar userdict["avatar"] = user.GetAvatar(); // can be empty when user has no avatar
@@ -348,7 +348,7 @@ Dictionary discord_sdk::user2dict(discord::User user)
return userdict; return userdict;
} }
Dictionary discord_sdk::relationship2dict(discord::Relationship relationship) Dictionary DiscordSDK::relationship2dict(discord::Relationship relationship)
{ {
Dictionary dict_relationship; Dictionary dict_relationship;
Dictionary presence; Dictionary presence;
@@ -420,7 +420,7 @@ Dictionary discord_sdk::relationship2dict(discord::Relationship relationship)
return dict_relationship; return dict_relationship;
} }
bool discord_sdk::get_is_discord_working() bool DiscordSDK::get_is_discord_working()
{ {
return result == discord::Result::Ok && app_id > 0; return result == discord::Result::Ok && app_id > 0;
} }

View File

@@ -13,21 +13,21 @@
using namespace godot; using namespace godot;
class discord_sdk : public Object class DiscordSDK : public Object
{ {
GDCLASS(discord_sdk, Object); GDCLASS(DiscordSDK, Object);
static discord_sdk *singleton; static DiscordSDK *singleton;
protected: protected:
static void _bind_methods(); static void _bind_methods();
public: public:
static discord_sdk * static DiscordSDK *
get_singleton(); get_singleton();
discord_sdk(); DiscordSDK();
~discord_sdk(); ~DiscordSDK();
// INTERBNAL // INTERBNAL
int64_t old_app_id; int64_t old_app_id;

View File

@@ -9,15 +9,15 @@
#include "discordgodot.h" #include "discordgodot.h"
using namespace godot; using namespace godot;
static discord_sdk *discordsdk; static DiscordSDK *discordsdk;
void initialize_discordsdk_module(ModuleInitializationLevel p_level) void initialize_discordsdk_module(ModuleInitializationLevel p_level)
{ {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
{ {
ClassDB::register_class<discord_sdk>(); ClassDB::register_class<DiscordSDK>();
discordsdk = memnew(discord_sdk); discordsdk = memnew(DiscordSDK);
Engine::get_singleton()->register_singleton("discord_sdk", discord_sdk::get_singleton()); Engine::get_singleton()->register_singleton("DiscordSDK", DiscordSDK::get_singleton());
} }
} }
@@ -25,7 +25,7 @@ void uninitialize_discordsdk_module(ModuleInitializationLevel p_level)
{ {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
{ {
Engine::get_singleton()->unregister_singleton("discord_sdk"); Engine::get_singleton()->unregister_singleton("DiscordSDK");
} }
} }