All Projects → Lachee → Discord Rpc Csharp

Lachee / Discord Rpc Csharp

Licence: mit
C# custom implementation for Discord Rich Presence. Not deprecated and still available!

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Discord Rpc Csharp

Aim Ik
A Unity-3D library, to procedural orientate character head (and chest) in a direction without using any animation data.
Stars: ✭ 164 (-41.84%)
Mutual labels:  unity, unity3d, library
Unity Editor Toolbox
Tools, custom attributes, drawers, hierarchy overlay, and other extensions for the Unity Editor.
Stars: ✭ 273 (-3.19%)
Mutual labels:  unity, unity3d
Noahgameframe
A fast, scalable, distributed game server engine/framework for C++, include the actor library, network library, can be used as a real time multiplayer game engine ( MMO RPG/MOBA ), which support C#/Lua script/ Unity3d, Cocos2dx and plan to support Unreal.
Stars: ✭ 3,258 (+1055.32%)
Mutual labels:  unity, unity3d
Framework
deprecated, use : https://github.com/CatLib/CatLib
Stars: ✭ 279 (-1.06%)
Mutual labels:  unity, unity3d
Nodebaseddialoguesystem
Node Based Dialogue System for Unity
Stars: ✭ 269 (-4.61%)
Mutual labels:  unity, unity3d
Skyhook
Parses webhooks and forwards them in the proper format to Discord.
Stars: ✭ 263 (-6.74%)
Mutual labels:  unity3d, discord
Ngx
Ngx - Neural network based visual generator and mixer
Stars: ✭ 277 (-1.77%)
Mutual labels:  unity, unity3d
Cloner
An example of use of procedural instancing.
Stars: ✭ 260 (-7.8%)
Mutual labels:  unity, unity3d
Merino
Merino is a narrative design tool that lets you write Yarn scripts inside the Unity Editor
Stars: ✭ 275 (-2.48%)
Mutual labels:  unity, unity3d
Nostrum
Elixir Discord Library
Stars: ✭ 274 (-2.84%)
Mutual labels:  library, discord
Unity Programming Patterns
A collection of programming patterns in Unity with examples when to use them. These are primarily from the book "Game Programming Patterns," but translated from C++ to C#
Stars: ✭ 272 (-3.55%)
Mutual labels:  unity, unity3d
Recyclable Scroll Rect
Recyclable Scroll Rect reuses or recycles the least number of cells required to fill the viewport. As a result a huge number of items can be shown in the list without any performance hit.
Stars: ✭ 262 (-7.09%)
Mutual labels:  unity, unity3d
Riru Il2cppdumper
Using Riru to dump il2cpp data at runtime
Stars: ✭ 259 (-8.16%)
Mutual labels:  unity, unity3d
Uieffect
UIEffect is an effect component for uGUI element in Unity. Let's decorate your UI with effects!
Stars: ✭ 3,449 (+1123.05%)
Mutual labels:  unity, unity3d
Unitynuget
Provides a service to install NuGet packages into a Unity project via the Unity Package Manager
Stars: ✭ 257 (-8.87%)
Mutual labels:  unity, unity3d
Hisocket
It is a lightweight client socket solution, you can used it in C# project or Unity3d
Stars: ✭ 275 (-2.48%)
Mutual labels:  unity, unity3d
Savegamefree
Save Game Free is a free and simple but powerful solution for saving and loading game data in unity.
Stars: ✭ 279 (-1.06%)
Mutual labels:  unity, unity3d
Discordeno
Discord API library for Deno
Stars: ✭ 254 (-9.93%)
Mutual labels:  library, discord
Unmaskforugui
Reverse mask for uGUI element in Unity.
Stars: ✭ 259 (-8.16%)
Mutual labels:  unity, unity3d
Rdsystem
Reaction-diffusion system with CustomRenderTexture.
Stars: ✭ 271 (-3.9%)
Mutual labels:  unity, unity3d

Discord Rich Presence

Build status Codacy Badge Nuget

This is a C# implementation of the Discord RPC library which was originally written in C++. This avoids having to use the official C++ and instead provides a managed way of using the Rich Presence within the .NET environment*.

While the official C++ library has been deprecated, this library has continued support and development for all your Rich Presence need, without requiring the Game SDK.

Here are some key features of this library:

  • Message Queuing
  • Threaded Reads
  • Managed Pipes*
  • Error Handling & Error Checking with automatic reconnects
  • Events from Discord (such as presence update and join requests)
  • Full Rich Presence Implementation (including Join / Spectate)
  • Inline Documented (for all your IntelliSense needs)
  • Helper Functionality (eg: AvatarURL generator from Join Requests)
  • Ghost Prevention (Tells Discord to clear the RP on disposal)
  • Full Unity3D Editor (Contains all the tools, inspectors and helpers for a Unity3D game all in one package).

