|
1 | 1 | import { type Disposable, type WindowState, debug, languages, window, workspace, commands } from "vscode";
|
2 | 2 | import { type SetActivity, type SetActivityResponse, Client } from "@xhayper/discord-rpc";
|
| 3 | +import type { GatewayActivityButton } from "discord-api-types/v10"; |
3 | 4 | import { getApplicationId } from "./helpers/getApplicationId";
|
4 | 5 | import { activity, onDiagnosticsChange } from "./activity";
|
5 | 6 | import { StatusBarMode, editor } from "./editor";
|
| 7 | +import { validURL } from "./helpers/validURL"; |
6 | 8 | import { throttle } from "./helpers/throttle";
|
7 | 9 | import { logError, logInfo } from "./logger";
|
8 | 10 | import { CONFIG_KEYS } from "./constants";
|
@@ -175,6 +177,20 @@ export class RPCController {
|
175 | 177 | this.state.instance = true;
|
176 | 178 | if (!this.state || Object.keys(this.state).length === 0 || !this.canSendActivity)
|
177 | 179 | return void this.client.user?.clearActivity(process.pid);
|
| 180 | + const filteredButton: GatewayActivityButton[] = []; |
| 181 | + this.state.buttons = (this.state.buttons ?? []).filter((button) => { |
| 182 | + const isValid = validURL(button.url); |
| 183 | + if (!isValid) filteredButton.push(button); |
| 184 | + return isValid; |
| 185 | + }); |
| 186 | + |
| 187 | + if (filteredButton.length > 0) |
| 188 | + logInfo( |
| 189 | + "[005]", |
| 190 | + "Invalid buttons!\n", |
| 191 | + filteredButton.map((button) => JSON.stringify(button, null, 2)).join("\n") |
| 192 | + ); |
| 193 | + |
178 | 194 | return this.client.user?.setActivity(this.state, process.pid);
|
179 | 195 | }
|
180 | 196 |
|
|
0 commit comments