obsidian-discordrpc
obsidian-discordrpc copied to clipboard
Support custom messages/statistics (such as word counts) in rich presence
After months of showing off all my amazing vault names to my friends, I wanted to do a bit more with my Rich Presence. Word count progress as I write, maybe?
I actually added a few lines of code to my own build to achieve this. For example, passing this string to status
makes today's word and character counts appear (thanks to your Better Word Count plugin!):
`${this.getApp().plugins.plugins["better-word-count"].dataManager.todayCounts.words} words, ${this.getApp().plugins.plugins["better-word-count"].dataManager.todayCounts.characters} chars today`
While adding the following to onload()
makes the word count refresh every 30 seconds (staying reasonably updated, while also abiding by Discord API limits), instead of just when a new file is opened:
this.registerInterval(window.setInterval(async () =>
this.setActivity(this.app.vault.getName(), this.currentFile.basename, this.currentFile.extension)
, 30000));
What I'd love to see is some more customizable way to set Rich Presence messages, beyond the vault/filename customization options. For example, maybe the templating syntax for the Better Word Count status bar could also be implemented in this plugin, with the possibility of users also defining their own code snippets such as the words/characters today one?