2025-09-27 19:17:06 +02:00
|
|
|
import { registerCommand } from "@vendetta/commands";
|
|
|
|
|
import { storage } from "@vendetta/plugin";
|
2025-09-27 19:56:56 +02:00
|
|
|
import {
|
2025-10-07 11:45:12 +02:00
|
|
|
catFactCommand,
|
|
|
|
|
dogFactCommand,
|
|
|
|
|
uselessFactCommand,
|
2025-09-27 19:56:56 +02:00
|
|
|
} from "./src/commands/facts";
|
|
|
|
|
import { pluginListCommand, themeListCommand } from "./src/commands/lists";
|
|
|
|
|
import { petPetCommand } from "./src/commands/petpet";
|
2025-09-27 20:04:06 +02:00
|
|
|
import { konoSelfCommand, konoSendCommand } from "./src/commands/konochan";
|
2025-09-27 23:47:29 +02:00
|
|
|
import { firstMessageCommand } from "./src/commands/firstmessage";
|
2025-09-30 19:03:33 +02:00
|
|
|
import { sysinfoCommand } from "./src/commands/sysinfo";
|
|
|
|
|
import {
|
2025-10-07 11:45:12 +02:00
|
|
|
spotifyTrackCommand,
|
|
|
|
|
spotifyAlbumCommand,
|
|
|
|
|
spotifyArtistsCommand,
|
|
|
|
|
spotifyCoverCommand,
|
2025-09-30 19:03:33 +02:00
|
|
|
} from "./src/commands/spotify";
|
2025-10-01 15:41:01 +02:00
|
|
|
import { garyCommand } from "./src/commands/gary";
|
2025-10-01 21:10:41 +02:00
|
|
|
import { lovefemboysCommand } from "./src/commands/lovefemboys";
|
2025-10-02 23:23:14 +02:00
|
|
|
import { ipCommand } from "./src/commands/ip";
|
|
|
|
|
import { nekoslifeCommand } from "./src/commands/nekoslife";
|
2025-10-07 11:45:12 +02:00
|
|
|
import {
|
|
|
|
|
friendInviteCreateCommand,
|
|
|
|
|
friendInviteViewCommand,
|
|
|
|
|
friendInviteRevokeCommand,
|
|
|
|
|
} from "./src/commands/friendinvites";
|
2025-12-09 22:28:25 +01:00
|
|
|
import settings from "./settings/settings";
|
|
|
|
|
import patchSidebar from "./sidebar";
|
2025-09-27 19:17:06 +02:00
|
|
|
|
2025-09-27 19:40:15 +02:00
|
|
|
if (!storage.factSettings) {
|
2025-10-07 11:45:12 +02:00
|
|
|
storage.factSettings = {
|
|
|
|
|
sendAsReply: true,
|
|
|
|
|
includeCitation: false,
|
|
|
|
|
};
|
2025-09-27 19:40:15 +02:00
|
|
|
}
|
|
|
|
|
if (!storage.listSettings) {
|
2025-10-07 11:45:12 +02:00
|
|
|
storage.listSettings = {
|
|
|
|
|
pluginListAlwaysDetailed: false,
|
|
|
|
|
themeListAlwaysDetailed: false,
|
|
|
|
|
};
|
2025-09-27 19:40:15 +02:00
|
|
|
}
|
2025-10-01 15:41:01 +02:00
|
|
|
if (!storage.garySettings) {
|
2025-10-07 11:45:12 +02:00
|
|
|
storage.garySettings = {
|
|
|
|
|
imageSource: "gary",
|
|
|
|
|
};
|
2025-10-01 15:41:01 +02:00
|
|
|
}
|
2025-09-27 20:30:21 +02:00
|
|
|
if (!storage.enabledCommands) {
|
2025-10-07 11:45:12 +02:00
|
|
|
storage.enabledCommands = {
|
|
|
|
|
catfact: true,
|
|
|
|
|
dogfact: true,
|
|
|
|
|
useless: true,
|
|
|
|
|
petpet: true,
|
|
|
|
|
pluginList: true,
|
|
|
|
|
themeList: true,
|
|
|
|
|
konoself: true,
|
|
|
|
|
konosend: true,
|
|
|
|
|
firstmessage: true,
|
|
|
|
|
sysinfo: true,
|
|
|
|
|
spotifyTrack: true,
|
|
|
|
|
spotifyAlbum: true,
|
|
|
|
|
spotifyArtists: true,
|
|
|
|
|
spotifyCover: true,
|
|
|
|
|
gary: true,
|
|
|
|
|
ip: true,
|
|
|
|
|
lovefemboys: false,
|
|
|
|
|
nekoslife: false,
|
|
|
|
|
friendInviteCreate: true,
|
|
|
|
|
friendInviteView: true,
|
|
|
|
|
friendInviteRevoke: true,
|
|
|
|
|
};
|
2025-10-01 21:10:41 +02:00
|
|
|
}
|
|
|
|
|
if (!storage.hiddenSettings) {
|
2025-10-07 11:45:12 +02:00
|
|
|
storage.hiddenSettings = {
|
|
|
|
|
enabled: false,
|
|
|
|
|
visible: false,
|
|
|
|
|
konochanBypassNsfw: false,
|
|
|
|
|
};
|
2025-09-27 20:30:21 +02:00
|
|
|
}
|
2025-12-09 22:28:25 +01:00
|
|
|
// sidebar enabled setting
|
|
|
|
|
if (storage.sidebarEnabled === undefined) {
|
|
|
|
|
storage.sidebarEnabled = true;
|
|
|
|
|
}
|
2025-09-27 20:30:21 +02:00
|
|
|
|
|
|
|
|
const commandMap = {
|
2025-10-07 11:45:12 +02:00
|
|
|
catfact: catFactCommand,
|
|
|
|
|
dogfact: dogFactCommand,
|
|
|
|
|
useless: uselessFactCommand,
|
|
|
|
|
petpet: petPetCommand,
|
|
|
|
|
pluginList: pluginListCommand,
|
|
|
|
|
themeList: themeListCommand,
|
|
|
|
|
konoself: konoSelfCommand,
|
|
|
|
|
konosend: konoSendCommand,
|
|
|
|
|
firstmessage: firstMessageCommand,
|
|
|
|
|
sysinfo: sysinfoCommand,
|
|
|
|
|
spotifyTrack: spotifyTrackCommand,
|
|
|
|
|
spotifyAlbum: spotifyAlbumCommand,
|
|
|
|
|
spotifyArtists: spotifyArtistsCommand,
|
|
|
|
|
spotifyCover: spotifyCoverCommand,
|
|
|
|
|
gary: garyCommand,
|
|
|
|
|
ip: ipCommand,
|
|
|
|
|
lovefemboys: lovefemboysCommand,
|
|
|
|
|
nekoslife: nekoslifeCommand,
|
|
|
|
|
friendInviteCreate: friendInviteCreateCommand,
|
|
|
|
|
friendInviteView: friendInviteViewCommand,
|
|
|
|
|
friendInviteRevoke: friendInviteRevokeCommand,
|
2025-09-27 20:30:21 +02:00
|
|
|
};
|
|
|
|
|
|
2025-09-27 19:56:56 +02:00
|
|
|
let commands: Array<() => void> = [];
|
2025-12-09 22:28:25 +01:00
|
|
|
let sidebarUnpatch: (() => void) | undefined;
|
2025-09-27 19:56:56 +02:00
|
|
|
|
2025-09-27 19:17:06 +02:00
|
|
|
export default {
|
2025-10-07 11:45:12 +02:00
|
|
|
onLoad: () => {
|
2025-12-09 22:28:25 +01:00
|
|
|
console.log("[Commands Plugin] Loading...");
|
|
|
|
|
|
|
|
|
|
// Patch sidebar if enabled
|
|
|
|
|
if (storage.sidebarEnabled !== false) {
|
|
|
|
|
try {
|
|
|
|
|
sidebarUnpatch = patchSidebar();
|
|
|
|
|
console.log("[Commands Plugin] Sidebar patched successfully");
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("[Commands Plugin] Failed to patch sidebar:", error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Register commands
|
2025-10-07 11:45:12 +02:00
|
|
|
for (const [key, command] of Object.entries(commandMap)) {
|
|
|
|
|
if (storage.enabledCommands[key]) {
|
2025-12-09 22:28:25 +01:00
|
|
|
try {
|
2026-01-24 00:27:30 +01:00
|
|
|
commands.push(registerCommand(command as any));
|
2025-12-09 22:28:25 +01:00
|
|
|
console.log(`[Commands Plugin] Registered command: ${key}`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(
|
|
|
|
|
`[Commands Plugin] Failed to register command ${key}:`,
|
|
|
|
|
error,
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-10-07 11:45:12 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onUnload: () => {
|
2025-12-09 22:28:25 +01:00
|
|
|
console.log("[Commands Plugin] Unloading...");
|
|
|
|
|
|
|
|
|
|
// Unregister commands
|
|
|
|
|
commands.forEach((unregister) => {
|
|
|
|
|
try {
|
|
|
|
|
unregister();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// Ignore errors during cleanup
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-10-07 11:45:12 +02:00
|
|
|
commands = [];
|
2025-12-09 22:28:25 +01:00
|
|
|
|
|
|
|
|
// Unpatch sidebar
|
|
|
|
|
if (sidebarUnpatch) {
|
|
|
|
|
try {
|
|
|
|
|
sidebarUnpatch();
|
|
|
|
|
sidebarUnpatch = undefined;
|
|
|
|
|
console.log("[Commands Plugin] Sidebar unpatched");
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("[Commands Plugin] Failed to unpatch sidebar:", error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-07 11:45:12 +02:00
|
|
|
},
|
|
|
|
|
settings,
|
2025-09-27 19:17:06 +02:00
|
|
|
};
|