fix: double check if RPC exists or not in commands

This commit is contained in:
iCrawl 2017-11-24 03:21:27 +01:00
parent b432c06ce9
commit a54dc0767a
No known key found for this signature in database
GPG key ID: E41A6DB922EC2CFE

View file

@ -32,12 +32,14 @@ export function activate(context: ExtensionContext) {
// Register the `discord.enable` command, and set the `enabled` config option to true. // Register the `discord.enable` command, and set the `enabled` config option to true.
const enabler = commands.registerCommand('discord.enable', () => { const enabler = commands.registerCommand('discord.enable', () => {
if (rpc) return;
config.update('enabled', true); config.update('enabled', true);
initRPC(config.get('clientID')); initRPC(config.get('clientID'));
}); });
// Register the `discord.disable` command, and set the `enabled` config option to false. // Register the `discord.disable` command, and set the `enabled` config option to false.
const disabler = commands.registerCommand('discord.disable', () => { const disabler = commands.registerCommand('discord.disable', () => {
if (!rpc) return;
config.update('enabled', false); config.update('enabled', false);
eventHandler.dispose(); eventHandler.dispose();
rpc.setActivity({}); rpc.setActivity({});