Documentation

All the documentation can be found lachee.github.io/discord-rpc-csharp/docs/

Installation

Dependencies:

  • Newtonsoft.Json
  • .NET 3.5+

Unity3D Dependencies:

  • Newtonsoft.Json (included in Unity Package).
  • .NET 2.0+ (not subset)
  • Unity Named Pipes Library (included in Unity Package).

Source: .NET Project

For projects that target either .NET Core or .NETFX, you can get the package on nuget:

PM> Install-Package DiscordRichPresence

You can also Download or Build your own version of the library if you have more specific requirements.

Source: Unity3D Game Engine

There is a Unity Package available for quick setup, which includes the editor scripts, managers and tools to make your life 100x easier. Simply download the package from the Artifacts AppVoyer generates. This includes prebuilt native library and the managed library, so you don't need to worry about a thing.

For building your own package, read the building guide.

Usage

The Discord.Example project within the solution contains example code, showing how to use all available features. For Unity Specific examples, check out the example project included. There are 3 important stages of usage, Initialization, Invoking and Deinitialization. It's important you follow all 3 stages to ensure proper behaviour of the library.

Initialization

This stage will setup the connection to Discord and establish the events. Once you have done the initialization you can call SetPresence and other variants as many times as you wish throughout your code. Please note that ideally this should only run once, otherwise conflicts may occur with them trying to access the same Discord client at the same time.

public DiscordRpcClient client;

//Called when your application first starts.
//For example, just before your main loop, on OnEnable for unity.
void Initialize() 
{
	/*
	Create a Discord client
	NOTE: 	If you are using Unity3D, you must use the full constructor and define
			 the pipe connection.
	*/
	client = new DiscordRpcClient("my_client_id");			
	
	//Set the logger
	client.Logger = new ConsoleLogger() { Level = LogLevel.Warning };

	//Subscribe to events
	client.OnReady += (sender, e) =>
	{
		Console.WriteLine("Received Ready from user {0}", e.User.Username);
	};
		
	client.OnPresenceUpdate += (sender, e) =>
	{
		Console.WriteLine("Received Update! {0}", e.Presence);
	};
	
	//Connect to the RPC
	client.Initialize();

	//Set the rich presence
	//Call this as many times as you want and anywhere in your code.
	client.SetPresence(new RichPresence()
	{
		Details = "Example Project",
		State = "csharp example",
		Assets = new Assets()
		{
			LargeImageKey = "image_large",
			LargeImageText = "Lachee's Discord IPC Library",
			SmallImageKey = "image_small"
		}
	});	
}

Invoking

Invoking is optional. Use this when thread safety is paramount.

The client will store messages from the pipe and won't invoke them until you call Invoke() or DequeueMessages(). It does this because the pipe is working on another thread, and manually invoking ensures proper thread safety and order of operations (especially important in Unity3D applications).

In order to enable this method of event calling, you need to set it in the constructor of the DiscordRpcClient under autoEvents.

//The main loop of your application, or some sort of timer. Literally the Update function in Unity3D
void Update() 
{
	//Invoke all the events, such as OnPresenceUpdate
	client.Invoke();
};

Here is an example on how a Timer could be used to invoke the events for a WinForm

var timer = new System.Timers.Timer(150);
timer.Elapsed += (sender, args) => { client.Invoke(); };
timer.Start();

Deinitialization

It's important that you dispose your client before your application terminates. This will stop the threads, abort the pipe reads, and tell Discord to clear the presence. Failure to do so may result in a memory leak!

//Called when your application terminates.
//For example, just after your main loop, on OnDisable for unity.
void Deinitialize() 
{
	client.Dispose();
}

Building

Master

Build status

Nuget

Build status

DiscordRPC Library

You can build the solution easily in Visual Studio, it's a simple matter of right clicking the project and hitting build. However, if you wish to build via command line, you can do so with the PowerShell build script:

.\build.ps1 -target Default -ScriptArgs '-buildType="Release"'

Unity3D

The project does have a Unity Package available on the Artifacts and it is always recommended to use that. Its automatically built and guaranteed to be the latest.

You can build the Unity3D package using the command below. Make sure you update the DiscordRPC.dll within the Unity Project first as it is not automatically updated:

.\build.ps1 -target Default -MakeUnityPackage -ScriptArgs '-buildType="Release"'

If you wish to have barebones Unity3D implementation, you need to build the DiscordRPC.dll, the Unity Named Pipes Library and the UnityNamedPipe.cs. Put these in your own Unity Project and the .dlls in a folder called Plugins.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].