1
0
mirror of synced 2024-12-01 02:27:22 +01:00
Switch-Toolbox/Switch_Toolbox_Library/DiscordPresence.cs
2018-11-29 23:59:29 -04:00

59 lines
1.5 KiB
C#

using DiscordRPC;
using DiscordRPC.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Switch_Toolbox_Library
{
/**
* Code from the DiscordRpc examples:
* https://github.com/Lachee/discord-rpc-csharp#usage
*/
public class DiscordPresence
{
public DiscordRpcClient client;
public String ClientID = "517901453935771668";
public void Initialize()
{
client = new DiscordRpcClient(ClientID);
client.Logger = new ConsoleLogger() { Level = LogLevel.Warning };
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);
};
client.Initialize();
var timer = new System.Timers.Timer(150);
timer.Elapsed += (sender, args) => { UpdatePresence(); };
timer.Start();
}
void UpdatePresence()
{
client.SetPresence(new RichPresence()
{
Details = "Working on a mod",
State ="",
Assets = new Assets()
{
LargeImageKey = "toolbox-logo",
LargeImageText = "Switch Toolbox"
}
});
}
}
}