Ejemplo n.º 1
0
        //Updates the presence when it detects a title change.

        private void UpdatePresence()
        {
            string newTitle = GetWindowTitle.GetFullTitle();

            if (oldTitle != newTitle)
            {
                if (client != null)
                {
                    client.Invoke();
                }

                //TickBoxSaver();

                CurrentlyOpen.Content      = GetWindowTitle.GetCaptionOfActiveWindow();
                CurrentProcessOpen.Content = GetWindowTitle.GetActiveProcessFileName();

                SetPresence.StatText    = CustomStatusText.Text;
                SetPresence.CustAppText = CustomAppText.Text;

                CustomAppText.MaxLength    = 128;
                CustomStatusText.MaxLength = 128;

                oldTitle = newTitle;

                BlockedWordCheck();
                var sP = new SetPresence();
                sP.RPCUpdate();
            }
        }
Ejemplo n.º 2
0
        private void OnGameInitialized()
        {
            GameInitialized = true;
            Logger.Log("OnGameInitialized");
            client.UpdateState("OnGameInitialized");
#if DEBUG
            Logger.Debug("Loaded assemblies:\n{0}", string.Join("\n", AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().FullName).OrderBy(x => x).ToArray()));
#else
            Logger.Debug("Loaded assemblies: {0}", string.Join(", ", AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name).ToArray()));
#endif
            Logger.Log($"[Discord] {client.SteamID}");
            Logger.Log($"[Discord] {client.TargetPipe}");
            Logger.Log($"[Discord] {client.ApplicationID}");
            Logger.Log($"[Discord] {client.AutoEvents}");
            if (client.Configuration != null)
            {
                Logger.Log($"[Discord] {client.Configuration.ApiEndpoint}");
                Logger.Log($"[Discord] {client.Configuration.CdnHost}");
                Logger.Log($"[Discord] {client.Configuration.Enviroment}");
            }
            Logger.Log($"[Discord] {client.CurrentPresence.Details}");
            Logger.Log($"[Discord] {client.CurrentPresence.State}");
            Logger.Log($"[Discord] {client.HasRegisteredUriScheme}");
            Logger.Log($"[Discord] {client.IsDisposed}");
            Logger.Log($"[Discord] {client.IsInitialized}");
            Logger.Log($"[Discord] {client.Logger.Level}");
            Logger.Log($"[Discord] {client.MaxQueueSize}");
            Logger.Log($"[Discord] {client.ProcessID}");
            Logger.Log($"[Discord] {client.ShutdownOnly}");
            Logger.Log($"[Discord] {client.SkipIdenticalPresence}");
            Logger.Log($"[Discord] {client.Subscription}");
            client.Invoke();
        }
Ejemplo n.º 3
0
        public void SetRichPresence(Presence presence)
        {
            RpcClient.SetPresence(new RichPresence
            {
                Assets = new Assets
                {
                    LargeImageKey  = presence.BigImage,
                    LargeImageText = presence.BigImageText,
                    SmallImageKey  = presence.SmallImage,
                    SmallImageText = presence.SmallImageText
                },
                Details    = presence.Data1,
                Party      = null,
                Secrets    = null,
                State      = presence.Data2,
                Timestamps = null,
                Buttons    = presence.Buttons
                             .Where(b => !string.IsNullOrWhiteSpace(b.Text) && !string.IsNullOrWhiteSpace(b.Url))
                             .Select(b => new Button {
                    Label = b.Text, Url = b.Url
                }).ToArray()
            });

            RpcClient.Invoke();
        }
