From 43c6c21f3b161172071068e1cb36d540a69c4acf Mon Sep 17 00:00:00 2001 From: DuroCodes Date: Fri, 27 Jan 2023 21:28:55 -0500 Subject: [PATCH] feat(docs): add api docs section --- apps/docs/package.json | 3 +- apps/docs/src/components/QuickStart.tsx | 8 +- .../src/components/pages/plugin/newPlugin.tsx | 2 +- apps/docs/src/pages/_meta.json | 3 +- apps/docs/src/pages/docs/_meta.json | 11 +- apps/docs/src/pages/docs/api/index.mdx | 6 - .../classes/@spark.ts/handler/SparkClient.mdx | 437 ++++++++++++++++++ .../@spark.ts/handler/SparkCommand.mdx | 33 ++ .../classes/@spark.ts/handler/SparkEvent.mdx | 31 ++ apps/docs/src/pages/docs/index.mdx | 23 +- .../docs/types/@spark.ts/handler/Command.mdx | 3 + .../types/@spark.ts/handler/CommandPlugin.mdx | 12 + .../types/@spark.ts/handler/CommandType.mdx | 9 + .../types/@spark.ts/handler/Controller.mdx | 10 + .../types/@spark.ts/handler/EventOptions.mdx | 9 + .../types/@spark.ts/handler/EventRunner.mdx | 3 + .../types/@spark.ts/handler/InitPlugin.mdx | 12 + .../types/@spark.ts/handler/SlashCommand.mdx | 13 + .../types/@spark.ts/handler/TextCommand.mdx | 16 + apps/docs/src/pages/guide/_meta.json | 8 + .../{docs => guide}/core-concepts/_meta.json | 0 .../core-concepts/adding-commands.mdx | 2 +- .../core-concepts/adding-events.mdx | 0 .../core-concepts/adding-plugins.mdx | 0 .../core-concepts/publishing-plugins.mdx | 0 apps/docs/src/pages/{docs => guide}/faq.mdx | 0 .../getting-started/_meta.json | 0 .../getting-started/add-to-project.mdx | 4 +- .../getting-started/create-new.mdx | 0 apps/docs/src/pages/guide/index.mdx | 20 + apps/docs/src/utils/docgen.mjs | 74 ++- 31 files changed, 713 insertions(+), 39 deletions(-) delete mode 100644 apps/docs/src/pages/docs/api/index.mdx create mode 100644 apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkClient.mdx create mode 100644 apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkCommand.mdx create mode 100644 apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkEvent.mdx create mode 100644 apps/docs/src/pages/docs/types/@spark.ts/handler/Command.mdx create mode 100644 apps/docs/src/pages/docs/types/@spark.ts/handler/CommandPlugin.mdx create mode 100644 apps/docs/src/pages/docs/types/@spark.ts/handler/CommandType.mdx create mode 100644 apps/docs/src/pages/docs/types/@spark.ts/handler/Controller.mdx create mode 100644 apps/docs/src/pages/docs/types/@spark.ts/handler/EventOptions.mdx create mode 100644 apps/docs/src/pages/docs/types/@spark.ts/handler/EventRunner.mdx create mode 100644 apps/docs/src/pages/docs/types/@spark.ts/handler/InitPlugin.mdx create mode 100644 apps/docs/src/pages/docs/types/@spark.ts/handler/SlashCommand.mdx create mode 100644 apps/docs/src/pages/docs/types/@spark.ts/handler/TextCommand.mdx create mode 100644 apps/docs/src/pages/guide/_meta.json rename apps/docs/src/pages/{docs => guide}/core-concepts/_meta.json (100%) rename apps/docs/src/pages/{docs => guide}/core-concepts/adding-commands.mdx (97%) rename apps/docs/src/pages/{docs => guide}/core-concepts/adding-events.mdx (100%) rename apps/docs/src/pages/{docs => guide}/core-concepts/adding-plugins.mdx (100%) rename apps/docs/src/pages/{docs => guide}/core-concepts/publishing-plugins.mdx (100%) rename apps/docs/src/pages/{docs => guide}/faq.mdx (100%) rename apps/docs/src/pages/{docs => guide}/getting-started/_meta.json (100%) rename apps/docs/src/pages/{docs => guide}/getting-started/add-to-project.mdx (74%) rename apps/docs/src/pages/{docs => guide}/getting-started/create-new.mdx (100%) create mode 100644 apps/docs/src/pages/guide/index.mdx diff --git a/apps/docs/package.json b/apps/docs/package.json index d816650..e6cf01a 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -10,7 +10,7 @@ "lint": "next lint", "vercel-build": "prisma generate && next build", "prisma:generate": "prisma generate", - "docgen": "node src/utils/docgen.mjs" + "docgen": "rm -rf src/pages/docs && node src/utils/docgen.mjs && node src/utils/docgen.mjs" }, "author": "DuroCodes", "license": "MIT", @@ -26,6 +26,7 @@ "@trpc/react-query": "^10.6.0", "@trpc/server": "^10.6.0", "copy-to-clipboard": "3.3.2", + "fast-glob": "^3.2.12", "next": "12.3.1", "next-auth": "^4.18.6", "next-mdx-remote": "^4.2.0", diff --git a/apps/docs/src/components/QuickStart.tsx b/apps/docs/src/components/QuickStart.tsx index aee628e..93b1538 100644 --- a/apps/docs/src/components/QuickStart.tsx +++ b/apps/docs/src/components/QuickStart.tsx @@ -14,7 +14,7 @@ export const QuickStartArea = () => ( name: 'Create a new project', description: 'Build a new Discord bot with Spark.', }} - href="/docs/getting-started/create-new" + href="/guide/getting-started/create-new" /> ( name: 'Add to your project', description: 'Add things to your bot with Spark.', }} - href="/docs/getting-started/add-to-project" + href="/guide/getting-started/add-to-project" /> ); @@ -35,7 +35,7 @@ export const FeatureArea = () => ( name: 'Adding commands', description: 'Add new commands to your project.', }} - href="/docs/core-concepts/adding-commands" + href="/guide/core-concepts/adding-commands" /> ( name: 'Adding events', description: 'Add new events to your project.', }} - href="/docs/core-concepts/adding-events" + href="/guide/core-concepts/adding-events" /> ); diff --git a/apps/docs/src/components/pages/plugin/newPlugin.tsx b/apps/docs/src/components/pages/plugin/newPlugin.tsx index ec1f35a..075b079 100644 --- a/apps/docs/src/components/pages/plugin/newPlugin.tsx +++ b/apps/docs/src/components/pages/plugin/newPlugin.tsx @@ -63,7 +63,7 @@ export default function NewPlugin() {

New Plugin

Create a plugin for the Spark community.

- Click here for a guide on how to publish plugins. + Click here for a guide on how to publish plugins.
+ +```typescript +new SparkClient(options) +``` + +| Parameter | Type | Optional | Description | +| --------- | ------------------ | -------- | ----------- | +| options | SparkClientOptions | ❌ | - | + +## Properties + +### public application: If\ + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L899` + +### public channels: ChannelManager + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L900` + +### public directories: Readonly\ + +The directories used for the handler. + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkClient.ts#L93) + +### public guilds: GuildManager + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L902` + +### private logLevel: LogLevel + +The log level used by the logger. + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkClient.ts#L71) + +### public logger: Logger + +The logger to be used by the handler. +Logger implemented by + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkClient.ts#L77) + +### public options: Omit\ & \{ intents: IntentsBitField } + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L903` + +### public prefix: string + +The prefix used for text commands. Defaults to '!' + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkClient.ts#L99) + +### public readyTimestamp: If\ + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L905` + +### public rest: REST + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L476` + +### public shard: null \| ShardClientUtil + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L907` + +### public sweepers: Sweepers + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L906` + +### public token: If\ + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L908` + +### public user: If\ + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L910` + +### public users: UserManager + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L911` + +### public voice: ClientVoiceManager + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L912` + +### public ws: WebSocketManager + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L913` + +### public static captureRejectionSymbol: (typeof captureRejectionSymbol) + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L328` + +### public static captureRejections: boolean + +Sets or gets the default captureRejection value for all emitters. + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L333` + +### public static defaultMaxListeners: number + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L334` + +### public static errorMonitor: (typeof errorMonitor) + +This symbol shall be used to install a listener for only monitoring + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L327` + +### public \_censoredToken: null \| string + +### public emojis: BaseGuildEmojiManager + +### public readyAt: If\ + +### public uptime: If\ + +## Methods + +### public addListener(eventName, listener): SparkClient\ + +Alias for + +| Parameter | Type | Optional | Description | +| --------- | --------------------------- | -------- | ----------- | +| eventName | string \| symbol | ❌ | - | +| listener | (args: Array\) => void | ❌ | - | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L354` + +### public destroy(): void + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L914` + +### public emit(event, args): boolean + +| Parameter | Type | Optional | Description | +| --------- | ---------------- | -------- | ----------- | +| event | K | ❌ | - | +| args | ClientEvents\[K] | ❌ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L940` + +### public eventNames(): Array\ + +Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L669` + +### public fetchGuildPreview(guild): Promise\ + +| Parameter | Type | Optional | Description | +| --------- | --------------- | -------- | ----------- | +| guild | GuildResolvable | ❌ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L915` + +### public fetchGuildTemplate(template): Promise\ + +| Parameter | Type | Optional | Description | +| --------- | ------ | -------- | ----------- | +| template | string | ❌ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L917` + +### public fetchGuildWidget(guild): Promise\ + +| Parameter | Type | Optional | Description | +| --------- | --------------- | -------- | ----------- | +| guild | GuildResolvable | ❌ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L922` + +### public fetchInvite(invite, options?): Promise\ + +| Parameter | Type | Optional | Description | +| --------- | ------------------------ | -------- | ----------- | +| invite | string | ❌ | - | +| options | ClientFetchInviteOptions | ✅ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L916` + +### public fetchPremiumStickerPacks(): Promise\> + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L920` + +### public fetchSticker(id): Promise\ + +| Parameter | Type | Optional | Description | +| --------- | ------ | -------- | ----------- | +| id | string | ❌ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L919` + +### public fetchVoiceRegions(): Promise\> + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L918` + +### public fetchWebhook(id, token?): Promise\ + +| Parameter | Type | Optional | Description | +| --------- | ------ | -------- | ----------- | +| id | string | ❌ | - | +| token | string | ✅ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L921` + +### public generateInvite(options?): string + +| Parameter | Type | Optional | Description | +| --------- | ----------------------- | -------- | ----------- | +| options | InviteGenerationOptions | ✅ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L923` + +### public getMaxListeners(): number + +Returns the current max listener value for the + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L526` + +### public isReady(): this is Client\ + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L925` + +### public listenerCount(eventName): number + +Returns the number of listeners listening to the event named + +| Parameter | Type | Optional | Description | +| --------- | ---------------- | -------- | ---------------------------------------- | +| eventName | string \| symbol | ❌ | The name of the event being listened for | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L616` + +### public listeners(eventName): Array\ + +Returns a copy of the array of listeners for the event named + +| Parameter | Type | Optional | Description | +| --------- | ---------------- | -------- | ----------- | +| eventName | string \| symbol | ❌ | - | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L539` + +### public login(token): Promise\ + +Registers the handler and logs into the bot. +Usage: + +| Parameter | Type | Optional | Description | +| --------- | ------ | -------- | ----------- | +| token | string | ❌ | - | + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkClient.ts#L120) + +### public off(event, listener): SparkClient\ + +| Parameter | Type | Optional | Description | +| --------- | -------------------------------------------- | -------- | ----------- | +| event | K | ❌ | - | +| listener | (args: ClientEvents\[K]) => Awaitable\ | ❌ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L943` + +### public on(event, listener): SparkClient\ + +| Parameter | Type | Optional | Description | +| --------- | -------------------------------------------- | -------- | ----------- | +| event | K | ❌ | - | +| listener | (args: ClientEvents\[K]) => Awaitable\ | ❌ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L928` + +### public once(event, listener): SparkClient\ + +| Parameter | Type | Optional | Description | +| --------- | -------------------------------------------- | -------- | ----------- | +| event | K | ❌ | - | +| listener | (args: ClientEvents\[K]) => Awaitable\ | ❌ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L934` + +### public prependListener(eventName, listener): SparkClient\ + +Adds the + +| Parameter | Type | Optional | Description | +| --------- | --------------------------- | -------- | ---------------------- | +| eventName | string \| symbol | ❌ | The name of the event. | +| listener | (args: Array\) => void | ❌ | The callback function | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L634` + +### public prependOnceListener(eventName, listener): SparkClient\ + +Adds a **one-time** + +| Parameter | Type | Optional | Description | +| --------- | --------------------------- | -------- | ---------------------- | +| eventName | string \| symbol | ❌ | The name of the event. | +| listener | (args: Array\) => void | ❌ | The callback function | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L650` + +### public rawListeners(eventName): Array\ + +Returns a copy of the array of listeners for the event named + +| Parameter | Type | Optional | Description | +| --------- | ---------------- | -------- | ----------- | +| eventName | string \| symbol | ❌ | - | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L569` + +### public removeAllListeners(event?): SparkClient\ + +| Parameter | Type | Optional | Description | +| --------- | ---- | -------- | ----------- | +| event | K | ✅ | - | + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L949` + +### public removeListener(eventName, listener): SparkClient\ + +Removes the specified + +| Parameter | Type | Optional | Description | +| --------- | --------------------------- | -------- | ----------- | +| eventName | string \| symbol | ❌ | - | +| listener | (args: Array\) => void | ❌ | - | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L494` + +### public setMaxListeners(n): SparkClient\ + +By default + +| Parameter | Type | Optional | Description | +| --------- | ------ | -------- | ----------- | +| n | number | ❌ | - | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L520` + +### public toJSON(): unknown + +- Source: `Programming/TypeScript/spark/node_modules/.pnpm/discord.js@14.7.1/node_modules/discord.js/typings/index.d.ts#L926` + +### public static getEventListeners(emitter, name): Array\ + +Returns a copy of the array of listeners for the event named + +| Parameter | Type | Optional | Description | +| --------- | -------------------------------- | -------- | ----------- | +| emitter | EventEmitter \| \_DOMEventTarget | ❌ | - | +| name | string \| symbol | ❌ | - | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L299` + +### public static listenerCount(emitter, eventName): number + +A class method that returns the number of listeners for the given + +- **⚠️ Deprecated** + +| Parameter | Type | Optional | Description | +| --------- | ---------------- | -------- | -------------------- | +| emitter | EventEmitter | ❌ | The emitter to query | +| eventName | string \| symbol | ❌ | The event name | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L271` + +### public static on(emitter, eventName, options?): AsyncIterableIterator\ + +```js +const { on, EventEmitter } = require('events'); + +(async () => { +const ee = new EventEmitter(); + +// Emit later on +process.nextTick(() => { +ee.emit('foo', 'bar'); +ee.emit('foo', 42); +}); + +for await (const event of on(ee, 'foo')) { +// The execution of this inner block is synchronous and it +// processes one event at a time (even with await). Do not use +// if concurrent execution is required. +console.log(event); // prints ['bar'] [42] +} +// Unreachable here +})(); +``` + +| Parameter | Type | Optional | Description | +| --------- | ------------------------- | -------- | ---------------------------------------- | +| emitter | EventEmitter | ❌ | - | +| eventName | string | ❌ | The name of the event being listened for | +| options | StaticEventEmitterOptions | ✅ | - | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L254` + +### public static once(emitter, eventName, options?): Promise\> + +Creates a + +| Parameter | Type | Optional | Description | +| --------- | ------------------------- | -------- | ----------- | +| emitter | \_NodeEventTarget | ❌ | - | +| eventName | string \| symbol | ❌ | - | +| options | StaticEventEmitterOptions | ✅ | - | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L194` + +### public static setMaxListeners(n?, eventTargets): void + +```js +const { +setMaxListeners, +EventEmitter +} = require('events'); + +const target = new EventTarget(); +const emitter = new EventEmitter(); + +setMaxListeners(5, target, emitter); +``` + +| Parameter | Type | Optional | Description | +| ------------ | ---------------------------------------- | -------- | ---------------------------------------------------------- | +| n | number | ✅ | A non-negative number. The maximum number of listeners per | +| eventTargets | Array\ | ❌ | - | + +- Source: `node_modules/@types/node/ts4.8/events.d.ts#L317` diff --git a/apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkCommand.mdx b/apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkCommand.mdx new file mode 100644 index 0000000..cf996e2 --- /dev/null +++ b/apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkCommand.mdx @@ -0,0 +1,33 @@ +## SparkCommand implements BaseCommand + +The event class. Use this class to create new commands in your bot. + +```typescript +new SparkCommand(options) +``` + +| Parameter | Type | Optional | Description | +| --------- | ------- | -------- | ----------- | +| options | Command | ❌ | - | + +## Properties + +### public description: string + +The description of the command. Will default to + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkCommand.ts#L42) + +### public name: string + +The name of the command. Will default to the file's name without the shortcut. +Example: + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkCommand.ts#L37) + +### public type: CommandType + +The type of the command. +You can use the + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkCommand.ts#L48) diff --git a/apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkEvent.mdx b/apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkEvent.mdx new file mode 100644 index 0000000..2a4f030 --- /dev/null +++ b/apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkEvent.mdx @@ -0,0 +1,31 @@ +## SparkEvent implements EventOptions\ + +The event class. Use this class to create new events in your bot. + +```typescript +new SparkEvent(options) +``` + +| Parameter | Type | Optional | Description | +| --------- | ------------------ | -------- | ----------- | +| options | EventOptions\ | ❌ | - | + +## Properties + +### public name: Key + +The name of the event. (Such as + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkEvent.ts#L37) + +### public once: boolean + +Whether the event should run once. + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkEvent.ts#L47) + +### public run: EventRunner\ + +The run function for the event. + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkEvent.ts#L42) diff --git a/apps/docs/src/pages/docs/index.mdx b/apps/docs/src/pages/docs/index.mdx index 06daec6..3dfee71 100644 --- a/apps/docs/src/pages/docs/index.mdx +++ b/apps/docs/src/pages/docs/index.mdx @@ -1,20 +1,15 @@ --- -title: Spark Quickstart -description: Create your first Spark Discord bot. +title: API Docs +description: View the Spark API Docs --- -# Spark Quickstart +import Callout from '~/components/Callout'; -Spark is an advanced **Discord.js handler**. -With Spark, you can create commands easily without the struggle of other handlers. +## API Docs -import { QuickStartArea, FeatureArea } from '~/components/QuickStart'; +In this section of the docs, you can view info on the classes and types, and view their methods and properties. - - -# Features - -Spark makes it easy for you to add events and commands to your Discord bot. -Just make a new file in the directory and write some code! - - + + This section is in beta, it may have some errors. + For now, it's best to use the `Guide` section to learn more. + diff --git a/apps/docs/src/pages/docs/types/@spark.ts/handler/Command.mdx b/apps/docs/src/pages/docs/types/@spark.ts/handler/Command.mdx new file mode 100644 index 0000000..735d49f --- /dev/null +++ b/apps/docs/src/pages/docs/types/@spark.ts/handler/Command.mdx @@ -0,0 +1,3 @@ +## Command + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/command.ts#L107) diff --git a/apps/docs/src/pages/docs/types/@spark.ts/handler/CommandPlugin.mdx b/apps/docs/src/pages/docs/types/@spark.ts/handler/CommandPlugin.mdx new file mode 100644 index 0000000..4665ffb --- /dev/null +++ b/apps/docs/src/pages/docs/types/@spark.ts/handler/CommandPlugin.mdx @@ -0,0 +1,12 @@ +## CommandPlugin + +Represents a plugin that is ran upon the command being used. +Good for guards, reusability. + +| Property | Type | Value | Description | +| ----------- | -------------------------------------------------------------------------- | ----- | ----------- | +| description | string | N/A | - | +| name | string | N/A | - | +| run | (options: CommandPluginOptionsDefs\[T]) => Awaitable\> | N/A | - | + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/plugin.ts#L87) diff --git a/apps/docs/src/pages/docs/types/@spark.ts/handler/CommandType.mdx b/apps/docs/src/pages/docs/types/@spark.ts/handler/CommandType.mdx new file mode 100644 index 0000000..bc4f9f0 --- /dev/null +++ b/apps/docs/src/pages/docs/types/@spark.ts/handler/CommandType.mdx @@ -0,0 +1,9 @@ +## CommandType + +| Property | Type | Value | Description | +| -------- | ------- | ----- | ----------- | +| Both | 'both' | N/A | - | +| Slash | 'slash' | N/A | - | +| Text | 'text' | N/A | - | + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/command.ts#L15) diff --git a/apps/docs/src/pages/docs/types/@spark.ts/handler/Controller.mdx b/apps/docs/src/pages/docs/types/@spark.ts/handler/Controller.mdx new file mode 100644 index 0000000..50646a8 --- /dev/null +++ b/apps/docs/src/pages/docs/types/@spark.ts/handler/Controller.mdx @@ -0,0 +1,10 @@ +## Controller + +Represents the controller object + +| Property | Type | Value | Description | +| -------- | ----------------------------------- | ----- | ---------------------------------------------------- | +| next | (...args: unknown\[]) => Ok\ | N/A | Continues plugin execution, runs the next plugin. | +| stop | (...args: unknown\[]) => Err\ | N/A | Stops plugin execution, doesn't run the next plugin. | + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/plugin.ts#L19) diff --git a/apps/docs/src/pages/docs/types/@spark.ts/handler/EventOptions.mdx b/apps/docs/src/pages/docs/types/@spark.ts/handler/EventOptions.mdx new file mode 100644 index 0000000..2abfc2e --- /dev/null +++ b/apps/docs/src/pages/docs/types/@spark.ts/handler/EventOptions.mdx @@ -0,0 +1,9 @@ +## EventOptions + +| Property | Type | Value | Description | +| -------- | ----------------- | ----- | ------------------------------------------------------- | +| name | Key | N/A | - | +| once | boolean | N/A | Whether the event should be ran once or multiple times. | +| run | EventRunner\ | N/A | - | + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/event.ts#L7) diff --git a/apps/docs/src/pages/docs/types/@spark.ts/handler/EventRunner.mdx b/apps/docs/src/pages/docs/types/@spark.ts/handler/EventRunner.mdx new file mode 100644 index 0000000..4e6d306 --- /dev/null +++ b/apps/docs/src/pages/docs/types/@spark.ts/handler/EventRunner.mdx @@ -0,0 +1,3 @@ +## EventRunner + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/event.ts#L3) diff --git a/apps/docs/src/pages/docs/types/@spark.ts/handler/InitPlugin.mdx b/apps/docs/src/pages/docs/types/@spark.ts/handler/InitPlugin.mdx new file mode 100644 index 0000000..196b6da --- /dev/null +++ b/apps/docs/src/pages/docs/types/@spark.ts/handler/InitPlugin.mdx @@ -0,0 +1,12 @@ +## InitPlugin + +Represents a plugin that is ran upon the command being loaded. +Good for pre-processing, or doing something with the data of the command. + +| Property | Type | Value | Description | +| ----------- | ----------------------------------------------------------------------- | ----- | ----------- | +| description | string | N/A | - | +| name | string | N/A | - | +| run | (options: InitPluginOptionsDefs\[T]) => Awaitable\> | N/A | - | + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/plugin.ts#L97) diff --git a/apps/docs/src/pages/docs/types/@spark.ts/handler/SlashCommand.mdx b/apps/docs/src/pages/docs/types/@spark.ts/handler/SlashCommand.mdx new file mode 100644 index 0000000..cdfee84 --- /dev/null +++ b/apps/docs/src/pages/docs/types/@spark.ts/handler/SlashCommand.mdx @@ -0,0 +1,13 @@ +## SlashCommand + +| Property | Type | Value | Description | +| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | ------------------------------------------------------------------- | +| description | string | N/A | - | +| initPlugins | Array\ \| InitPlugin\> | N/A | Plugins that will be ran upon the command being initialized/loaded. | +| name | string | N/A | - | +| options | ApplicationCommandOptionData | N/A | - | +| plugins | Array\ \| CommandPlugin\> | N/A | Plugins that will be ran upon the command being used. | +| run | (options: \{ args: CommandInteractionOptionResolver\,client: Client\,interaction: ChatInputCommandInteraction\ }) => unknown | N/A | - | +| type | Slash | N/A | - | + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/command.ts#L62) diff --git a/apps/docs/src/pages/docs/types/@spark.ts/handler/TextCommand.mdx b/apps/docs/src/pages/docs/types/@spark.ts/handler/TextCommand.mdx new file mode 100644 index 0000000..009c40f --- /dev/null +++ b/apps/docs/src/pages/docs/types/@spark.ts/handler/TextCommand.mdx @@ -0,0 +1,16 @@ +## TextCommand + +A text command. Ran with a prefix, and can have aliases. + +| Property | Type | Value | Description | +| ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ----- | ------------------------------------------------------------------- | +| aliases | Array\ | N/A | Aliases for the command. | +| The command will be ran if any of these aliases are used with the prefix. | +| description | string | N/A | - | +| initPlugins | Array\ \| InitPlugin\> | N/A | Plugins that will be ran upon the command being initialized/loaded. | +| name | string | N/A | - | +| plugins | Array\ \| CommandPlugin\> | N/A | Plugins that will be ran upon the command being used. | +| run | (options: \{ args: Array\,client: Client\,message: Message\ }) => unknown | N/A | - | +| type | Text | N/A | - | + +- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/command.ts#L44) diff --git a/apps/docs/src/pages/guide/_meta.json b/apps/docs/src/pages/guide/_meta.json new file mode 100644 index 0000000..cebfcd1 --- /dev/null +++ b/apps/docs/src/pages/guide/_meta.json @@ -0,0 +1,8 @@ +{ + "index": { + "title": "Quickstart" + }, + "getting-started": "Getting Started", + "core-concepts": "Core Concepts", + "faq": "FAQ" +} diff --git a/apps/docs/src/pages/docs/core-concepts/_meta.json b/apps/docs/src/pages/guide/core-concepts/_meta.json similarity index 100% rename from apps/docs/src/pages/docs/core-concepts/_meta.json rename to apps/docs/src/pages/guide/core-concepts/_meta.json diff --git a/apps/docs/src/pages/docs/core-concepts/adding-commands.mdx b/apps/docs/src/pages/guide/core-concepts/adding-commands.mdx similarity index 97% rename from apps/docs/src/pages/docs/core-concepts/adding-commands.mdx rename to apps/docs/src/pages/guide/core-concepts/adding-commands.mdx index b0857fd..44becdb 100644 --- a/apps/docs/src/pages/docs/core-concepts/adding-commands.mdx +++ b/apps/docs/src/pages/guide/core-concepts/adding-commands.mdx @@ -82,4 +82,4 @@ Inside of message commands, you can add the `aliases` property, where you can de As of `@spark.ts/handler` version 1.2.0, you can create plugins for your commands. -You can view more information on the [plugin page](/docs/core-concepts/adding-plugins) +You can view more information on the [plugin page](/guide/core-concepts/adding-plugins) diff --git a/apps/docs/src/pages/docs/core-concepts/adding-events.mdx b/apps/docs/src/pages/guide/core-concepts/adding-events.mdx similarity index 100% rename from apps/docs/src/pages/docs/core-concepts/adding-events.mdx rename to apps/docs/src/pages/guide/core-concepts/adding-events.mdx diff --git a/apps/docs/src/pages/docs/core-concepts/adding-plugins.mdx b/apps/docs/src/pages/guide/core-concepts/adding-plugins.mdx similarity index 100% rename from apps/docs/src/pages/docs/core-concepts/adding-plugins.mdx rename to apps/docs/src/pages/guide/core-concepts/adding-plugins.mdx diff --git a/apps/docs/src/pages/docs/core-concepts/publishing-plugins.mdx b/apps/docs/src/pages/guide/core-concepts/publishing-plugins.mdx similarity index 100% rename from apps/docs/src/pages/docs/core-concepts/publishing-plugins.mdx rename to apps/docs/src/pages/guide/core-concepts/publishing-plugins.mdx diff --git a/apps/docs/src/pages/docs/faq.mdx b/apps/docs/src/pages/guide/faq.mdx similarity index 100% rename from apps/docs/src/pages/docs/faq.mdx rename to apps/docs/src/pages/guide/faq.mdx diff --git a/apps/docs/src/pages/docs/getting-started/_meta.json b/apps/docs/src/pages/guide/getting-started/_meta.json similarity index 100% rename from apps/docs/src/pages/docs/getting-started/_meta.json rename to apps/docs/src/pages/guide/getting-started/_meta.json diff --git a/apps/docs/src/pages/docs/getting-started/add-to-project.mdx b/apps/docs/src/pages/guide/getting-started/add-to-project.mdx similarity index 74% rename from apps/docs/src/pages/docs/getting-started/add-to-project.mdx rename to apps/docs/src/pages/guide/getting-started/add-to-project.mdx index 50fd213..6c28296 100644 --- a/apps/docs/src/pages/docs/getting-started/add-to-project.mdx +++ b/apps/docs/src/pages/guide/getting-started/add-to-project.mdx @@ -9,7 +9,7 @@ description: Add commands and events to your Spark bot If you'd like to add a new command to your Spark bot, simply create a new file in the commands directory with your command. -View the [`adding commands`](/docs/core-concepts/adding-commands) section for more information. +View the [`adding commands`](/guide/core-concepts/adding-commands) section for more information. You can also create subfolders to organize your commands. @@ -17,6 +17,6 @@ You can also create subfolders to organize your commands. If you'd like to create a new event listener for your bot, simply create a new file in your events directory and put the event listener there. -View the [`adding events`](/docs/core-concepts/adding-events) section for more information. +View the [`adding events`](/guide/core-concepts/adding-events) section for more information. Similarly to commands, you can create subfolders to organize your events. diff --git a/apps/docs/src/pages/docs/getting-started/create-new.mdx b/apps/docs/src/pages/guide/getting-started/create-new.mdx similarity index 100% rename from apps/docs/src/pages/docs/getting-started/create-new.mdx rename to apps/docs/src/pages/guide/getting-started/create-new.mdx diff --git a/apps/docs/src/pages/guide/index.mdx b/apps/docs/src/pages/guide/index.mdx new file mode 100644 index 0000000..06daec6 --- /dev/null +++ b/apps/docs/src/pages/guide/index.mdx @@ -0,0 +1,20 @@ +--- +title: Spark Quickstart +description: Create your first Spark Discord bot. +--- + +# Spark Quickstart + +Spark is an advanced **Discord.js handler**. +With Spark, you can create commands easily without the struggle of other handlers. + +import { QuickStartArea, FeatureArea } from '~/components/QuickStart'; + + + +# Features + +Spark makes it easy for you to add events and commands to your Discord bot. +Just make a new file in the directory and write some code! + + diff --git a/apps/docs/src/utils/docgen.mjs b/apps/docs/src/utils/docgen.mjs index c3a0d86..1b3b174 100644 --- a/apps/docs/src/utils/docgen.mjs +++ b/apps/docs/src/utils/docgen.mjs @@ -1,8 +1,80 @@ import { createDocumentation } from 'typedoc-nextra'; +import glob from 'fast-glob'; +import fs from 'fs'; await createDocumentation({ input: [`${process.cwd()}/../../packages/handler/src/index.ts`], - output: `${process.cwd()}/src/pages/docs/api`, + output: `${process.cwd()}/src/pages/docs`, tsconfigPath: `${process.cwd()}/../../packages/handler/tsconfig-base.json`, markdown: true, }); + +const docFiles = await glob('src/pages/docs/**/*.mdx'); + +const paths = docFiles.map((v) => ({ + path: v, + name: v.split('/').at(-1), + folder: v.split('/').at(-4), +})); + +paths.forEach(({ path, folder, name }) => { + fs.renameSync(path, `src/pages/docs/${folder}/${name}`); +}); + +const folders = [...new Set(paths.map(({ folder }) => folder))]; +folders.forEach((folder) => { + fs.rmdirSync(`src/pages/docs/${folder}/@spark.ts/handler`); + fs.rmdirSync(`src/pages/docs/${folder}/@spark.ts`); +}); + +const newFiles = await glob('src/pages/docs/**/*.mdx'); + +newFiles.forEach((file) => { + const data = fs.readFileSync(file, 'utf-8'); + + const replacedData = data + .split('\n') + .map((v) => { + if (v.includes('node_modules/discord.js/typings/index.d.ts')) { + return '- [Source](https://github.com/discordjs/discord.js/blob/main/packages/discord.js/typings/index.d.ts)'; + } + + if (v.includes('node_modules/@types/node')) { + return ''; + } + + return v; + }) + .join('\n'); + + const newData = `\ +--- +title: ${file.split('/').at(-1).split('.')[0]} +--- + +${replacedData}`; + + fs.writeFileSync(file, newData); +}); + +fs.writeFileSync('src/pages/docs/_meta.json', JSON.stringify({ + classes: 'Classes', + types: 'Types', +}, null, 2)); + +fs.writeFileSync('src/pages/docs/index.mdx', `--- +title: API Docs +description: View the Spark API Docs +--- + +import Callout from '~/components/Callout'; + +## API Docs + +In this section of the docs, you can view info on the classes and types, and view their methods and properties. + + + This section is in beta, it may have some errors. + For now, it's best to use the \`Guide\` section to learn more. + +`);