mirror of https://github.com/clickscodes/nucleus
parent
64486c49fb
commit
752af46e5e
@ -1,9 +1,9 @@
|
|||||||
import type { Guild } from "discord.js";
|
import type { Guild } from "discord.js";
|
||||||
import type { HaikuClient } from "../utils/haiku/index.js";
|
import type { NucleusClient } from "../utils/client.js";
|
||||||
import guide from "../reflex/guide.js";
|
import guide from "../reflex/guide.js";
|
||||||
|
|
||||||
export const event = "guildCreate";
|
export const event = "guildCreate";
|
||||||
|
|
||||||
export async function callback(_client: HaikuClient, guild: Guild) {
|
export async function callback(_client: NucleusClient, guild: Guild) {
|
||||||
guide(guild);
|
guide(guild);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,23 +1,27 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
export default async function getSubcommandsInFolder(path: string) {
|
export default async function getSubcommandsInFolder(path: string, indent: string = "") {
|
||||||
const files = fs.readdirSync(path, { withFileTypes: true }).filter(
|
const files = fs.readdirSync(path, { withFileTypes: true }).filter(
|
||||||
file => !file.name.endsWith(".ts") && !file.name.endsWith(".map")
|
file => !file.name.endsWith(".ts") && !file.name.endsWith(".map")
|
||||||
);
|
);
|
||||||
const subcommands = [];
|
const subcommands = [];
|
||||||
const subcommandGroups = [];
|
const subcommandGroups = [];
|
||||||
|
let errors = 0;
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
if (file.name === "_meta.js") continue;
|
if (file.name === "_meta.js") continue;
|
||||||
// If its a folder
|
try {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
// Get the _meta.ts file
|
// Get the _meta.ts file
|
||||||
console.log(`│ ├─ Loading subcommand group ${file.name}}`)
|
subcommandGroups.push((await import(`../../../${path}/${file.name}/_meta.js`)).command);
|
||||||
subcommandGroups.push((await import(`../../../${path}/${file.name}/_meta.js`)).command);
|
} else if (file.name.endsWith(".js")) {
|
||||||
} else if (file.name.endsWith(".js")) {
|
// If its a file
|
||||||
// If its a file
|
console.log(`│ ${indent}├─ Loading subcommand ${file.name}`)
|
||||||
console.log(`│ ├─ Loading subcommand ${file.name}}`)
|
subcommands.push((await import(`../../../${path}/${file.name}`)).command);
|
||||||
subcommands.push((await import(`../../../${path}/${file.name}`)).command);
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`│ ${indent}│ └─ Error loading ${file.name}: ${e}`);
|
||||||
|
errors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {subcommands, subcommandGroups};
|
return {subcommands, subcommandGroups, errors};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in new issue