feat: custom string support
This commit is contained in:
parent
04442116dc
commit
4318c325ac
3 changed files with 55 additions and 12 deletions
|
@ -14,9 +14,13 @@ Give me a little bit of time and this will be resolved! 😉
|
|||
|
||||
* Shows what you are editing in VSCode with no bullsh*t involved.
|
||||
* Enable/Disable Rich Presence for individual workspaces (enabled by default).
|
||||
* Automatic reconnect after losing internet or a discord restart/crash. (defaults to 20 reconnect attempts)
|
||||
* Custom string support
|
||||
|
||||
## The rich presence won't show after my PC has been put to sleep / after I lost internet!
|
||||
It will only attempt to reconnect 20 times. After it hit that threshold you will have to manually enable it again. Just open the command pallette and execute the enable command for the extension.
|
||||
It will only attempt to reconnect 20 times. After it hit that threshold you will have to manually enable it again.
|
||||
Just open the command pallette and execute the enable command for the extension.
|
||||
You can also set the reconnectThreshold in the settings to something very high, for example 9999 or Infinity to never stop trying to reconnect.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
42
package.json
42
package.json
|
@ -41,12 +41,52 @@
|
|||
"discord.clientID": {
|
||||
"type": "string",
|
||||
"default": "383226320970055681",
|
||||
"description": "Only modify this if you know what you are doing (most of you don't)."
|
||||
"description": "Only modify this if you know what you are doing (most of you don't)"
|
||||
},
|
||||
"discord.enabled": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Controls if Discord Presence is active"
|
||||
},
|
||||
"discord.reconnectThreshold": {
|
||||
"type": "number",
|
||||
"default": 20,
|
||||
"description": "Decides how often a reconnect attempt should be made before stopping"
|
||||
},
|
||||
"discord.details": {
|
||||
"type": "string",
|
||||
"default": "Editing {filename}",
|
||||
"description": "Custom string for the details section of the rich presence"
|
||||
},
|
||||
"discord.detailsIdle": {
|
||||
"type": "string",
|
||||
"default": "Idling.",
|
||||
"description": "Custom string for the details section of the rich presence when idling"
|
||||
},
|
||||
"discord.workspace": {
|
||||
"type": "string",
|
||||
"default": "Workspace: {workspace}",
|
||||
"description": "Custom string for the state section of the rich presence"
|
||||
},
|
||||
"discord.workspaceIdle": {
|
||||
"type": "string",
|
||||
"default": "Idling.",
|
||||
"description": "Custom string for the state section of the rich presence when idling"
|
||||
},
|
||||
"discord.largeImage": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "Custom string for the largeImageText section of the rich presence"
|
||||
},
|
||||
"discord.largeImageIdle": {
|
||||
"type": "string",
|
||||
"default": "Idling",
|
||||
"description": "Custom string for the largeImageText section of the rich presence when idling"
|
||||
},
|
||||
"discord.smallImage": {
|
||||
"type": "string",
|
||||
"default": "Visual Studio Code",
|
||||
"description": "Custom string for the smallImageText section of the rich presence"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,8 +93,8 @@ function initRPC(clientID: string): void {
|
|||
// Log in to the RPC Client, and check whether or not it errors.
|
||||
rpc.login(clientID).catch(error => {
|
||||
if (reconnect) {
|
||||
// Destroy and dispose of everything after 20 reconnect attempts
|
||||
if (reconnectCounter >= 20) destroyRPC();
|
||||
// Destroy and dispose of everything after a default of 20 reconnect attempts
|
||||
if (reconnectCounter >= config.get('reconnectThreshold')) destroyRPC();
|
||||
else return;
|
||||
}
|
||||
if (error.message.includes('ENOENT')) window.showErrorMessage('No Discord Client detected!');
|
||||
|
@ -126,15 +126,14 @@ function setActivity(): void {
|
|||
if (!rpc) return;
|
||||
if (window.activeTextEditor && window.activeTextEditor.document.fileName === lastKnownFileName) return;
|
||||
lastKnownFileName = window.activeTextEditor ? window.activeTextEditor.document.fileName : null;
|
||||
|
||||
// Create a JSON Object with the user's activity information.
|
||||
const activity = {
|
||||
details: window.activeTextEditor
|
||||
? `Editing ${basename(window.activeTextEditor.document.fileName)}`
|
||||
: 'Idle.',
|
||||
? config.get('details').replace('{filename}', basename(window.activeTextEditor.document.fileName))
|
||||
: config.get('detailsIdle'),
|
||||
state: window.activeTextEditor
|
||||
? `Workspace: ${workspace.getWorkspaceFolder(window.activeTextEditor.document.uri).name}`
|
||||
: 'Idling.',
|
||||
? config.get('workspace').replace('{workspace}', workspace.getWorkspaceFolder(window.activeTextEditor.document.uri).name)
|
||||
: config.get('workspaceIdle'),
|
||||
startTimestamp: new Date().getTime() / 1000,
|
||||
largeImageKey: window.activeTextEditor
|
||||
? extname(basename(window.activeTextEditor.document.fileName)).substring(1)
|
||||
|
@ -142,10 +141,10 @@ function setActivity(): void {
|
|||
|| 'file'
|
||||
: 'vscode-big',
|
||||
largeImageText: window.activeTextEditor
|
||||
? window.activeTextEditor.document.languageId
|
||||
: 'Idling',
|
||||
? config.get('largeImage') || window.activeTextEditor.document.languageId
|
||||
: config.get('largeImageIdle'),
|
||||
smallImageKey: 'vscode',
|
||||
smallImageText: 'Visual Studio Code',
|
||||
smallImageText: config.get('smallImage'),
|
||||
instance: false
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue