feat: use custom configuration for client ID for those who really know what they are doing which does not include 90% of you

This commit is contained in:
iCrawl 2017-11-23 16:21:46 +01:00
parent d186b17763
commit 15c4888812
No known key found for this signature in database
GPG key ID: E41A6DB922EC2CFE
3 changed files with 44 additions and 5 deletions

BIN
assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -20,6 +20,46 @@
"activationEvents": [
"*"
],
"contributes": {
"configuration": [
{
"title": "Visual Studio Code Discord Configuration",
"type": "object",
"properties": {
"discord.clientID": {
"type": "string",
"default": "383226320970055681",
"description": "Only modify this if you know what you are doing (most of you don't)."
}
}
}
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/iCrawl/discord-vscode.git"
},
"bugs": {
"url": "https://github.com/iCrawl/discord-vscode/issues"
},
"keywords": [
"discord",
"vscode",
"status",
"update",
"rich",
"presence",
"rpc",
"rich presence"
],
"categories": [
"Other"
],
"homepage": "https://github.com/iCrawl/discord-vscode#readme",
"icon": "assets/icon.png",
"galleryBanner": {
"theme": "dark"
},
"dependencies": {
"discord-rpc": "^3.0.0-beta.2"
},

View file

@ -1,17 +1,16 @@
import { Client } from 'discord-rpc';
import { basename, extname } from 'path';
import { ExtensionContext, commands, window, workspace, Uri, TextDocumentChangeEvent } from 'vscode';
import { ExtensionContext, commands, window, workspace, Uri, TextDocumentChangeEvent, TextDocument } from 'vscode';
export function activate(context: ExtensionContext) {
const rpc = new Client({ transport: 'ipc' });
const config = workspace.getConfiguration('discord');
rpc.once('ready', () => {
setActivity(rpc);
workspace.onDidChangeTextDocument((e: TextDocumentChangeEvent) => {
setActivity(rpc);
workspace.onDidChangeTextDocument((e: TextDocumentChangeEvent) => setActivity(rpc));
});
});
rpc.login('').catch(error =>
rpc.login(config.get('clientID')).catch(error =>
window.showErrorMessage(`Could not connect to discord via rpc: ${error.message}`)
);
}