Skip to content

Commit a4a5905

Browse files
committed
Add configuration option to suppress RPC connection error notifications
Useful if Discord is not permanently running (e.g. no auto start-up)
1 parent 2d3a276 commit a4a5905

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@
691691
"default": false,
692692
"description": "Suppresses all notifications from the extension."
693693
},
694+
"vscord.behaviour.supressRpcCouldNotConnect": {
695+
"type": "boolean",
696+
"default": false,
697+
"description": "Suppresses \"RPC_COULD_NOT_CONNECT\" notification."
698+
},
694699
"vscord.behaviour.prioritizeLanguagesOverExtensions": {
695700
"type": "boolean",
696701
"default": false,

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export interface ExtensionConfigurationType {
109109
"file.size.spacer": string;
110110
"behaviour.additionalFileMapping": Record<string, string>;
111111
"behaviour.suppressNotifications": boolean;
112+
"behaviour.supressRpcCouldNotConnect": boolean;
112113
"behaviour.prioritizeLanguagesOverExtensions": boolean;
113114
"behaviour.statusBarAlignment": "Left" | "Right";
114115
"behaviour.debug": boolean;

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export const CONFIG_KEYS = {
201201
Behaviour: {
202202
AdditionalFileMapping: "behaviour.additionalFileMapping" as const,
203203
SuppressNotifications: "behaviour.suppressNotifications" as const,
204+
SuppressRpcCouldNotConnect: "behaviour.supressRpcCouldNotConnect" as const,
204205
PrioritizeLanguagesOverExtensions: "behaviour.prioritizeLanguagesOverExtensions" as const,
205206
StatusBarAlignment: "behaviour.statusBarAlignment" as const,
206207
Debug: "behaviour.debug" as const

src/controller.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ export class RPCController {
3636

3737
logError("Encountered following error while trying to login:", error);
3838
editor.setStatusBarItem(StatusBarMode.Disconnected);
39-
if (!config.get(CONFIG_KEYS.Behaviour.SuppressNotifications))
39+
if (!config.get(CONFIG_KEYS.Behaviour.SuppressNotifications) &&
40+
(error.name !== "RPC_COULD_NOT_CONNECT" || !config.get(CONFIG_KEYS.Behaviour.SuppressRpcCouldNotConnect))
41+
) {
4042
window.showErrorMessage("Failed to connect to Discord Gateway");
43+
}
4144
await this.client?.destroy();
4245
logInfo("[002] Destroyed Discord RPC client");
4346
});

0 commit comments

Comments
 (0)