Merge branch 'discord-social-sdk' of https://github.com/vaporvee/discord-rpc-godot into discord-social-sdk
This commit is contained in:
@@ -3,6 +3,12 @@ extends DiscordConnector
|
||||
func _on_user_connected(access_token: String, refresh_token: String, expires_in: int) -> void:
|
||||
print_debug("Access token: %s \nRefresh Token: %s \nExpires in: %s" % [access_token, refresh_token, expires_in])
|
||||
|
||||
func _on_user_updated() -> void:
|
||||
print_debug("USER UPDATED")
|
||||
await get_tree().create_timer(2).timeout
|
||||
print("oop")
|
||||
$DiscordLobby.create_or_join_lobby("beanis")
|
||||
|
||||
func _on_user_connection_failed(error: String) -> void:
|
||||
push_error("User connection failed! Error: " + error)
|
||||
|
||||
|
1
project/discord_lobby.gd
Normal file
1
project/discord_lobby.gd
Normal file
@@ -0,0 +1 @@
|
||||
extends DiscordLobby
|
1
project/discord_lobby.gd.uid
Normal file
1
project/discord_lobby.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://del0aaf7txxn6
|
@@ -2,6 +2,7 @@
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b3qm246m7pnsx" path="res://assets/Logo_V2.png" id="2_gd222"]
|
||||
[ext_resource type="Script" uid="uid://kmubk5a6i385" path="res://discord_connector.gd" id="3_h2yge"]
|
||||
[ext_resource type="Script" uid="uid://del0aaf7txxn6" path="res://discord_lobby.gd" id="4_1bvp3"]
|
||||
[ext_resource type="Script" uid="uid://46tue7u6crd6" path="res://addons/discord-rpc-gd/nodes/debug.gd" id="6_ujijw"]
|
||||
|
||||
[node name="Node" type="Node"]
|
||||
@@ -51,6 +52,10 @@ script = ExtResource("3_h2yge")
|
||||
[node name="DiscordActivity" type="DiscordActivity" parent="DiscordConnector"]
|
||||
root_connector = NodePath("..")
|
||||
|
||||
[node name="DiscordLobby" type="DiscordLobby" parent="DiscordConnector"]
|
||||
root_connector = NodePath("..")
|
||||
script = ExtResource("4_1bvp3")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(789, 330.5)
|
||||
scale = Vector2(0.408203, 0.408203)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <godot_cpp/godot.hpp>
|
||||
|
||||
static const char *_doc_data_hash = "8311200392454987859";
|
||||
static const char *_doc_data_hash = "8781033133787346433";
|
||||
static const int _doc_data_uncompressed_size = 4148;
|
||||
static const int _doc_data_compressed_size = 684;
|
||||
static const unsigned char _doc_data_compressed[] = {
|
||||
|
@@ -81,7 +81,7 @@ void DiscordConnector::_ready()
|
||||
|
||||
void DiscordConnector::_process(double delta)
|
||||
{
|
||||
if (!Engine::get_singleton()->is_editor_hint() && !editor_process)
|
||||
if (!Engine::get_singleton()->is_editor_hint() && !editor_process && client)
|
||||
{
|
||||
discordpp::RunCallbacks();
|
||||
}
|
||||
|
16
src/nodes/discord_linked_channel.cpp
Normal file
16
src/nodes/discord_linked_channel.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "discord_linked_channel.h"
|
||||
|
||||
void DiscordLinkedChannel ::_bind_methods()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DiscordLinkedChannel::DiscordLinkedChannel ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DiscordLinkedChannel::~DiscordLinkedChannel()
|
||||
{
|
||||
|
||||
}
|
20
src/nodes/discord_linked_channel.h
Normal file
20
src/nodes/discord_linked_channel.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef DISCORD_LINKED_CHANNEL_H
|
||||
#define DISCORD_LINKED_CHANNEL_H
|
||||
|
||||
#include "discord_connected.h"
|
||||
|
||||
using namespace godot;
|
||||
|
||||
class DiscordLinkedChannel : public DiscordConnected
|
||||
{
|
||||
GDCLASS(DiscordLinkedChannel, DiscordConnected);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
DiscordLinkedChannel();
|
||||
~DiscordLinkedChannel();
|
||||
};
|
||||
|
||||
#endif
|
31
src/nodes/discord_lobby.cpp
Normal file
31
src/nodes/discord_lobby.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "discord_lobby.h"
|
||||
|
||||
void DiscordLobby ::_bind_methods()
|
||||
{
|
||||
BIND_METHOD(DiscordLobby, create_or_join_lobby, "secret");
|
||||
}
|
||||
|
||||
void DiscordLobby::create_or_join_lobby(String secret) {
|
||||
if (connector) {
|
||||
auto current_client = connector->client;
|
||||
|
||||
current_client->CreateOrJoinLobby(secret.utf8().get_data(),[current_client](discordpp::ClientResult result, uint64_t lobbyId) {
|
||||
if(result.Successful()) {
|
||||
std::cout << "Lobby created or joined successfully! Lobby Id: " << lobbyId << std::endl;
|
||||
} else {
|
||||
std::cout << "Lobby creation/join failed\n" << result.Error().c_str();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
DiscordLobby::DiscordLobby()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DiscordLobby::~DiscordLobby()
|
||||
{
|
||||
|
||||
}
|
||||
|
21
src/nodes/discord_lobby.h
Normal file
21
src/nodes/discord_lobby.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef DISCORD_LOBBY_H
|
||||
#define DISCORD_LOBBY_H
|
||||
|
||||
#include "discord_connected.h"
|
||||
|
||||
using namespace godot;
|
||||
|
||||
class DiscordLobby : public DiscordConnected
|
||||
{
|
||||
GDCLASS(DiscordLobby, DiscordConnected);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void create_or_join_lobby(String secret);
|
||||
DiscordLobby();
|
||||
~DiscordLobby();
|
||||
};
|
||||
|
||||
#endif
|
@@ -15,6 +15,8 @@ void initialize_DiscordUtil_module(ModuleInitializationLevel p_level)
|
||||
ClassDB::register_class<EditorPresence>();
|
||||
ClassDB::register_class<DiscordConnector>();
|
||||
ClassDB::register_abstract_class<DiscordConnected>();
|
||||
ClassDB::register_class<DiscordLobby>();
|
||||
ClassDB::register_class<DiscordLinkedChannel>();
|
||||
ClassDB::register_class<DiscordActivity>();
|
||||
ClassDB::register_class<ActivityResource>();
|
||||
}
|
||||
|
@@ -17,6 +17,8 @@ void uninitialize_DiscordUtil_module();
|
||||
#include "nodes/editor_presence.h"
|
||||
#include "nodes/discord_connector.h"
|
||||
#include "nodes/discord_connected.h"
|
||||
#include "nodes/discord_lobby.h"
|
||||
#include "nodes/discord_linked_channel.h"
|
||||
#include "nodes/discord_activity.h"
|
||||
#include "resources/activity.h"
|
||||
|
||||
|
Reference in New Issue
Block a user