This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
70 lines (65 loc) · 2.01 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Net;
using System.Net.Security;
using System.Threading.Tasks;
using DiscordRPC;
namespace Deezcord
{
public class Program
{
static DiscordRpcClient client = new DiscordRpcClient(APIKeys.DiscordApplicationId);
public static long currentlyPlaying;
private static void Main()
{
Console.WriteLine("Deezcord Plus - https://github.com/b1sergiu/deezcord-plus/");
MainAsync().GetAwaiter().GetResult();
}
static async Task MainAsync()
{
Console.WriteLine("Initializing Discord...");
client.Initialize();
client.SetPresence(new RichPresence()
{
Assets = new Assets()
{
LargeImageKey = "logo"
}
});
await StartPresence();
}
public static async Task StartPresence()
{
while (true)
{
Track track = await DeezerAPI.LastTrack();
if (currentlyPlaying != track.Id)
{
UpdatePresence(track);
Console.WriteLine($"Currently playing: {track.Title} by {track.Artist.Name} - {track.Album.Title}");
currentlyPlaying = track.Id;
}
await Task.Delay(30000);
}
}
public static void UpdatePresence(Track song)
{
client.SetPresence(new RichPresence()
{
Details = song.Title,
State = $"by {song.Artist.Name}",
Assets = new Assets()
{
LargeImageKey = "logo",
LargeImageText = song.Album.Title
}
});
client.Invoke();
}
public async Task Login()
{
await DeezerAPI.Authenticate();
User user = await DeezerAPI.User();
Console.WriteLine($"Deezer user: {user.Name}");
}
}
}