Merge branch 'main' of https://github.com/vaporvee/discord-sdk-godot into polish-2.0
This commit is contained in:
@@ -7,6 +7,7 @@ func _ready():
|
|||||||
discord_sdk.connect("activity_join_request",_on_activity_join_request)
|
discord_sdk.connect("activity_join_request",_on_activity_join_request)
|
||||||
discord_sdk.connect("activity_join",_on_activity_join)
|
discord_sdk.connect("activity_join",_on_activity_join)
|
||||||
discord_sdk.connect("activity_spectate",_on_activity_spectate)
|
discord_sdk.connect("activity_spectate",_on_activity_spectate)
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if(discord_sdk.get_is_discord_working()):
|
if(discord_sdk.get_is_discord_working()):
|
||||||
@@ -14,6 +15,16 @@ func _process(_delta):
|
|||||||
else:
|
else:
|
||||||
$AnimatedSprite2D.play("gray")
|
$AnimatedSprite2D.play("gray")
|
||||||
$AnimatedSprite2D.stop()
|
$AnimatedSprite2D.stop()
|
||||||
|
=======
|
||||||
|
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)
|
||||||
|
>>>>>>> df556e8a72808fd92859cd4421819b2e6fe1926f
|
||||||
|
|
||||||
func _on_http_request_request_completed(_result, _response_code, _headers, _body):
|
func _on_http_request_request_completed(_result, _response_code, _headers, _body):
|
||||||
var image = Image.new()
|
var image = Image.new()
|
||||||
|
@@ -608,8 +608,15 @@ position = Vector2(1127.75, 24.25)
|
|||||||
scale = Vector2(0.100586, 0.100586)
|
scale = Vector2(0.100586, 0.100586)
|
||||||
sprite_frames = SubResource("SpriteFrames_lajjo")
|
sprite_frames = SubResource("SpriteFrames_lajjo")
|
||||||
animation = &"gray"
|
animation = &"gray"
|
||||||
|
offset_top = -4.0
|
||||||
|
offset_right = 136.0
|
||||||
|
offset_bottom = 29.0
|
||||||
|
grow_vertical = 2
|
||||||
|
text = "Get current user"
|
||||||
|
|
||||||
|
|
||||||
[connection signal="toggled" from="CheckButton" to="." method="_on_check_button_toggled"]
|
[connection signal="toggled" from="CheckButton" to="." method="_on_check_button_toggled"]
|
||||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||||
[connection signal="text_submitted" from="LineEdit" to="." method="_on_line_edit_text_submitted"]
|
[connection signal="text_submitted" from="LineEdit" to="." method="_on_line_edit_text_submitted"]
|
||||||
[connection signal="text_submitted" from="LineEdit2" to="." method="_on_line_edit_2_text_submitted"]
|
[connection signal="text_submitted" from="LineEdit2" to="." method="_on_line_edit_2_text_submitted"]
|
||||||
|
[connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"]
|
||||||
|
@@ -93,6 +93,8 @@ void discord_sdk::_bind_methods()
|
|||||||
ClassDB::bind_method(D_METHOD("send_invite", "user_id", "is_spectate", "message_content"), &discord_sdk::send_invite);
|
ClassDB::bind_method(D_METHOD("send_invite", "user_id", "is_spectate", "message_content"), &discord_sdk::send_invite);
|
||||||
ClassDB::bind_method(D_METHOD("accept_invite", "user_id"), &discord_sdk::accept_invite);
|
ClassDB::bind_method(D_METHOD("accept_invite", "user_id"), &discord_sdk::accept_invite);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_current_user"), &discord_sdk::get_current_user);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_is_overlay_enabled"), &discord_sdk::get_is_overlay_enabled);
|
ClassDB::bind_method(D_METHOD("get_is_overlay_enabled"), &discord_sdk::get_is_overlay_enabled);
|
||||||
ClassDB::bind_method(D_METHOD("get_is_overlay_locked"), &discord_sdk::get_is_overlay_locked);
|
ClassDB::bind_method(D_METHOD("get_is_overlay_locked"), &discord_sdk::get_is_overlay_locked);
|
||||||
ClassDB::bind_method(D_METHOD("set_is_overlay_locked", "is_overlay_locked"), &discord_sdk::set_is_overlay_locked);
|
ClassDB::bind_method(D_METHOD("set_is_overlay_locked", "is_overlay_locked"), &discord_sdk::set_is_overlay_locked);
|
||||||
@@ -156,6 +158,10 @@ void discord_sdk::set_app_id(int64_t value)
|
|||||||
|
|
||||||
if (result == discord::Result::Ok && app_id > 0)
|
if (result == discord::Result::Ok && app_id > 0)
|
||||||
{
|
{
|
||||||
|
// initialize currentuser stuff
|
||||||
|
core->UserManager().OnCurrentUserUpdate.Connect([]()
|
||||||
|
{discord::User 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()
|
{ discord_sdk::get_singleton()
|
||||||
@@ -442,6 +448,26 @@ void discord_sdk::register_steam(int32_t value)
|
|||||||
if (result == discord::Result::Ok && app_id > 0)
|
if (result == discord::Result::Ok && app_id > 0)
|
||||||
core->ActivityManager().RegisterSteam(value);
|
core->ActivityManager().RegisterSteam(value);
|
||||||
}
|
}
|
||||||
|
Dictionary discord_sdk::get_current_user()
|
||||||
|
{
|
||||||
|
Dictionary userdict;
|
||||||
|
if (result == discord::Result::Ok && app_id > 0)
|
||||||
|
{
|
||||||
|
discord::User user{};
|
||||||
|
core->UserManager().GetCurrentUser(&user);
|
||||||
|
userdict["avatar"] = user.GetAvatar(); // can be empty when user has no avatar
|
||||||
|
userdict["is_bot"] = user.GetBot();
|
||||||
|
userdict["discriminator"] = user.GetDiscriminator();
|
||||||
|
userdict["id"] = user.GetId();
|
||||||
|
userdict["username"] = user.GetUsername();
|
||||||
|
if (String(userdict["avatar"]).is_empty())
|
||||||
|
userdict["avatar_url"] = String(std::string("https://cdn.discordapp.com/embed/avatars/" + std::to_string((userdict["discriminator"].INT % 5) - 1) + ".png").c_str());
|
||||||
|
else
|
||||||
|
userdict["avatar_url"] = String(std::string("https://cdn.discordapp.com/avatars/" + std::to_string(user.GetId()) + "/" + user.GetAvatar() + ".png?size=512").c_str());
|
||||||
|
userdict.make_read_only();
|
||||||
|
}
|
||||||
|
return userdict;
|
||||||
|
}
|
||||||
|
|
||||||
bool discord_sdk::get_is_discord_working()
|
bool discord_sdk::get_is_discord_working()
|
||||||
{
|
{
|
||||||
|
@@ -110,6 +110,9 @@ public:
|
|||||||
void register_command(String value);
|
void register_command(String value);
|
||||||
void register_steam(int32_t value);
|
void register_steam(int32_t value);
|
||||||
|
|
||||||
|
Dictionary get_current_user();
|
||||||
|
void set_current_user(Dictionary value);
|
||||||
|
|
||||||
bool get_is_discord_working();
|
bool get_is_discord_working();
|
||||||
int get_result_int();
|
int get_result_int();
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user