Ejemplo n.º 4
0
        //event when gamestatelistener has a new event
        static void OnNewGameState(GameState gs)
        {
            try
            {
                if (gsl.CurrentGameState.Map.Name == "" && gsl.CurrentGameState.Player.MatchStats.Kills == -1)
                {
                    client.SetPresence(new RichPresence()
                    {
                        Details = "In Main Menu",
                        State   = "Main Menu",
                        Assets  = new Assets()
                        {
                            LargeImageKey  = "mainmenu",
                            LargeImageText = "Main Menu"
                        },
                        Timestamps = new Timestamps(gameOpened),
                    });
                    client.Invoke();
                }
                else
                {
                    if (gsl.CurrentGameState.Provider.SteamID == gsl.CurrentGameState.Player.SteamID)
                    {
                        string currentWeapon = gsl.CurrentGameState.Player.Weapons.ActiveWeapon.Name.Replace("weapon_", "");
                        currentWeapon = currentWeapon.Contains("knife_") ? currentWeapon.Replace("knife_", "") : currentWeapon;
                        string playerState = gsl.CurrentGameState.Player.State.Flashed > 0 ? "Flashed" : gsl.CurrentGameState.Player.State.Smoked > 0 ? "In Smoke" :
                                             gsl.CurrentGameState.Player.State.Burning > 0 ? "In a Fire" : "";
                        string stateText = gsl.CurrentGameState.Map.Phase.ToString() != "Live" ? gsl.CurrentGameState.Map.Phase.ToString() : playerState;

                        client.SetPresence(new RichPresence()
                        {
                            Details = gsl.CurrentGameState.Player.MatchStats.Kills + "-" + gsl.CurrentGameState.Player.MatchStats.Assists + "-" + gsl.CurrentGameState.Player.MatchStats.Deaths
                                      + " " + currentWeapon,

                            State  = "CT : " + gsl.CurrentGameState.Map.TeamCT.Score + " T : " + gsl.CurrentGameState.Map.TeamT.Score + " " + stateText,
                            Assets = new Assets()
                            {
                                LargeImageKey  = gsl.CurrentGameState.Map.Name,
                                LargeImageText = gsl.CurrentGameState.Map.Name + " - " + gsl.CurrentGameState.Map.Mode.ToString(),
                                SmallImageKey  = "team" + gsl.CurrentGameState.Player.Team.ToString().ToLower(),
                                SmallImageText = "Team " + gsl.CurrentGameState.Player.Team.ToString() + " - " + gsl.CurrentGameState.Player.State.Health + " Health",
                            },
                            Timestamps = new Timestamps(gameOpened),
                        });
                    }
                    client.Invoke();
                }
            } catch (Exception ex)
            {
                if (ex is StringOutOfRangeException)
                {
                    Console.WriteLine("Map name too long to load into discord! :(");
                }
                else
                {
                    Console.WriteLine(ex);
                }
            }
        }
Ejemplo n.º 5
0
 void updatePresence(String details, String state)
 {
     client.UpdateDetails(status);
     client.UpdateState(state);
     client.UpdateLargeAsset("cover");
     client.UpdateSmallAsset(smallImageKey, smallImageText);
     client.UpdateStartTime(DateTime.UtcNow);
     client.UpdateEndTime(endtime);
     client.Invoke();
 }
