Oops, probably should have committed this lol
This commit is contained in:
51
Assets/Scripts/DiscordRPCHandler.cs
Normal file
51
Assets/Scripts/DiscordRPCHandler.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using DiscordRPC;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class DiscordRPCHandler : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static DiscordRPCHandler Instance;
|
||||||
|
public DiscordRpcClient client;
|
||||||
|
private readonly Timestamps timestamp = Timestamps.Now;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
if (Application.isMobilePlatform || Instance != null)
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance = this;
|
||||||
|
DontDestroyOnLoad(gameObject);
|
||||||
|
|
||||||
|
client = new DiscordRpcClient("1421877993176961155");
|
||||||
|
client.Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnApplicationQuit()
|
||||||
|
{
|
||||||
|
client.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateRPC(string details, string state)
|
||||||
|
{
|
||||||
|
client.SetPresence(new RichPresence
|
||||||
|
{
|
||||||
|
Details = details,
|
||||||
|
State = state,
|
||||||
|
Assets = new Assets
|
||||||
|
{
|
||||||
|
LargeImageKey = "https://berrydash.lncvrt.xyz/assets/icon.png",
|
||||||
|
LargeImageText = "Berry Dash",
|
||||||
|
SmallImageKey = "https://cdn.lncvrt.xyz/pfp.png",
|
||||||
|
SmallImageText = "Made by Lncvrt!"
|
||||||
|
},
|
||||||
|
Buttons = new[]
|
||||||
|
{
|
||||||
|
new Button { Label = "Website", Url = "https://berrydash.lncvrt.xyz" },
|
||||||
|
new Button { Label = "Download", Url = "https://berrydash.lncvrt.xyz/download" }
|
||||||
|
},
|
||||||
|
Timestamps = timestamp
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/DiscordRPCHandler.cs.meta
Normal file
2
Assets/Scripts/DiscordRPCHandler.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 56de20fc3e06f4c9ab65f9280b72723b
|
||||||
14
Assets/Scripts/DiscordRPCUpdater.cs
Normal file
14
Assets/Scripts/DiscordRPCUpdater.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
using DiscordRPC;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class DiscordRPCUpdater : MonoBehaviour
|
||||||
|
{
|
||||||
|
public string details;
|
||||||
|
public string state;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
if (DiscordRPCHandler.Instance != null) DiscordRPCHandler.Instance.UpdateRPC(details, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/DiscordRPCUpdater.cs.meta
Normal file
2
Assets/Scripts/DiscordRPCUpdater.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 74ebfdb8209384c82be16355035de665
|
||||||
Reference in New Issue
Block a user