/// <summary> /// Creats a new Presence object, copying values of the Rich Presence /// </summary> /// <param name="presence">The rich presence, often received by discord.</param> public DiscordPresence(DiscordRPC.RichPresence presence) { this.state = presence.State; this.details = presence.Details; this.party = presence.HasParty() ? new DiscordParty(presence.Party) : new DiscordParty(); this.secrets = presence.HasSecrets() ? new DiscordSecrets(presence.Secrets) : new DiscordSecrets(); if (presence.HasAssets()) { this.smallAsset = new DiscordAsset() { image = presence.Assets.SmallImageKey, tooltip = presence.Assets.SmallImageText }; this.largeAsset = new DiscordAsset() { image = presence.Assets.LargeImageKey, tooltip = presence.Assets.LargeImageText }; } else { this.smallAsset = new DiscordAsset(); this.largeAsset = new DiscordAsset(); } if (presence.HasTimestamps()) { this.startTime = presence.Timestamps.Start.HasValue ? new DiscordTimestamp(presence.Timestamps.Start.Value) : new DiscordTimestamp(0); this.endTime = presence.Timestamps.End.HasValue ? new DiscordTimestamp(presence.Timestamps.End.Value) : new DiscordTimestamp(0); } }
private void UpdatePresence(string artist, string track, string album, string duration, Boolean playing) { DiscordRPC.RichPresence presence = new DiscordRPC.RichPresence(); /* Discord RPC doesn't like strings that are only one character long, so I * add a space after each track to make sure it's over 1 character long */ track = Utility.Utf16ToUtf8(track + " "); artist = Utility.Utf16ToUtf8("by " + artist); // Next line, shows the artist // There are characters at the end of each line which Discord renders poorly // (side-effect of Utf8, I guess?) so we need touse a substring instead presence.state = artist.Substring(0, artist.Length - 1); presence.details = track.Substring(0, track.Length - 1); // Hovering over the image presents the album name presence.largeImageText = album; /* Next block is fetching the album image from Discord's * server. They don't allow spaces in their file names, so * we need to convert them into underscores. */ char[] albumArray = album.ToCharArray(); // Create a char array because we can't edit strings // Search album string for spaces for (int i = 0; i < album.Length; i++) { // If the current character is a space, turn it into an underscore // If the current character is an apostrophe, turn it into an underscore (discord doesnt support them and does this too) if (album[i] == ' ' || album[i] == '\'') { albumArray[i] = '_'; } // Otherwise, just continue on else { albumArray[i] = album[i]; } } // Create a string from the array, in lowercase string newAlbum = new String(albumArray).ToLower(); newAlbum = checkAlbumList(newAlbum); // Set the album art to the manipulated album string. presence.largeImageKey = newAlbum; // Set the small image to the playback status. if (playing) { presence.smallImageKey = "playing"; } else { presence.smallImageKey = "paused"; } DiscordRPC.UpdatePresence(ref presence); }
public override void Update(DiscordRPC.RichPresence RP) { // DiscordRpc.UpdatePresence(RP); // RP.details = Text1; // RP.state = Text2; // RP.largeImageKey = ImgLarge; // RP.largeImageText = TextLarge; // RP.smallImageKey = ImgSmall; // RP.smallImageText = TextSmall; }
/// <summary> /// Creats a new Presence object, copying values of the Rich Presence /// </summary> /// <param name="presence">The rich presence, often received by discord.</param> public DiscordPresence(DiscordRPC.RichPresence presence) { if (presence != null) { this.state = presence.State; this.details = presence.Details; this.party = presence.HasParty() ? new DiscordParty(presence.Party) : new DiscordParty(); this.secrets = presence.HasSecrets() ? new DiscordSecrets(presence.Secrets) : new DiscordSecrets(); if (presence.HasAssets()) { this.smallAsset = new DiscordAsset() { image = presence.Assets.SmallImageKey, tooltip = presence.Assets.SmallImageText, snowflake = presence.Assets.SmallImageID.GetValueOrDefault(0) }; this.largeAsset = new DiscordAsset() { image = presence.Assets.LargeImageKey, tooltip = presence.Assets.LargeImageText, snowflake = presence.Assets.LargeImageID.GetValueOrDefault(0) }; } else { this.smallAsset = new DiscordAsset(); this.largeAsset = new DiscordAsset(); } if (presence.HasTimestamps()) { //This could probably be made simpler this.startTime = presence.Timestamps.Start.HasValue ? new DiscordTimestamp((long)presence.Timestamps.StartUnixMilliseconds.Value) : DiscordTimestamp.Invalid; this.endTime = presence.Timestamps.End.HasValue ? new DiscordTimestamp((long)presence.Timestamps.EndUnixMilliseconds.Value) : DiscordTimestamp.Invalid; } } else { this.state = ""; this.details = ""; this.party = new DiscordParty(); this.secrets = new DiscordSecrets(); this.smallAsset = new DiscordAsset(); this.largeAsset = new DiscordAsset(); this.startTime = DiscordTimestamp.Invalid; this.endTime = DiscordTimestamp.Invalid; } }
/// <summary> /// Converts this object into a new instance of a rich presence, ready to be sent to the discord client. /// </summary> /// <returns>A new instance of a rich presence, ready to be sent to the discord client.</returns> public DiscordRPC.RichPresence ToRichPresence() { var presence = new DiscordRPC.RichPresence(); presence.State = this.state; presence.Details = this.details; presence.Party = !this.party.IsEmpty() ? this.party.ToRichParty() : null; presence.Secrets = !this.secrets.IsEmpty() ? this.secrets.ToRichSecrets() : null; if ((smallAsset != null && !smallAsset.IsEmpty()) || (largeAsset != null && !largeAsset.IsEmpty())) { presence.Assets = new DiscordRPC.Assets() { SmallImageKey = smallAsset.image, SmallImageText = smallAsset.tooltip, LargeImageKey = largeAsset.image, LargeImageText = largeAsset.tooltip }; } if (startTime.IsValid() || endTime.IsValid()) { presence.Timestamps = new DiscordRPC.Timestamps(); if (startTime.IsValid()) { presence.Timestamps.Start = startTime.GetDateTime(); } if (endTime.IsValid()) { presence.Timestamps.End = endTime.GetDateTime(); } } if (buttons.Length > 0) { presence.Buttons = new DiscordRPC.Button[buttons.Length]; for (int i = 0; i < buttons.Length; i++) { presence.Buttons[i] = new DiscordRPC.Button { Label = buttons[i].label, Url = buttons[i].url }; } } return(presence); }
/// <summary> /// Converts this object into a new instance of a rich presence, ready to be sent to the discord client. /// </summary> /// <returns>A new instance of a rich presence, ready to be sent to the discord client.</returns> public DiscordRPC.RichPresence ToRichPresence() { var presence = new DiscordRPC.RichPresence(); presence.State = this.state; presence.Details = this.details; presence.Party = !this.party.IsEmpty() ? this.party.ToRichParty() : null; presence.Secrets = !this.secrets.IsEmpty() ? this.secrets.ToRichSecrets() : null; if ((smallAsset != null && !smallAsset.IsEmpty()) || (largeAsset != null && !largeAsset.IsEmpty())) { presence.Assets = new DiscordRPC.Assets() { SmallImageKey = smallAsset.image, SmallImageText = smallAsset.tooltip, LargeImageKey = largeAsset.image, LargeImageText = largeAsset.tooltip }; } if (startTime.IsValid() || endTime.IsValid()) { presence.Timestamps = new DiscordRPC.Timestamps(); if (startTime.IsValid()) { presence.Timestamps.Start = startTime.GetDateTime(); } if (endTime.IsValid()) { presence.Timestamps.End = endTime.GetDateTime(); } } if ((firstButton != null && !firstButton.IsEmpty()) || (secondButton != null && !secondButton.IsEmpty())) { presence.Buttons = new DiscordRPC.Button[] { new DiscordRPC.Button { Label = firstButton.label, Url = firstButton.url }, new DiscordRPC.Button { Label = secondButton.label, Url = secondButton.url } }; } return(presence); }
private void UpdatePresence(string song, string duration, int position, string state = "Listening to music") { DiscordRPC.RichPresence presence = new DiscordRPC.RichPresence(); presence.state = state; song = Utility.Utf16ToUtf8(song); presence.details = song.Substring(0, song.Length - 1); presence.largeImageKey = "musicbee"; long now = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; presence.startTimestamp = now - position; // string[] durations = duration.Split(':'); // long end = now + System.Convert.ToInt64(durations[0]) * 60 + System.Convert.ToInt64(durations[1]); // presence.endTimestamp = end; DiscordRPC.UpdatePresence(ref presence); }
public override void Update(DiscordRPC.RichPresence RP) { // RP.largeImageKey = "winmedia"; // RP.largeImageText = "Windoware is best"; IntPtr Handle = FindWindow("WMPlayerApp", "Windows Media Player"); TreeWalker walker = TreeWalker.ControlViewWalker; AutomationElement Player = AutomationElement.FromHandle(Handle); AutomationElement AppHost = walker.GetFirstChild(Player); AutomationElement SkinHost = walker.GetFirstChild(AppHost); AutomationElement Con = walker.GetFirstChild(SkinHost); AutomationElement song = walker.GetFirstChild(Con); foreach (object i in song.CachedChildren) { Console.WriteLine(i); } // DiscordRpc.UpdatePresence(RP); }
public override void Update(DiscordRPC.RichPresence RP) { WinType Type = WinType; if (WinType == WinType.Auto) { // Insert code to detect windows version } Type = WinType.Win10; // RP.smallImageKey = ""; // RP.smallImageText = ""; // RP.startTimestamp = 0; // RP.endTimestamp = 0; // RP.largeImageText = ""; switch (Type) { case WinType.Win10: // RP.details = "Windows 10"; // RP.largeImageKey = "win8"; // RP.largeImageText = "Inserting spyware..."; long ticks = Stopwatch.GetTimestamp(); double uptime = ((double)ticks) / Stopwatch.Frequency; TimeSpan uptimeSpan = TimeSpan.FromSeconds(uptime); //RP.state = $"{uptimeSpan.Hours} h {uptimeSpan.Minutes} m"; break; case WinType.Win8: // Windows 8 icon break; case WinType.Win7: // Windows 7 icon break; case WinType.WinXP: // Windows XP icon break; } // Pick a random string // DiscordRpc.UpdatePresence(RP); }
/// <summary> /// Converts this object into a new instance of a rich presence, ready to be sent to the discord client. /// </summary> /// <returns>A new instance of a rich presence, ready to be sent to the discord client.</returns> public DiscordRPC.RichPresence ToRichPresence() { var presence = new DiscordRPC.RichPresence(); presence.State = this.state; presence.Details = this.details; presence.Party = !this.party.IsEmpty() ? this.party.ToRichParty() : null; presence.Secrets = !this.secrets.IsEmpty() ? this.secrets.ToRichSecrets() : null; if (!smallAsset.IsEmpty() || !largeAsset.IsEmpty()) { presence.Assets = new DiscordRPC.Assets() { SmallImageKey = smallAsset.image, SmallImageText = smallAsset.tooltip, LargeImageKey = largeAsset.image, LargeImageText = largeAsset.tooltip }; } if (startTime.IsValid() || endTime.IsValid()) { presence.Timestamps = new DiscordRPC.Timestamps(); if (startTime.IsValid()) { presence.Timestamps.Start = startTime.GetDateTime(); } if (endTime.IsValid()) { presence.Timestamps.End = endTime.GetDateTime(); } } return(presence); }
public override void Update(DiscordRPC.RichPresence RP) { // RP.state = ""; Process[] p = Process.GetProcessesByName("firefox"); // RP.largeImageKey = "firefoxnightly"; // RP.largeImageText = "Browsing..."; // RP.details = Proc.MainWindowTitle; // // if (RP.details.Contains(" - Firefox Nightly")) // RP.details = RP.details.Replace(" - Firefox Nightly", ""); // else // RP.details = RP.details.Replace(" - Firefox", ""); //int Count = 0; // while (RP.details.StartsWith("(")) // { // RP.details = RP.details.Replace($"({Count})", ""); // Count++; // } // Console.WriteLine(RP.details); // if (RP.details.Contains(" - YouTube")) // { // RP.details = RP.details.Replace(" - YouTube", ""); // RP.smallImageKey = "youtube"; // RP.smallImageText = "YouTube"; // if (RP.details.Contains(" [Monstercat Release]")) // { // RP.details = RP.details.Replace(" [Monstercat Release]", ""); // RP.smallImageText = "YouTube - Monstercat"; // } // } // else if (RP.details == "Google" || RP.details.Contains("Google Search")) // { // RP.details = "Searching Google"; // RP.smallImageKey = "google"; // RP.smallImageText = "Never use bing"; // } // else if (RP.details.EndsWith(" - Gmail")) // { // RP.details = "Gmail"; // RP.state = "Reading emails"; // RP.smallImageKey = "google"; // RP.smallImageText = "Never use bing"; // } // else if (RP.details.StartsWith("Discord - ")) // { // RP.state = RP.details.Replace("Discord - ", ""); // RP.details = "Discord"; // RP.smallImageKey = "discord"; // RP.smallImageText = "X days before outage"; // } // else if (RP.details.EndsWith(" | Trello") && RP.details.Contains("(")) // { // RP.state = RP.details.Replace(" | Trello", ""); // // RP.smallImageKey = "trello"; // RP.smallImageText = "Playing with chalk"; // if (RP.state == "Home" || RP.state == "Boards" || RP.state == "Profile" || RP.state == "Cards" || RP.state == "Settings" || RP.state == "Billing" || RP.state == "Keyboard Shortcuts") // { // RP.details = "Trello"; // RP.state = "Viewing profile"; // } // else // { // RP.details = "- Trello Board -"; // } // } // if (RP.details.Length > 25) // { // IEnumerable<string> Strings = ChunksUpto(RP.details, 25); // int Count2 = 0; // foreach (string S in Strings) // { // if (Count2 == 0) RP.details = S; // if (Count2 != 0) RP.state += S; // Count2++; // } // } // DiscordRpc.UpdatePresence(RP); }
public override void Update(DiscordRPC.RichPresence RP) { //DiscordRpc.UpdatePresence(RP); }
public static extern void UpdatePresence(ref DiscordRPC.RichPresence presence);
public virtual void Update(DiscordRPC.RichPresence rp) { }
public override void Update(DiscordRPC.RichPresence RP) { }