Ejemplo n.º 6
0
 public static void Update(string detail = null, string state = null)
 {
     _client.SetPresence(new RichPresence
     {
         Assets     = _assets,
         Timestamps = _baseTimestamp,
         Details    = string.IsNullOrEmpty(detail) ? _presence?.Details : detail,
         State      = string.IsNullOrEmpty(state) ? _presence?.State : state
     });
     _client.Invoke();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Updates the presence.
        /// </summary>
        public static void Update(RichPresence presence)
        {
            if (!RichPresenceHelper.IsInitialized)
            {
                throw new Exception("RPC must be initialized before the presence can be updated.");
            }

            _client.Invoke();
            _client.SetPresence(presence);
            _client.Invoke();
        }
Ejemplo n.º 8
0
        private static void Main()
        {
            _client.Initialize();
            _client.OnError          += _client_OnError;
            _client.OnPresenceUpdate += _client_OnPresenceUpdate;

            TrackInfo currentTrack = new TrackInfo();
            TrackInfo oldTrack     = new TrackInfo();

            while (_client.IsInitialized)
            {
                if (_grooveInfoFetcher.IsUsingAudio())
                {
                    try
                    {
                        currentTrack = _grooveInfoFetcher.GetTrackInfo();
                        if (oldTrack.Title != currentTrack.Title)
                        {
                            var details = $"Title: {currentTrack.Title}";
                            var state   = $"Artist: {currentTrack.Artist}";

                            _client.SetPresence(new RichPresence
                            {
                                Details = details,
                                State   = state,
                                Assets  = new Assets
                                {
                                    LargeImageKey  = "groove",
                                    LargeImageText = "Groove Music",
                                    SmallImageKey  = "groove_small"
                                }
                            });

                            _client.Invoke();
                        }
                    }
                    catch (Exception)
                    {
                        _client.SetPresence(new RichPresence()
                        {
                            Details = "Failed to get track info"
                        });
                        Console.WriteLine("Failed to get track info");
                    }
                }
                else
                {
                    _client.ClearPresence();
                    oldTrack = new TrackInfo();
                    _client.Invoke();
                }
            }
        }
        private void UpdateFromURL()
        {
            client.Invoke();
            string url = CurrentURL();

            if (url == null || url == "")
            {
                client.ClearPresence();
                return;
            }
            if (url.Contains("game"))
            {
                DoGameUpdate(url);
                return;
            }
            if (url.Contains("assess"))
            {
                DoAssesUpdate(url);
                return;
            }
            if (url.Contains("essentials"))
            {
                DoEssentialsUpdates(url);
                return;
            }
            SetRP("Idle", "", "cd");
        }
Ejemplo n.º 10
0
        private void BasicClient()
        {
            //Create a new client
            var client = new DiscordRpcClient("560482798364917789");

            //Create some events so we know things are happening
            //Create a timer that will regularly call invoke
            var timer = new System.Timers.Timer(150);

            timer.Elapsed += (sender, evt) => { client.Invoke(); };
            timer.Start();

            //Connect
            client.Initialize();

            //Send a presence. Do this as many times as you want
            client.SetPresence(new RichPresence()
            {
                Details = "Gamemode: Valid Hunt Racing",
                State   = "/vg/station",
                Assets  = new Assets()
                {
                    LargeImageKey  = "vgstation-logo2",
                    LargeImageText = "Meta Station",
                    SmallImageKey  = "logo",
                },
                Timestamps = Timestamps.FromTimeSpan(10)
            });
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Invokes all the events, such as OnPresenceUpdate
 /// </summary>
 public void Update()
 {
     if (IsEnabled)
     {
         _discClient.Invoke();
     }
 }
Ejemplo n.º 12
0
        private void Update()
        {
            if (m_Client == null && m_Active)
            {
                m_Client = new DiscordRpcClient(DiscordAppId);
                if (m_Client.Initialize() == false)
                {
                    m_Client.Dispose();
                    m_Client = null;
                }
            }

            if (m_Client != null && !m_Active)
            {
                m_Client.Dispose();
                m_Client = null;
            }

            if (m_Client != null && !m_Lock.IsWriteLockHeld)
            {
                m_Lock.EnterReadLock();
                try
                {
                    m_Client.SetPresence(m_Presence);
                }
                finally
                {
                    m_Lock.ExitReadLock();
                }
                m_Client.Invoke();
            }
        }
Ejemplo n.º 13
0
        static void mainPresence()
        {
            var client = new DiscordRpcClient(_ClientID);

            //client.Logger = new ConsoleLogger() {Level = DiscordLogLevel, Colored = true};

            //client.OnReady += (sender, msg) => { Console.WriteLine("Connected to discord under user: {0}", msg.User.Username); };
            //client.OnPresenceUpdate += (sender, msg) => { Console.WriteLine("Presence has been updated"); };

            //timer to regularly invoke
            var timer = new System.Timers.Timer(150);

            timer.Elapsed += (sender, evt) => { client.Invoke(); };
            timer.Start();

            //connect
            client.Initialize();

            client.SetPresence(presence);

            Console.WriteLine("Discord Rich Presence Initialization Finished.");
            Console.WriteLine("This window close in 15 seconds.");
            Console.WriteLine("You can terminate the program in task manager. It will be called CustomPresence.exe in background processes.");
            Thread.Sleep(15000);
            //Hide
            var handle = GetConsoleWindow();

            ShowWindow(handle, SW_HIDE);

            Console.ReadKey();
            timer.Dispose();
            client.Dispose();
        }
Ejemplo n.º 14
0
        private void UpdateDetails()
        {
            if (GameService.Player.Map == null)
            {
                return;
            }

            // rpcClient *shouldn't* be null at this point unless a rare race condition occurs
            // In the event that this occurs, it'll be resolved by the next loop
            rpcClient?.SetPresence(new RichPresence()
            {
                // Truncate length (requirements: https://discordapp.com/developers/docs/rich-presence/how-to)
                // Identified in: [BLISHHUD-11]
                Details = TruncateLength(GameService.Player.CharacterName, 128),
#if DEBUG
                State = "Working on Blish HUD",
#else
                State = TruncateLength($"in {GameService.Player.Map.Name}", 128),
#endif
                Assets = new Assets()
                {
                    LargeImageKey  = TruncateLength(mapOverrides.ContainsKey(GameService.Player.Map.Id) ? mapOverrides[GameService.Player.Map.Id] : GetDiscordSafeString(GameService.Player.Map.Name), 32),
                    LargeImageText = TruncateLength(GameService.Player.Map.Name, 128),
                    SmallImageKey  = TruncateLength(((MapType)GameService.Player.MapType).ToString().ToLower(), 32),
                    SmallImageText = TruncateLength(((MapType)GameService.Player.MapType).ToString().Replace("_", " "), 128)
                },
                Timestamps = new Timestamps()
                {
                    Start = startTime
                }
            });

            rpcClient?.Invoke();
        }
Ejemplo n.º 15
0
        public static void Init()
        {
            DiscordClient.Logger = new ConsoleLogger()
            {
                Level = LogLevel.Info
            };
            DiscordClient.OnPresenceUpdate += (sender, e) =>
            {
                Console.WriteLine("Received Update! {0}", e.Presence);
            };

            //Connect to the RPC
            DiscordClient.Initialize();

            //Set the rich presence
            DiscordClient.SetPresence(new RichPresence()
            {
                Details = "In the launcher"
            });

            new Thread(() =>
            {
                while (DiscordClient != null)
                {
                    DiscordClient.Invoke();
                    Thread.Sleep(10);
                }
            }).Start();
        }
Ejemplo n.º 16
0
        static void MainLoop()
        {
            client.Invoke();
            Thread.Sleep(7000);

            while (client != null && !client.IsDisposed)
            {
                string winTitle;
                if (client != null)
                {
                    winTitle = GetFLTitle();
                    if (winTitle != null)
                    {
                        UpdatePresence(winTitle);
                        tray.Detected(true);
                    }
                    else
                    {
                        UpdatePresence(null);
                        tray.Detected(false);
                    }
                    Thread.Sleep(15000);
                }
            }
        }
Ejemplo n.º 17
0
        public void Execute()
        {
            // todo do things
            Console.CancelKeyPress += new ConsoleCancelEventHandler(CtrlC);
            running         = true;
            client          = new DiscordRpcClient("410474255810035712", null, true, -1); // bind to 1st available pipe
            client.OnReady += RPCReady;

            Assets assets = new Assets()
            {
                LargeImageKey  = "cone",
                LargeImageText = "VLC media player"
            };

            presence = new RichPresence()
            {
                State   = "In C#",
                Details = "Test",
                Assets  = assets
            };

            client.SetPresence(presence);
            client.Initialize();

            while (running && client != null)
            {
                client.Invoke();
                Thread.Sleep(15000); // sleep for 15s
            }
        }
Ejemplo n.º 18
0
 public void Update()
 {
     try
     {
         if (DiscordLImagePath == "")
         {
             DiscordLImagePath = "default_main";
         }
         client.SetPresence(new RichPresence()
         {
             Details = DiscordDetail,
             State   = DiscordState,
             Assets  = new Assets()
             {
                 LargeImageKey  = DiscordLImagePath,
                 LargeImageText = DiscordLImageText,
                 SmallImageKey  = DiscordSImagePath,
                 SmallImageText = DiscordSImageText
             }
         });
         client.Invoke();
     }
     catch
     {
     }
 }
        public static void ChangePresence(MainWindow window)
        {
            DateTime utcTime = DateTime.UtcNow;

            gameTime = DateTime.UtcNow.AddSeconds(Convert.ToDouble(window.EndTimeBox.Value));
            TimeSpan elapseTime = gameTime - utcTime;

            client.SetPresence(new RichPresence
            {
                Details = window.DetailsTextBox.Text,
                State   = window.StateTextBox.Text,
                Party   = new Party
                {
                    ID   = window.PartyIDTextBox.Text,
                    Max  = 21,
                    Size = 1,
                },
                Secrets = new Secrets
                {
                    JoinSecret = window.JoinSecretTextBox.Text,
                },
                Assets = new Assets
                {
                    LargeImageKey  = window.LargeImageKeyTextBox.Text,
                    LargeImageText = window.LargeImageTextBox.Text,
                    SmallImageKey  = window.SmallImageKeyTextBox.Text,
                    SmallImageText = window.SmallImageTextBox.Text,
                },
                Timestamps = window.TimeElapsedCheckBox.IsChecked.Value ? Timestamps.Now : Timestamps.FromTimeSpan(elapseTime)
            });
            client.Invoke();
        }
Ejemplo n.º 20
0
        private void UpdateDetails()
        {
            if (GameService.Player.Map == null)
            {
                return;
            }

            Logger.Debug($"Player changed maps to '{GameService.Player.Map.Name}' ({GameService.Player.Map.Id}).");

            // rpcClient *shouldn't* be null at this point unless a rare race condition occurs
            // In the event that this occurs, it'll be resolved by the next loop
            _rpcClient?.SetPresence(new RichPresence()
            {
                // Truncate length (requirements: https://discordapp.com/developers/docs/rich-presence/how-to)
                Details = DiscordUtil.TruncateLength(GameService.Player.CharacterName, 128),
                State   = DiscordUtil.TruncateLength($"in {GameService.Player.Map.Name}", 128),
                Assets  = new Assets()
                {
                    LargeImageKey = DiscordUtil.TruncateLength(_mapOverrides.ContainsKey(GameService.Player.Map.Id.ToString())
                                                                   ? _mapOverrides[GameService.Player.Map.Id.ToString()]
                                                                   : DiscordUtil.GetDiscordSafeString(GameService.Player.Map.Name), 32),
                    LargeImageText = DiscordUtil.TruncateLength(GameService.Player.Map.Name, 128),
                    SmallImageKey  = DiscordUtil.TruncateLength(((MapType)GameService.Player.MapType).ToString().ToLower(), 32),
                    SmallImageText = DiscordUtil.TruncateLength(((MapType)GameService.Player.MapType).ToString().Replace("_", " "), 128)
                },
                Timestamps = new Timestamps()
                {
                    Start = _startTime
                }
            });

            _rpcClient?.Invoke();
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Turn the rich presence on.
        /// </summary>
        /// <param name="automatic">Whether to have EliteAPI send events to the presence.</param>
        public RichPresenceClient TurnOn(bool automatic = true)
        {
            //Create RPC client.
            rpc = new DiscordRpcClient(clientID, true);
            api.Logger.Log("Starting rich presence.");

            //Subscribe to events.
            rpc.OnConnectionEstablished += (sender, e) => api.Logger.Log(Severity.Debug, $"Attempting to connect to Discord ... ");
            rpc.OnConnectionFailed      += (sender, e) => { api.Logger.Log(Severity.Error, $"There was an error while trying to connect to Discord. Make sure Discord is running.", new ExternalException("Discord is unresponsive, or might not be running on this machine.")); TurnOff(); };
            rpc.OnError              += (sender, e) => api.Logger.Log(Severity.Error, $"Discord Rich Presence stumbled upon an error.", new ExternalException(e.Message, (int)e.Code));
            rpc.OnReady              += (sender, e) => { api.Logger.Log(Severity.Success, $"Discord Rich Presence has connected and is running."); IsReady = true; };
            rpc.OnClose              += (sender, e) => { api.Logger.Log($"Discord Rich Presence closed.", new ExternalException(e.Reason, e.Code)); TurnOff(); };
            rpc.OnJoin               += (sender, e) => api.Logger.Log(Severity.Debug, $"Discord Rich Presence joined with secret '{e.Secret}'.");
            rpc.OnJoinRequested      += (sender, e) => api.Logger.Log(Severity.Debug, $"Discord Rich Presence joining with '{e.User.Username}' (ID {e.User.ID})");
            api.Events.DockedEvent   += (sender, e) => { justDocked = true; };
            api.Events.UndockedEvent += (sender, e) => { justDocked = false; };

            //Start the RPC.
            //Mark as running.
            IsRunning = true;
            rpc.SetSubscription(EventType.Join | EventType.JoinRequest | EventType.Spectate);
            rpc.Initialize();
            Task.Run(() => { while (!IsReady)
                             {
                                 Thread.Sleep(1000); rpc.Invoke();
                             }
                     });
            if (automatic)
            {
                DoAutomaticEvents();
            }
            return(this);
        }
        public static void Initalize(MainWindow window)
        {
            if (initialised && window.ClientIDTextBox.Text != "")
            {
                ShutDown();
            }

            client = new DiscordRpcClient(window.ClientIDTextBox.Text);

            client.OnError += (sender, e) =>
            {
                MessageBox.Show("Error");
            };

            client.OnReady += (sender, e) =>
            {
            };

            client.OnConnectionFailed += (sender, e) =>
            {
                MessageBox.Show("Connection Failed");
            };

            client.OnPresenceUpdate += (sender, e) =>
            {
                MessageBox.Show("Updated Presence");
            };

            client.Initialize();
            client.RegisterUriScheme();
            ChangePresence(window);
            client.Invoke();
            initialised = true;
        }
Ejemplo n.º 23
0
        static void MainLoop()
        {
            /*
             * Enter a infinite loop, polling the Discord Client for events.
             * In game termonology, this will be equivalent to our main game loop.
             * If you were making a GUI application without a infinite loop, you could implement
             * this with timers.
             */
            isRunning = true;
            while (client != null && isRunning)
            {
                //We will invoke the client events.
                // In a game situation, you would do this in the Update.
                if (client != null)
                {
                    client.Invoke();
                }

                //Try to read any keys if available
                if (Console.KeyAvailable)
                {
                    ProcessKey();
                }

                //This can be what ever value you want, as long as it is faster than 30 seconds.
                //Console.Write("+");
                Thread.Sleep(10);
            }

            Console.WriteLine("Press any key to terminate");
            Console.ReadKey();
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Invokes a new Instance of RPC
 /// </summary>
 /// <remarks>Starts a new RPC for Launcher</remarks>
 public static void Update()
 {
     if (Running())
     {
         Client.Invoke();
     }
 }
Ejemplo n.º 25
0
        private static void updateOnJob(object sender, ElapsedEventArgs e)
        {
            Console.WriteLine(sender);
            if (JobInfoActive)
            {
                Console.WriteLine("job update 1");
                RichPresence RPC = new RichPresence()
                {
                    Details = (int)TelemetryHandler.Telemetry_Data.TruckValues.CurrentValues.DashboardValues.Speed.Kph + " km/h",
                    State   = (int)TelemetryHandler.Telemetry_Data.NavigationValues.NavigationDistance / 1000 + " km(" + (int)((((TelemetryHandler.Telemetry_Data.NavigationValues.NavigationDistance / 1000) / TelemetryHandler.Telemetry_Data.JobValues.PlannedDistanceKm) * 100)) + "%) " + translation.DISCORD_JOB_REMAINING,

                    Assets = new Assets()
                    {
                        LargeImageKey  = jobRPC.Assets.LargeImageKey,
                        LargeImageText = jobRPC.Assets.LargeImageText,
                        SmallImageKey  = jobRPC.Assets.SmallImageKey,
                        SmallImageText = jobRPC.Assets.SmallImageText
                    }
                };
                client.SetPresence(RPC);
                client.Invoke();
                JobInfoActive = false;
            }
            else
            {
                Console.WriteLine("job update2");
                client.SetPresence(jobRPC);
                JobInfoActive = true;
            }
        }
Ejemplo n.º 26
0
        private void Update()
        {
            if (m_Client != null)
            {
                m_Lock.EnterReadLock();
                try
                {
                    m_Client.SetPresence(m_Presence);
                }
                finally
                {
                    m_Lock.ExitReadLock();
                }
                m_Client.Invoke();
            }

            if (m_Active == true)
            {
                if (m_Client == null)
                {
                    m_Client = new DiscordRpcClient("845540839878164490");
                    if (m_Client.Initialize() == false)
                    {
                        m_Client.Dispose();
                        m_Client = null;
                    }
                }
            }
            else if (m_Client != null)
            {
                m_Client.Dispose();
                m_Client = null;
            }
        }
Ejemplo n.º 27
0
 private void DoUpdate(object sender, UpdateTickedEventArgs e)
 {
     client.Invoke();
     if (e.IsMultipleOf(30))
     {
         client.SetPresence(GetPresence());
     }
 }
Ejemplo n.º 28
0
 public void Invoke()
 {
     if (!IsUp)
     {
         return;
     }
     DiscordRpcClient.Invoke();
 }
Ejemplo n.º 29
0
        private void Initialize(DiscordRpcClient client)
        {
            timer          = new System.Timers.Timer(1000);
            timer.Elapsed += (sender, evt) => { client.Invoke(); Update(client); };
            timer.Start();

            secondUpd(client);
        }
Ejemplo n.º 30
0
        private void OnConnectionEstablished(object sender, ConnectionEstablishedMessage args)
        {
            client.SetPresence(new RichPresence()
            {
                Details = JsonConfig.settings.discordPresenceDetail,
                State   = JsonConfig.settings.discordPresenceState,

                Assets = new Assets()
                {
                    LargeImageKey  = JsonConfig.settings.discordLargeImageKey,
                    LargeImageText = JsonConfig.settings.discordLargeImageText,
                    SmallImageKey  = JsonConfig.settings.discordSmallImageKey,
                    SmallImageText = JsonConfig.settings.discordSmallImageText,
                }
            });
            client.Invoke();
        }