/// <summary> /// Update is called every frame, if the MonoBehaviour is enabled. /// </summary> void Update() { DiscordRpc.RunCallbacks(); updateTimer += Time.deltaTime; if (updateTimer < kUpdateInterval) { return; } updateTimer = 0f; if (!isReady) { return; } var presence = new DiscordRpc.RichPresence { state = GetStatus(), startTimestamp = startTimestamp, largeImageKey = "default", // largeImageText = "Large image text test", partySize = GetPlayerCount(), partyMax = (int)GameMode.GlobalMaxPlayers }; var stage = GetSceneData(); var character = GetCurrentCharacter(); if (character != null) { presence.smallImageKey = character.name; presence.smallImageText = character.LongName; } if (stage != null) { presence.details = stage.Name; } DiscordRpc.UpdatePresence(presence); }
/// <summary> /// Sets discord's rich presence using custom rpc data. /// </summary> public static void SetFullRPC(bool restartTimestamp, [NotNull] DiscordRpc.RichPresence richPresence) { if (richPresence == null) { throw new ArgumentNullException(nameof(richPresence)); } //Debug.Log("Will update presence to " + richPresence); if (!IsInitialized) { return; } if (restartTimestamp || _lastTimestamp == 0) { ResetTimestamp(); } if (!IsConnected) { return; } HasPresence = true; DiscordRpc.UpdatePresence(richPresence); }
private static void Initialize(DiscordRpc.RichPresence newPresence) { initialized = true; controller = new GameObject(); controller.AddComponent <DiscordController>(); updatePresence(newPresence); }
static void Ready() { timer_connecting.Stop(); presence.largeImageKey = "google_banner"; presence.largeImageText = "Google Play Music"; ready = true; oldPresence = presence; Menu.MenuItemCollection menuIndex = notifyIcon.ContextMenu.MenuItems; menuIndex.Clear(); menuIndex.Add(Buttons["forc"]); menuIndex.Add(Buttons["stop"]); menuIndex.Add(Buttons["quit"]); timer.Tick += new EventHandler(UpdatePresence); timer.Interval = 2500; timer.Start(); timer.Enabled = true; CreatePopup("Connected!"); }
public void RenderEvtFinish(RenderStatusEventArgs renderargs, Vegas vegas) { if (!PresenceEnabled) { return; } SecondsSinceLastAction = 0; isActive = false; presence = new DiscordRpc.RichPresence(); resetPresence(ref presence, vegas); switch (renderargs.Status) { case RenderStatus.Complete: presence.state = "Just finished rendering"; break; case RenderStatus.Failed: presence.state = "Just failed to render"; break; case RenderStatus.Canceled: presence.state = "Just canceled rendering"; break; } DiscordRpc.UpdatePresence(ref presence); }
void OnEnable() { Dictionary.DS = this; DontDestroyOnLoad(gameObject); presence = new DiscordRpc.RichPresence(); PlayerPrefs.SetInt("USE_DISCORD", 1); if (PlayerPrefs.GetInt("USE_DISCORD") == 1) //do zmiany wylaczone dla testów { Debug.Log("Discord: Now Initiating"); handlers = new DiscordRpc.EventHandlers(); handlers.readyCallback += ReadyCallback; handlers.errorCallback += ErrorCallback; DiscordRpc.Initialize("655464840222998537", ref handlers, true, ""); if (update20SecLoop) { StartCoroutine(UpdatePresence()); } } else { Debug.Log("Discord: Not initiating - Disabled"); Dictionary.CT = Dictionary.ConnectionType.Unconnected; } }
public void UpdatePresence(PresenceState state) { DiscordRpc.RichPresence presence = state.create(); Debug.Log(string.Format("DiscordRP: Send presence: {0} ({1})", presence, state)); DiscordRpc.UpdatePresence(ref presence); }
private void HandleTimer(Object source, ElapsedEventArgs e) { string title = ""; string episodeName = ""; if (Process.GetProcessesByName("kodi").Length > 0) { Debug.WriteLine("Seen Kodi"); bEnable = true; } else { if (bEnable) { Debug.WriteLine("Shutting down Discord RPC"); Discord_RPC_Shutdown(); } bEnable = false; } if (bEnable) { if (!bInitialized) { Debug.WriteLine("Starting up Discord RPC"); handlers = new DiscordRpc.EventHandlers(); discordPresence = new DiscordRpc.RichPresence(); DiscordRpc.Initialize(APPLICATION_ID, ref handlers, true, null); bInitialized = true; } using (WebClient wc = new WebClient()) { try { var json = wc.DownloadString(TEST_URL); dynamic parsed = Newtonsoft.Json.JsonConvert.DeserializeObject(json); title = parsed.result.item.showtitle; episodeName = parsed.result.item.title; if ((title == "") && (episodeName == "")) { title = "In Menus"; } } catch { Debug.WriteLine("Unable to Connect to Remote Server"); } } discordPresence.details = title; discordPresence.state = episodeName; discordPresence.largeImageKey = "diskodi_logo"; DiscordRpc.UpdatePresence(ref discordPresence); } }
//This updates the presence static void UpdatePresence() { DiscordRpc.RichPresence discordPresence = new DiscordRpc.RichPresence(); discordPresence.state = "Scene: " + EditorSceneManager.GetActiveScene().name; discordPresence.details = "Project: " + GetProjectName(); discordPresence.startTimestamp = long.Parse(EditorPrefs.GetString("timestamp", GetTimestamp())); discordPresence.largeImageKey = "logo"; discordPresence.largeImageText = "Unity " + Application.unityVersion; discordPresence.smallImageKey = "marshmello"; discordPresence.smallImageText = "UERP on Github"; DiscordRpc.UpdatePresence(discordPresence); }
/// <summary> /// Returns instance of RichPresence initialized with ZZS defaults. /// Make necessary changes & initializations before updating presence. /// </summary> /// <returns></returns> DiscordRpc.RichPresence GetDefaultRPC() { var discordPresence = new DiscordRpc.RichPresence(); discordPresence.details = "Building the Zoo"; discordPresence.largeImageKey = "zoo-icon"; discordPresence.largeImageText = "Zoo: The Zoological Society"; //discordPresence.spectateSecret = "MTIzNDV8MTIzNDV8MTMyNDU0"; return(discordPresence); }
public static void Discord_RPC_Shutdown() { DiscordRpc.RichPresence discordPresence = new DiscordRpc.RichPresence(); discordPresence.details = ""; discordPresence.state = ""; discordPresence.largeImageKey = ""; DiscordRpc.UpdatePresence(ref discordPresence); DiscordRpc.Shutdown(); bEnable = false; bInitialized = false; }
private void UpdatePresenceStopped() { var presence = new DiscordRpc.RichPresence { state = "Spotify Closed", largeImageKey = "spotify", largeImageText = "Spotify is closed...", smallImageKey = "stop", smallImageText = "Stopped" }; presence.startTimestamp = _stoppedSince; DiscordRpc.UpdatePresence(ref presence); }
public static void updatePresence(DiscordRpc.RichPresence newPresence) { if (!initialized || controller == null) { Initialize(newPresence); return; } Debug.Log("Discord: update presence (Z)"); controller.GetComponentInChildren <DiscordController>().presence = newPresence; currentPresence = newPresence; DiscordRpc.UpdatePresence(newPresence); }
protected override void LoadComplete() { var presence = new DiscordRpc.RichPresence { details = "Test Game", state = "In-Game", largeImageKey = "logo" }; DiscordRpc.UpdatePresence(ref presence); bg.BlurTo(new Vector2(10)); }
private DiscordRpc.RichPresence GetPresence() { DiscordRpc.RichPresence presence = new DiscordRpc.RichPresence { details = api.FormatText(Conf.Details), state = api.FormatText(Conf.State), largeImageKey = "default_large", largeImageText = api.FormatText(Conf.LargeImageText), smallImageText = api.FormatText(Conf.SmallImageText) }; if (Conf.ForceSmallImage) { presence.smallImageKey = "default_small"; } if (presence.smallImageText != null) { presence.smallImageKey = presence.smallImageKey ?? "default_small"; } if (Context.IsWorldReady) { GamePresence conf = (GamePresence)Conf; if (conf.ShowSeason) { presence.largeImageKey = $"{Game1.currentSeason}_{FarmTypeKey()}"; } if (conf.ShowWeather) { presence.smallImageKey = "weather_" + WeatherKey(); } if (conf.ShowPlayTime) { presence.startTimestamp = timestampFarm; } if (Context.IsMultiplayer && conf.ShowPlayerCount) { try { presence.partyId = Game1.MasterPlayer.UniqueMultiplayerID.ToString(); presence.partySize = Game1.numberOfPlayers(); presence.partyMax = Game1.getFarm().getNumberBuildingsConstructed("Cabin") + 1; presence.joinSecret = Game1.server.getInviteCode(); } finally { } } } if (config.ShowGlobalPlayTime) { presence.startTimestamp = timestampSession; } return(presence); }
private void Application_Exit(object sender, ExitEventArgs e) { Debug.WriteLine("Application_Exit"); if (bEnable) { DiscordRpc.RichPresence discordPresence = new DiscordRpc.RichPresence(); discordPresence.details = ""; discordPresence.state = ""; discordPresence.largeImageKey = ""; DiscordRpc.UpdatePresence(ref discordPresence); DiscordRpc.Shutdown(); } }
protected override void OnEntering(Screen last) { var presence = new DiscordRpc.RichPresence { details = "Liveshow Selection", state = "Idle", largeImageKey = "logo" }; DiscordRpc.UpdatePresence(ref presence); Content.FadeInFromZero(400); base.OnEntering(last); }
void OnEnable() { Debug.Log("Discord: init"); handlers = new DiscordRpc.EventHandlers(); handlers.readyCallback += ReadyCallback; handlers.disconnectedCallback += DisconnectedCallback; handlers.errorCallback += ErrorCallback; handlers.joinCallback += JoinCallback; handlers.spectateCallback += SpectateCallback; handlers.requestCallback += RequestCallback; DiscordRpc.Initialize(applicationId, ref handlers, true, optionalSteamId); presence = GetDefaultRPC(); DiscordRpc.UpdatePresence(presence); }
protected override void OnEntering(Screen last) { Content.FadeIn(400); var presence = new DiscordRpc.RichPresence { state = "Idle", details = "Main Menu", largeImageKey = "logo" }; DiscordRpc.UpdatePresence(ref presence); base.OnEntering(last); }
/// <summary> /// Makes full presence refresh to resolve new state. /// </summary> /// <exception cref="ArgumentOutOfRangeException"/> public static void RefreshPresence(bool clear = false) { // Check if we should clear RPC. var shouldClear = clear || !JEMDiscordConfiguration.Resolve().Enable; if (shouldClear) { JEMDiscordController.ClearRPC(); return; } // Construct new presence. var scene = ResolveSceneName(); var presence = new DiscordRpc.RichPresence(); presence.details = $"Developing {Application.productName}"; string str; if (_inPlayMode) { str = $"In playmode ({scene})"; } else { switch (_drawState) { case State.DrawScene: str = $"Editing {scene}"; break; case State.DrawPrefab: str = "N/A"; break; default: throw new ArgumentOutOfRangeException(nameof(_drawState), _drawState, null); } } presence.state = str; presence.largeImageKey = JEMDiscordController.GetImageName(JEMDiscordImageKey.UnityDefault); presence.largeImageText = Application.unityVersion; // Apply presence. JEMDiscordController.SetFullRPC(false, presence); }
private void updateButton_Click(object sender, EventArgs e) { if (CurrentApplication == null) { return; } DiscordRpc.Shutdown(); DiscordRpc.Initialize(CurrentApplication.appId, ref handlers, false, string.Empty); DiscordRpc.RichPresence richPresence = new DiscordRpc.RichPresence(); richPresence.details = detailsTextBox.Text; richPresence.state = stateTextBox.Text; if (largeIconBox.SelectedIndex > 0) { richPresence.largeImageKey = (string)largeIconBox.SelectedItem; richPresence.largeImageText = CurrentApplication.GetLargeIconText(largeIconBox.SelectedIndex); } if (smallIconBox.SelectedIndex > 0) { richPresence.smallImageKey = (string)smallIconBox.SelectedItem; richPresence.smallImageText = CurrentApplication.GetSmallIconText(smallIconBox.SelectedIndex); } if (partyCheckBox.Checked) { richPresence.partySize = (int)partySizeNumeric.Value; richPresence.partyMax = (int)partyMaxNumeric.Value; } if (timeCheckBox.Checked) { if (startTimeRadioButton.Checked) { richPresence.startTimestamp = (long)dateTimePicker.Value.ToUniversalTime().Subtract(unixDateTimeStart).TotalSeconds; } else if (endTimeRadioButton.Checked) { richPresence.endTimestamp = (long)dateTimePicker.Value.ToUniversalTime().Subtract(unixDateTimeStart).TotalSeconds; } } DiscordRpc.UpdatePresence(richPresence); }
void UpdatePresence() { if (DiscordRPC_Active.Checked) { DiscordRpc.EventHandlers handlers = new DiscordRpc.EventHandlers(); DiscordRpc.RichPresence presence = new DiscordRpc.RichPresence(); DiscordRpc.Initialize("738137354589437972", ref handlers, true, null); presence.details = DiscordRPC_Description.Text; presence.largeImageKey = Properties.Settings.Default.DiscordRPC_Image; presence.largeImageText = "Seafight"; presence.startTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); DiscordRpc.UpdatePresence(ref presence); } else { DiscordRpc.Shutdown(); } }
/// <summary> /// Resets the presence object. /// </summary> /// <param name="pres">The presence object to reset (Future use: ?)</param> /// <param name="vegas">The Vegas object</param> /// <param name="smallKey">Small image key</param> /// <param name="smallText">Small image hover text</param> public void resetPresence(ref DiscordRpc.RichPresence pres, Vegas vegas, string smallKey = "", string smallText = "") { if (!PresenceEnabled) { return; } pres = new DiscordRpc.RichPresence { largeImageKey = (int.Parse(vegas.Version.Split(' ')[1].Split('.')[0]) > 14 ? "v15" : "v" + vegas.Version.Split(' ')[1].Split('.')[0]), largeImageText = vegas.Version }; if (smallKey != "") { pres.smallImageKey = smallKey; } if (smallText != "") { pres.smallImageText = smallText; } }
public static DiscordRpc.RichPresence getCurrentPresence() { if (initialized) { return(currentPresence); } else { //your default presence, basically. DiscordRpc.RichPresence presence = new DiscordRpc.RichPresence(); presence.state = DiscordConfig.state; presence.details = DiscordConfig.details; System.DateTime epochStart = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); int cur_time = (int)(System.DateTime.UtcNow - epochStart).TotalSeconds; presence.startTimestamp = cur_time; presence.largeImageKey = DiscordConfig.largeImageKey; presence.largeImageText = DiscordConfig.largeImageText; presence.smallImageText = DiscordConfig.smallImageText; return(presence); } }
static void Main(string[] args) { // Register callbacks var Callbacks = new DiscordRpc.EventHandlers(); Callbacks.readyCallback = ReadyCallback; Callbacks.disconnectedCallback += DisconnectedCallback; Callbacks.errorCallback += ErrorCallback; Task.Run((Action) delegate { // Connect (Using the 'send-presence.c' id for demo MAKE_YOUR_OWN) DiscordRpc.Initialize("345229890980937739", ref Callbacks, true, null); // Register status var Status = new DiscordRpc.RichPresence(); Status.details = "Doing a thing!"; // Update status DiscordRpc.UpdatePresence(ref Status); while (Continue) { // Callbacks DiscordRpc.RunCallbacks(); System.Threading.Thread.Sleep(100); } }); while (Continue) { System.Threading.Thread.Sleep(100); } // Clean up DiscordRpc.Shutdown(); }
private static extern void ExternUpdatePresence(ref DiscordRpc.RichPresence presence);
// Token: 0x06006734 RID: 26420 RVA: 0x001EFD2C File Offset: 0x001EDF2C public static void JPLLIKHNPKG(DiscordRpc.RichPresence LBKOCHOCABF) { DiscordRpc.RichPresenceStruct richPresenceStruct = LBKOCHOCABF.KIMDNABCOAC(); DiscordRpc.AAKMLKFEDJM(ref richPresenceStruct); LBKOCHOCABF.BPLLAKDACDI(); }
public static extern void UpdatePresence(ref DiscordRpc.RichPresence presence);
public static void UpdatePresence(object sender, EventArgs e) { if (!ready) { return; } string filePath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Google Play Music Desktop Player\json_store\playback.json" ); string FileContents = ""; try { FileContents = File.ReadAllText(filePath); } catch (FileNotFoundException) { MessageBox.Show("Cannot find playback.json", "Discord Play", MessageBoxButtons.OK, MessageBoxIcon.Error); TerminateProgram(); } catch (IOException) { return; } GooglePlay result = JsonConvert.DeserializeObject <GooglePlay> (FileContents); presence.details = $"Song: {result.song["title"]}"; presence.state = $"Artist: {result.song["artist"]}"; // Album: {result.song["album"]} if (result.playing) { presence.smallImageKey = "status_play"; presence.smallImageText = "Playing"; } else { presence.smallImageKey = "status_pause"; presence.smallImageText = "Paused"; } /*var now = DateTime.UtcNow; * presence.startTimestamp = GetCurrentUNIXTimestamp () - result.time ["current"]; * presence.endTimestamp = presence.startTimestamp + result.time ["total"];*/ if (presence.details != oldPresence.details || presence.state != oldPresence.state || presence.smallImageText != oldPresence.smallImageText) { oldPresence = presence; //CreatePopup ($"{result.song["title"]} by {result.song["artist"]}"); DiscordRpc.UpdatePresence(ref presence); } }
public void UpdatePresence(ref DiscordRpc.RichPresence presence) { ExternUpdatePresence(ref presence); }