static async Task DiscordSetup() { var discordRpcClient = new DiscordRpcClient(ClientId); //Set the logger discordRpcClient.Logger = new ConsoleLogger() { Level = DiscordRPC.Logging.LogLevel.Info }; //Subscribe to events discordRpcClient.OnReady += (sender, e) => { Console.WriteLine("Received Ready from user {0}", e.User.Username); }; discordRpcClient.OnPresenceUpdate += (sender, e) => { Console.WriteLine("Received Update! {0}", e.Presence); }; //Connect to the RPC discordRpcClient.Initialize(); discordRpcClient.Authorize(DefaultScopes); while (string.IsNullOrWhiteSpace(discordRpcClient.AccessCode)) { await Task.Delay(500, CancellableShellHelper.CancellationToken); } discordRpcClient.Authenticate(null); while (string.IsNullOrWhiteSpace(discordRpcClient.AccessToken)) { await Task.Delay(500, CancellableShellHelper.CancellationToken); } discordRpcClient.RegisterUriScheme(); discordRpcClient.GetVoiceSettings(); var newPresence = new RichPresence() { State = "Accessing Named Pipes", }; discordRpcClient.SetPresence(newPresence); discordRpcClient.Subscribe(EventType.VoiceSettingsUpdate); discordRpcClient.OnVoiceSettingsUpdate += ProcessDiscordVoiceStatus; while (!CancellableShellHelper.CancellationToken.WaitHandle.WaitOne(0)) { await Task.Delay(500, CancellableShellHelper.CancellationToken); } discordRpcClient.ClearPresence(); discordRpcClient.ShutdownOnly = true; }