static void Start() { Debug.ClearDeveloperConsole(); Debug.Log("Discord: init"); applicationId = editorAppId; callbackCalls = 0; 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); started = true; string[] s = Application.dataPath.Split('/'); string projectName = s[s.Length - 2]; Debug.Log("project = " + projectName); presence.details = string.Format("Working on {0}, in scene {1}", projectName, SceneManager.GetActiveScene().name); presence.largeImageKey = string.Format("unityicon"); presence.startTimestamp = EditorPrefs.GetInt("discordEpoch"); DiscordRpc.UpdatePresence(presence); DiscordRpc.RunCallbacks(); }
/// <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); }
protected override void Initialize() { DiscordRpc.Initialize( Config.Instance.ApplicationId, ref eh, true, null ); dte = (DTE)GetService(typeof(SDTE)); events = dte.Events; timestamp = DiscordRpc.GetTimestamp(); rp.startTimestamp = null; rp.endTimestamp = null; rp.largeImageKey = "visualstudio"; rp.largeImageText = "Visual Studio"; DiscordRpc.UpdatePresence(rp); DiscordRpc.RunCallbacks(); events.SolutionEvents.Opened += SolutionEvents_Opened; events.SolutionEvents.AfterClosing += SolutionEvents_Closed; events.WindowEvents.WindowActivated += WindowEvents_WindowActivated; base.Initialize(); Log.Info("Initialized."); }
// Connect button handler private void discordConnectButton_Click(object sender, EventArgs e) { if (initialized) { return; } if (DISCORD_CLIENT_ID == "") { updateStatus("Missing Discord client ID"); return; } // Initialize the event handlers and DiscordRpc so we can begin // updating our rich presence handlers = new DiscordRpc.EventHandlers { readyCallback = Ready, }; handlers.disconnectedCallback += Disconnected; handlers.errorCallback += Error; DiscordRpc.Initialize(DISCORD_CLIENT_ID, ref handlers, true, null); updateStatus("Initialized!"); DiscordRpc.RunCallbacks(); initialized = true; timer1.Enabled = true; }
private static void RunCallbacksController() { while (!CallbacksCts.IsCancellationRequested) { DiscordRpc.RunCallbacks(); Thread.Sleep(1000); } }
private static void CheckConnected(object sender, EventArgs e) { if (ready) { return; } DiscordRpc.RunCallbacks(); }
void WindowEvents_WindowActivated(Window GotFocus, Window LostFocus) { CheckTimestamp(); if (Config.Instance.ShowProjectName && dte.Solution != null && File.Exists(dte.Solution.FullName)) { var name = Path.GetFileNameWithoutExtension(new FileInfo(dte.Solution.FullName).FullName); var str = Config.Instance.GetString("VS_WORKING_ON_PROJECT"); rp.state = str.exists ? str.text + name : name; } if (GotFocus != null && GotFocus.Document != null && File.Exists(GotFocus.Document.FullName)) { rp.largeImageKey = null; rp.largeImageText = null; rp.smallImageKey = null; rp.smallImageText = null; var filename = new FileInfo(GotFocus.Document.FullName).FullName; var extension = Path.GetExtension(filename).Substring(1); var name = Path.GetFileName(filename); var str = Config.Instance.GetString("VS_EDITING_FILE"); rp.details = str.exists ? str.text + name : name; var ext = Config.Instance.Extensions.Find(e => e.Extension == extension); if (ext != null) { if (ext.HasLargeImageKey) { rp.largeImageKey = ext.LargeImageKey; } if (ext.HasLargeImageText) { rp.largeImageText = ext.LargeImageText; } if (ext.HasSmallImageKey) { rp.smallImageKey = ext.SmallImageKey; } if (ext.HasSmallImageText) { rp.smallImageText = ext.SmallImageText; } } } DiscordRpc.UpdatePresence(rp); DiscordRpc.RunCallbacks(); }
void Update() { try { DiscordRpc.RunCallbacks(); } catch (DllNotFoundException e) { Debug.Log("Discord controller not found! Probably just a non-Windows build idk"); enabled = false; } }
void Update() { DiscordRpc.RunCallbacks(); timeUntilNextUpdate -= Time.deltaTime; if (timeUntilNextUpdate <= 0) { timeUntilNextUpdate = 1; UpdateRichPresence(); } }
void Update() { if (mapName == null) { presence.state = "Nothing"; DiscordRpc.UpdatePresence(presence); } else { presence.state = string.Format("{0}", mapName); DiscordRpc.UpdatePresence(presence); } DiscordRpc.RunCallbacks(); }
public void Update() { try { if (isInitialized) { DiscordRpc.RunCallbacks(); } } catch (Exception ex) { Trace.TraceError("Error processing discord-RPC events: {0}", ex); } }
void Update() { DiscordRpc.RunCallbacks(); if (RO.Settings.peliSäätäjä.all_players[0].Angira == true) { playingAs = playingAngira; fightingWith = "Fighting with Angira"; } if (RO.Settings.peliSäätäjä.all_players[0].Grontto == true) { playingAs = playingGrontto; fightingWith = "Fighting with Grontto"; } }
private void TimerTick(object stateInfo) { if (!_spotifyEnabled && SpotifyLocalAPI.IsSpotifyRunning()) { if (_spotify.Connect()) { _spotifyEnabled = true; _stoppedSince = 0; SetStatus("Connected"); } } if (_spotifyEnabled && !SpotifyLocalAPI.IsSpotifyRunning()) { _spotifyEnabled = false; if (_stoppedSince == 0) { _stoppedSince = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } SetStatus("Spotify Not Running"); } _seconds++; if (_seconds == 15) { if (_spotifyEnabled) { UpdatePresenceSpotify(); } else { UpdatePresenceStopped(); } _seconds = 0; } try { Dispatcher.InvokeAsync(() => DiscordRpc.RunCallbacks()); } catch (AccessViolationException e) { Console.WriteLine(e); } SetProgress(_seconds); }
public static void Main(string[] args) { Console.WriteLine("Discord: init"); handlers = new DiscordRpc.EventHandlers { readyCallback = ReadyCallback, disconnectedCallback = DisconnectedCallback, errorCallback = ErrorCallback, joinCallback = JoinCallback, spectateCallback = SpectateCallback, requestCallback = RequestCallback }; DiscordRpc.Initialize(applicationId, ref handlers, false, null); while (true) { DiscordRpc.RunCallbacks(); } }
private void Initialize() { _spotify = new SpotifyLocalAPI(); var handlers = new DiscordRpc.EventHandlers { readyCallback = HandleReady, errorCallback = HandleError, disconnectedCallback = HandleDisconnected }; DiscordRpc.Initialize("383020355553460224", ref handlers, true, null); DiscordRpc.RunCallbacks(); SetStatus("Initializing"); _tickTimer = new Timer(TimerTick, null, 1000, 1000); }
public void Update() { DiscordRpc.RunCallbacks(); if (inLobby && LobbyManager_Specific.Instance != null) { string id = typeof(LobbyManager_Specific).GetField("mCreatedMatchAtHost", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(LobbyManager_Specific.Instance) as string; if (id.Contains('#')) { id = id.Replace("MonsterProm_", string.Empty).Replace("#", string.Empty); } if (lobbyId != id) { lobbyId = id; Presence.state = lobbyId; DiscordRpc.UpdatePresence(Presence); } } }
void SolutionEvents_Closed() { CheckTimestamp(); rp.state = null; rp.details = null; rp.largeImageKey = "visualstudio"; rp.largeImageText = "Visual Studio"; rp.smallImageKey = null; rp.smallImageText = null; rp.startTimestamp = null; rp.endTimestamp = null; DiscordRpc.UpdatePresence(rp); DiscordRpc.RunCallbacks(); }
void SolutionEvents_Opened() { CheckTimestamp(); if (Config.Instance.ShowProjectName) { var name = Path.GetFileNameWithoutExtension(dte.Solution.FileName); var str = Config.Instance.GetString("VS_WORKING_ON_PROJECT"); rp.state = str.exists ? str.text + name : name; } else { rp.details = null; } DiscordRpc.UpdatePresence(rp); DiscordRpc.RunCallbacks(); }
public void InitializeModule(Vegas vegas) { resetPresence(ref presence, vegas); DiscordRpc.Initialize("434711433112977427", ref callbacks, true, string.Empty); presence.details = "Idling"; vegas.TrackCountChanged += (a, b) => UpdateTrackNumber(vegas); vegas.TrackEventCountChanged += (a, b) => UpdateTrackNumber(vegas); vegas.PlaybackStarted += (a, b) => { isActive = true; GenericNonIdleAction(vegas); }; vegas.PlaybackStopped += (a, b) => { isActive = false; GenericNonIdleAction(vegas); }; vegas.ProjectSaving += (a, b) => GenericNonIdleAction(vegas); vegas.RenderStarted += (a, b) => RenderStarted(vegas); vegas.RenderFinished += (a, b) => RenderEvtFinish(b, vegas); vegas.AppInitialized += (a, b) => loadDummyDocker((Vegas)a); DiscordRpc.RunCallbacks(); DiscordRpc.UpdatePresence(ref presence); idleTimer.Interval = 10000; idleTimer.Tick += (a, b) => IntervalTick(); idleTimer.Start(); }
private void DiscordInit() { _discordStatus = "Discord - Connecting"; stDiscord.Text = _discordStatus; dchn = new DiscordRpc.EventHandlers(); dchn.readyCallback = ReadyCallback; dchn.errorCallback = ErrorCallback; dchn.disconnectedCallback = DisconnectedCallback; DiscordRpc.Initialize(cliid, ref dchn, true, null); _discordStatus = "Discord - Connected?"; stDiscord.Text = _discordStatus; DiscordRpc.RunCallbacks(); DiscordRpc.UpdatePresence(ref dcrp); }
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(); }
void Update() { DiscordRpc.RunCallbacks(); }
/// <summary> /// Calls ReadyCallback(), DisconnectedCallback(), ErrorCallback(). /// </summary> private void RunCallbacks() { DiscordRpc.RunCallbacks(); this.SetStatusBarMessage("Rallbacks run."); }
public static void UpdatePresence() { try { if (Form != null) { if (me == null) { me = MessengerDotNet.MessengerAPI.Me; } var count = MessengerDotNet.MessengerAPI.Contacts.Count(); var stauts = me.Status; var signInName = me.SignInName; CurrentPresence.largeImageKey = "messenger"; if (Form.StatusCheckBox.Checked) { CurrentPresence.smallImageText = ToString(stauts); CurrentPresence.smallImageKey = ToKey(stauts); } //Details if (Form.EmailCheckBox.Checked && Form.NameCheckBox.Checked) { CurrentPresence.details = $"{GetFilteredName()} ({signInName})"; } else if (Form.NameCheckBox.Checked) { CurrentPresence.details = GetFilteredName(); } else if (Form.EmailCheckBox.Checked) { CurrentPresence.details = signInName; } //Invitation Stuff CurrentPresence.partyMax = Form.InviteCheckBox.Checked ? 1500 : 0; CurrentPresence.partySize = Form.ContactsCheckBox.Checked ? count : 1; CurrentPresence.partyId = Form.InviteCheckBox.Checked ? "FriendInvite" : null; CurrentPresence.joinSecret = Form.InviteCheckBox.Checked ? signInName : null; //Contacts count if (Form.InviteCheckBox.Checked) { CurrentPresence.state = Form.ContactsCheckBox.Checked ? "Contacts: " : String.Empty; } else { CurrentPresence.state = Form.ContactsCheckBox.Checked ? count.ToString() + " contacts" : String.Empty; } DiscordRpc.UpdatePresence(ref CurrentPresence); } try { DiscordRpc.RunCallbacks(); } catch (SEHException) { //Ignore } } catch (COMException) { //Ignore } }
void Update() { if (discordToggle.discordconnected == true) { DiscordRpc.RunCallbacks(); DiscordRpc.UpdatePresence(presence); presence.smallImageText = "Current skin"; presence.largeImageText = "Current map"; if (PlayerPrefs.GetInt("map", 0) == 0) { presence.largeImageKey = "normal"; } if (PlayerPrefs.GetInt("map", 0) == 1) { presence.largeImageKey = "beach"; } if (PlayerPrefs.GetInt("skin", 0) == 5) { presence.largeImageKey = "snow"; } if (PlayerPrefs.GetInt("skin", 0) == 0) { presence.smallImageKey = "thanosl"; } if (PlayerPrefs.GetInt("skin", 0) == 1) { presence.smallImageKey = "thanosr"; } if (PlayerPrefs.GetInt("skin", 0) == 2) { presence.smallImageKey = "thanosgr"; } if (PlayerPrefs.GetInt("skin", 0) == 3) { presence.smallImageKey = "thanosgu"; } if (PlayerPrefs.GetInt("skin", 0) == 4) { presence.smallImageKey = "thanosjul"; } if (guiController.actualPlayTime > 0) { if (guiController.sharpmode == true) { presence.details = "Playing \"Sharp shurikens\""; if (guiController.scoreHit > 0) { presence.state = "Curent score: " + guiController.scoreHit; } else { presence.state = "No last score"; } } else if (guiController.newmode == true) { presence.details = "Playing \"Refuel\""; if (guiController.scoreHit > 0) { presence.state = "Current score: " + guiController.scoreHit; } else { presence.state = "No last score"; } } else if (guiController.speedmode == true) { presence.details = "Playing \"Flying Fast\""; presence.state = "Current score: " + guiController.scoreHit; } else if (guiController.scoreHit > 1 && guiController.sharpmode == false && guiController.speedmode == false && guiController.actualPlayTime > 1 && guiController.playTime > 1) { presence.details = "Playing \"Classic\""; if (guiController.scoreHit > 0) { presence.state = "Last score: " + guiController.scoreHit; } else { presence.state = "No last score"; } } } if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("start") || SceneManager.GetActiveScene() == SceneManager.GetSceneByName("gameover")) { presence.details = "In a lobby"; if (guiController.scoreHit > 0) { presence.state = "Last score: " + guiController.scoreHit; } else { presence.state = "No last score"; } } if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("skins")) { presence.details = "Selecting a skin"; if (guiController.scoreHit > 0) { presence.state = "Last score: " + guiController.scoreHit; } else { presence.state = "No last score"; } } if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("stats")) { presence.details = "Viewing stats"; if (guiController.scoreHit > 0) { presence.state = "Last score: " + guiController.scoreHit; } else { presence.state = "No last score"; } } } else if (discordToggle.discordconnected == false) { DiscordRpc.Shutdown(); } }
public static async Task MainAsync() { _presence = new DiscordRpc.RichPresence { state = "Idle", largeImageKey = "npp_logo", largeImageText = "Notepad++", }; _handlers = new DiscordRpc.EventHandlers(); _handlers.readyCallback += ReadyCallback; _handlers.disconnectedCallback += DisconnectedCallback; _handlers.errorCallback += ErrorCallback; _handlers.joinCallback += JoinCallback; _handlers.spectateCallback += SpectateCallback; _handlers.requestCallback += RequestCallback; Console.WriteLine("c"); DiscordRpc.Initialize("420428166536888320", ref _handlers, true, null); Console.WriteLine("b"); DiscordRpc.RunCallbacks(); Console.WriteLine("a"); DiscordRpc.UpdatePresence(ref _presence); while (true) { try { await Task.Delay(3000); var handle = Process.GetProcessesByName("notepad++") .Select(e => e.MainWindowTitle) .FirstOrDefault(e => e.EndsWith("Notepad++")) ?? "null"; var re = Regex.Match(handle, @"\*?(.+?) - Notepad\+\+"); Console.WriteLine(re + " / " + re.Success); if (!re.Success) { _presence.details = ""; _presence.state = "Idle"; _presence.startTimestamp = 0; _presence.largeImageKey = "npp_logo"; _presence.largeImageText = "Notepad++"; DiscordRpc.UpdatePresence(ref _presence); continue; } var group1 = re.Groups[1].Value; var fname = Path.GetFileName(group1); var ext = Path.GetExtension(group1); _presence.details = "Editing:"; _presence.state = handle.StartsWith("*") ? fname + " (unsaved)" : fname; _presence.startTimestamp = StartTime(group1); _presence.largeImageKey = "npp_logo"; _presence.largeImageText = "Notepad++"; DiscordRpc.UpdatePresence(ref _presence); } catch (Exception e) { Console.WriteLine(e); } } }
public override void OnUpdate() { DiscordRpc.RunCallbacks(); }
public void UpdateCallbacks() { DiscordRpc.RunCallbacks(); }
public override void _Process(float delta) { DiscordRpc.RunCallbacks(); }
public override void OnUpdate() { DiscordRpc.RunCallbacks(); // for if we are going to handle invites... }