feat: add more useful output for the rich presence
This commit is contained in:
parent
0a97e575f0
commit
d186b17763
1 changed files with 8 additions and 7 deletions
|
@ -20,18 +20,19 @@ export function deactivate(context: ExtensionContext) {}
|
||||||
|
|
||||||
function setActivity(rpc: Client): void {
|
function setActivity(rpc: Client): void {
|
||||||
if (!rpc) return;
|
if (!rpc) return;
|
||||||
const startTimestamp = Date.now();
|
|
||||||
const activity = {
|
const activity = {
|
||||||
details: window.activeTextEditor ? `${basename(window.activeTextEditor.document.fileName)}` : 'Idle.',
|
details: window.activeTextEditor ? `Editing ${basename(window.activeTextEditor.document.fileName)}` : 'Idle.',
|
||||||
state: 'No idea.',
|
state: typeof workspace.workspaceFolders !== 'undefined' ? `Workspaces: ${workspace.workspaceFolders.map(folder => folder.name).join(' | ')}` : 'Idling.',
|
||||||
startTimestamp,
|
startTimestamp: new Date().getTime() / 1000,
|
||||||
largeImageKey: 'vscode-big',
|
largeImageKey: window.activeTextEditor ? extname(basename(window.activeTextEditor.document.fileName)).substring(1) : 'vscode-big',
|
||||||
largeImageText: 'No really, nothing yet',
|
largeImageText: window.activeTextEditor ? window.activeTextEditor.document.languageId : 'Idling.',
|
||||||
smallImageKey: 'vscode',
|
smallImageKey: 'vscode',
|
||||||
smallImageText: 'What did you expect?',
|
smallImageText: 'Visual Studio Code',
|
||||||
instance: false
|
instance: false
|
||||||
};
|
};
|
||||||
rpc.setActivity(activity).catch(error =>
|
rpc.setActivity(activity).catch(error =>
|
||||||
window.showErrorMessage(`DiscordRPC: ${error.message}`)
|
window.showErrorMessage(`DiscordRPC: ${error.message}`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.on('unhandledRejection', err => console.error(err));
|
||||||
|
|
Loading…
Reference in a new issue