samsface / godot-discord-game-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Godot-Discord-Game-SDK 🥏🎶

Godot Discord Game SDK integration using GDNative. Supports 💰Windows & 🐧Linux.

Getting Started

  1. Download the example project.
  2. Download the Discord Game SDK following the offical Discord Game SDK documenation and extract any .so, .dll or .dylib files into the sample project's addons/discord_game_sdk directory.
  3. Start the sample project! The Godot API is verbatim almost to the offical API so just follow the offical documenation.

Or checkout this little tutorial on getting started:

Watch the video

Snippets

Updating activity

func update_activity() -> void:
	var activity = Discord.Activity.new()
	activity.set_type(Discord.ActivityType.Playing)
	activity.set_state("Reached: 2-2")
	activity.set_details("Loadout: grenade + rail gun")

	var assets = activity.get_assets()
	assets.set_large_image("zone2")
	assets.set_large_text("ZONE 2 WOOO")
	assets.set_small_image("capsule_main")
	assets.set_small_text("ZONE 2 WOOO")

	var result = yield(Discord.activity_manager.update_activity(activity), "result").result
	if result != Discord.Result.Ok:
		push_error(result)

Create lobby

func create_lobby():
	var transaction := Discord.lobby_manager.get_lobby_create_transaction()

	transaction.set_capacity(2)
	transaction.set_type(Discord.LobbyType.Private)
	transaction.set_locked(false)

	var result = yield(Discord.lobby_manager.create_lobby(transaction), "result")
	if result.result != Discord.Result.Ok:
		push_error(result.result)
		return

	var lobby = result.data	
	Discord.lobby_manager.send_lobby_message(lobby.get_id(), "hello people!")

About


Languages

Language:C# 40.6%Language:C++ 35.4%Language:C 19.6%Language:GDScript 3.2%Language:CMake 0.6%Language:Python 0.4%Language:Shell 0.2%