vd-plugins/plugins/Commands/index.ts

108 lines
2.7 KiB
TypeScript
Raw Normal View History

import { registerCommand } from "@vendetta/commands";
import { storage } from "@vendetta/plugin";
import {
catFactCommand,
dogFactCommand,
uselessFactCommand,
} from "./src/commands/facts";
import { pluginListCommand, themeListCommand } from "./src/commands/lists";
import { petPetCommand } from "./src/commands/petpet";
import { konoSelfCommand, konoSendCommand } from "./src/commands/konochan";
import { firstMessageCommand } from "./src/commands/firstmessage";
2025-09-30 19:03:33 +02:00
import { sysinfoCommand } from "./src/commands/sysinfo";
import {
spotifyTrackCommand,
spotifyAlbumCommand,
spotifyArtistsCommand,
spotifyCoverCommand
} from "./src/commands/spotify";
2025-10-01 15:41:01 +02:00
import { garyCommand } from "./src/commands/gary";
import settings from "./settings";
// Initialize storage with default values
if (!storage.factSettings) {
storage.factSettings = {
sendAsReply: true,
includeCitation: false,
};
}
if (!storage.listSettings) {
storage.listSettings = {
pluginListAlwaysDetailed: false,
themeListAlwaysDetailed: false,
};
}
2025-10-01 15:41:01 +02:00
if (!storage.garySettings) {
storage.garySettings = {
imageSource: "gary",
};
}
if (!storage.enabledCommands) {
storage.enabledCommands = {
catfact: true,
dogfact: true,
useless: true,
petpet: true,
pluginList: true,
themeList: true,
konoself: true,
konosend: true,
firstmessage: true,
2025-09-30 19:03:33 +02:00
sysinfo: true,
spotifyTrack: true,
spotifyAlbum: true,
spotifyArtists: true,
spotifyCover: true,
2025-10-01 15:41:01 +02:00
gary: true,
};
}
// Map commands to their storage keys
const commandMap = {
catfact: catFactCommand,
dogfact: dogFactCommand,
useless: uselessFactCommand,
petpet: petPetCommand,
pluginList: pluginListCommand,
themeList: themeListCommand,
konoself: konoSelfCommand,
konosend: konoSendCommand,
firstmessage: firstMessageCommand,
2025-09-30 19:03:33 +02:00
sysinfo: sysinfoCommand,
spotifyTrack: spotifyTrackCommand,
spotifyAlbum: spotifyAlbumCommand,
spotifyArtists: spotifyArtistsCommand,
spotifyCover: spotifyCoverCommand,
2025-10-01 15:41:01 +02:00
gary: garyCommand,
};
// Store registered commands for cleanup
let commands: Array<() => void> = [];
export default {
onLoad: () => {
console.log("[All-In-One Commands] Loading plugin...");
// Register only enabled commands
for (const [key, command] of Object.entries(commandMap)) {
if (storage.enabledCommands[key]) {
commands.push(registerCommand(command));
}
}
console.log("[All-In-One Commands] Plugin loaded successfully!");
},
onUnload: () => {
console.log("[All-In-One Commands] Unloading plugin...");
commands.forEach((unregister) => unregister());
commands = [];
console.log("[All-In-One Commands] Plugin unloaded successfully!");
},
settings,
};