Initial commit: autoMover, friendsCheck, watchCord plugins and README

This commit is contained in:
X4Lo committed 2026-11-11 17:41:39 +00:00
commit f06f2f493b
11 files changed
+3799

No files matched your search

+90
View File
@@ -0,0 +1,90 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2026 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { app, IpcMainInvokeEvent, shell } from "electron";
import { appendFile, writeFile } from "fs/promises";
import { join } from "path";
const LOG_FILE = "watchcord-logs.txt";
const STATUS_CHANGE_FILE = "watchcord-full-status-changes.json";
function getLogPath(): string {
return join(app.getPath("userData"), LOG_FILE);
}
function getStatusChangePath(): string {
return join(app.getPath("userData"), STATUS_CHANGE_FILE);
}
export async function appendLog(
_: IpcMainInvokeEvent,
logLine: string
): Promise<void> {
const logPath = getLogPath();
await appendFile(logPath, logLine + "\n", "utf-8");
}
export async function clearLogs(_: IpcMainInvokeEvent): Promise<void> {
const logPath = getLogPath();
await writeFile(logPath, "", "utf-8");
}
export async function openLogFile(_: IpcMainInvokeEvent): Promise<void> {
const logPath = getLogPath();
// Create file if it doesn't exist
try {
await appendFile(logPath, "", { flag: "a" });
} catch {
// ignore
}
shell.openPath(logPath);
}
export async function sendWebhook(
_: IpcMainInvokeEvent,
webhookUrl: string,
content: string
): Promise<{ ok: boolean; error?: string }> {
try {
const res = await fetch(webhookUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ content }),
});
return { ok: res.ok };
} catch (e) {
return { ok: false, error: String(e) };
}
}
export async function logFullStatusChange(
_: IpcMainInvokeEvent,
statusChangeObject: any
): Promise<void> {
const statusChangePath = getStatusChangePath();
const timestamp = new Date().toISOString();
const logEntry = {
timestamp,
data: statusChangeObject
};
await appendFile(statusChangePath, JSON.stringify(logEntry, null, 2) + "\n---\n", "utf-8");
}
export async function openStatusChangeFile(_: IpcMainInvokeEvent): Promise<void> {
const statusChangePath = getStatusChangePath();
// Create file if it doesn't exist
try {
await appendFile(statusChangePath, "", { flag: "a" });
} catch {
// ignore
}
shell.openPath(statusChangePath);
}
export async function clearStatusChanges(_: IpcMainInvokeEvent): Promise<void> {
const statusChangePath = getStatusChangePath();
await writeFile(statusChangePath, "", "utf-8");
}