Skip to content

Commit

Permalink
chore: update jsdoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostdevv committed Nov 10, 2024
1 parent 68ddaeb commit b7d8ff0
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .changeset/lemon-eggs-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"create-jellycommands": patch
"jellycommands": patch
---

chore: update jsdoc comments
2 changes: 1 addition & 1 deletion packages/create-jellycommands/src/js/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference types="jellycommands/ambient" />

// See https://jellycommands.dev/guide/props
// See https://jellycommands.dev/components/props
interface Props {}
6 changes: 3 additions & 3 deletions packages/create-jellycommands/src/js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { JellyCommands } from 'jellycommands';
import { IntentsBitField } from 'discord.js';

const client = new JellyCommands({
// https://jellycommands.dev/guide/overview#components
// https://jellycommands.dev/components
components: 'src/components',

clientOptions: {
Expand All @@ -12,11 +12,11 @@ const client = new JellyCommands({

dev: {
// In testing we should enable this, it will make all our commands register in our testing guild
// https://jellycommands.dev/guide/commands/dev#global-dev-mode
// https://jellycommands.dev/components/commands/dev
global: true,

// Put your testing guild id here
// https://jellycommands.dev/guide/commands/dev#setup
// https://jellycommands.dev/components/commands/dev
guilds: [''],
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/create-jellycommands/src/ts/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference types="jellycommands/ambient" />

// See https://jellycommands.dev/guide/props
// See https://jellycommands.dev/components/props
interface Props {}
6 changes: 3 additions & 3 deletions packages/create-jellycommands/src/ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { JellyCommands } from 'jellycommands';
import { IntentsBitField } from 'discord.js';

const client = new JellyCommands({
// https://jellycommands.dev/guide/overview#components
// https://jellycommands.dev/components
components: 'src/components',

clientOptions: {
Expand All @@ -12,11 +12,11 @@ const client = new JellyCommands({

dev: {
// In testing we should enable this, it will make all our commands register in our testing guild
// https://jellycommands.dev/guide/commands/dev#global-dev-mode
// https://jellycommands.dev/components/commands/dev
global: true,

// Put your testing guild id here
// https://jellycommands.dev/guide/commands/dev#setup
// https://jellycommands.dev/components/commands/dev
guilds: [''],
},
});
Expand Down
10 changes: 5 additions & 5 deletions packages/jellycommands/src/JellyCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
* client.login();
* ```
*
* @see https://jellycommands.dev/guide/overview/#the-client
* @see https://jellycommands.dev/getting-started#the-client
*/
export class JellyCommands extends Client {
// todo these options include data that isn't relevant (like given components) so mayb shouldn't be here
Expand All @@ -45,7 +45,7 @@ export class JellyCommands extends Client {

/**
* Props are used to pass data around your client.
* @see https://jellycommands.dev/guide/props/
* @see https://jellycommands.dev/components/props/
*/
public readonly props: Props;

Expand Down Expand Up @@ -75,17 +75,17 @@ export class JellyCommands extends Client {
this.props = {
get() {
throw new Error(
'props.get has been removed, SEE: https://jellycommands.dev/guide/migrate/props',
'props.get has been removed, SEE: https://jellycommands.dev/migrate/props',
);
},
set() {
throw new Error(
'props.set has been removed, SEE: https://jellycommands.dev/guide/migrate/props',
'props.set has been removed, SEE: https://jellycommands.dev/migrate/props',
);
},
has() {
throw new Error(
'props.has has been removed, SEE: https://jellycommands.dev/guide/migrate/props',
'props.has has been removed, SEE: https://jellycommands.dev/migrate/props',
);
},
...this.props,
Expand Down
4 changes: 2 additions & 2 deletions packages/jellycommands/src/components/buttons/buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type ButtonCallback = (context: {

/**
* Represents a button.
* @see https://jellycommands.dev/guide/buttons/files/
* @see https://jellycommands.dev/components/buttons
*/
export class Button extends Component<ButtonOptions> {
public readonly options: ButtonOptions;
Expand All @@ -34,7 +34,7 @@ export class Button extends Component<ButtonOptions> {

/**
* Creates a button.
* @see https://jellycommands.dev/guide/buttons/files/
* @see https://jellycommands.dev/components/buttons
*/
export const button = (options: ButtonOptions & { run: ButtonCallback }) => {
const { run, ...rest } = options;
Expand Down
1 change: 1 addition & 0 deletions packages/jellycommands/src/components/buttons/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async function findButton(
break;

case 'function':
// todo should this be sync only? might cause issues when not deffered
if (await id(incomingId)) return button;
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@ export type AutocompleteHandler = (options: {

/**
* Represents a slash command.
* @see https://jellycommands.dev/guide/commands/files/#slash-commands
* @see https://jellycommands.dev/components/commands
*/
export class Command extends BaseCommand<
CommandOptions,
ChatInputCommandInteraction
> {
public readonly type = ApplicationCommandType.ChatInput;

/**
* On some options you can enable autocomplete, which allows you to
* provide suggestions as a user types your command option.
*
* @see https://jellycommands.dev/components/commands/slash#autocomplete
*/
public readonly autocomplete?: AutocompleteHandler;

constructor({
Expand Down Expand Up @@ -108,14 +114,22 @@ export class Command extends BaseCommand<

/**
* Creates a slash command.
* @see https://jellycommands.dev/guide/commands/files/#slash-commands
* @see https://jellycommands.dev/components/commands
*/
export const command = (
options: CommandOptions & {
/**
* The callback function to call when your command is executed.
* @see http://localhost:4321/components/commands#handling-commands
*/
run: CommandCallback<ChatInputCommandInteraction>;

/**
* On some options you can enable autocomplete, which allows you to
* provide suggestions as a user types your command option.
*
* @see https://jellycommands.dev/components/commands/slash#autocomplete
*/
autocomplete?: AutocompleteHandler;
},
) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BaseCommand } from '../BaseCommand';

/**
* Represents a Message Context Menu command.
* @see https://jellycommands.dev/guide/commands/files/#message-commands
* @see https://jellycommands.dev/components/commands/context-menu#message-commands
*/
export class MessageCommand extends BaseCommand<
MessageCommandOptions,
Expand All @@ -25,12 +25,13 @@ export class MessageCommand extends BaseCommand<

/**
* Creates a Message Context Menu command.
* @see https://jellycommands.dev/guide/commands/files/#message-commands
* @see https://jellycommands.dev/components/commands/context-menu#message-commands
*/
export const messageCommand = (
options: MessageCommandOptions & {
/**
* The callback function to call when your command is executed.
* @see http://localhost:4321/components/commands#handling-commands
*/
run: CommandCallback<MessageContextMenuCommandInteraction>;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BaseCommand } from '../BaseCommand';

/**
* Represents a User Context Menu command.
* @see https://jellycommands.dev/guide/commands/files/#user-commands
* @see https://jellycommands.dev/components/commands/context-menu#user-commands
*/
export class UserCommand extends BaseCommand<
UserCommandOptions,
Expand All @@ -25,12 +25,13 @@ export class UserCommand extends BaseCommand<

/**
* Creates a User Context Menu command.
* @see https://jellycommands.dev/guide/commands/files/#user-commands
* @see https://jellycommands.dev/components/commands/context-menu#user-commands
*/
export const userCommand = (
options: UserCommandOptions & {
/**
* The callback function to call when your command is executed.
* @see http://localhost:4321/components/commands#handling-commands
*/
run: CommandCallback<UserContextMenuCommandInteraction>;
},
Expand Down
12 changes: 9 additions & 3 deletions packages/jellycommands/src/components/events/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { parseSchema } from '../../utils/zod';

/**
* The Discord event name
*
* @see https://jellycommands.dev/components/events
* @see https://discord.js.org/docs/packages/discord.js/14.16.3/ClientEvents:Interface
*/
export type EventName = keyof ClientEvents | (string & {});
Expand All @@ -17,13 +19,17 @@ export type EventName = keyof ClientEvents | (string & {});
* It takes in a base JellyCommands context as it's first param,
* followed by all the arguments your event provides.
*
* @see https://jellycommands.dev/guide/events/files/
* @see https://jellycommands.dev/components/events#handling-events
*/
export type EventCallback<E extends EventName> = (
ctx: { client: JellyCommands; props: Props },
...args: E extends keyof ClientEvents ? ClientEvents[E] : any[]
) => MaybePromise<any>;

/**
* A component for handling Discord.js events.
* @see https://jellycommands.dev/components/events
*/
export class Event<T extends EventName = EventName> extends Component {
/**
* The options you pass to when creating this event.
Expand Down Expand Up @@ -65,7 +71,7 @@ export class Event<T extends EventName = EventName> extends Component {
* This creates an event component for your bot. Events can be used
* to respond to actions such as a new user joining a guild.
*
* @see https://jellycommands.dev/guide/events/files/
* @see https://jellycommands.dev/components/events
*/
export const event = <K extends EventName>(
options: EventOptions<K> & {
Expand All @@ -74,7 +80,7 @@ export const event = <K extends EventName>(
* It takes in a base JellyCommands context as it's first param,
* followed by all the arguments your event provides.
*
* @see https://jellycommands.dev/guide/events/files/
* @see https://jellycommands.dev/components/events#handling-events
*/
run: EventCallback<K>;
},
Expand Down
2 changes: 1 addition & 1 deletion packages/jellycommands/src/components/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function read(client: JellyCommands, path: string): Promise<File[]> {
* The components of your bot. For any strings that are passed they
* will be loaded recursively from that path.
*
* @see https://jellycommands.dev/guide/components
* @see https://jellycommands.dev/components
*/
export type LoadableComponents = string | (string | Component)[];

Expand Down
16 changes: 11 additions & 5 deletions packages/jellycommands/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface JellyCommandsOptions {
* The components of your bot. For any strings that are passed they
* will be loaded recursively from that path.
*
* @see https://jellycommands.dev/guide/components
* @see https://jellycommands.dev/components
*/
components?: LoadableComponents;

Expand All @@ -80,7 +80,7 @@ export interface JellyCommandsOptions {

/**
* Props are used to pass data around your client.
* @see https://jellycommands.dev/guide/props/
* @see https://jellycommands.dev/components/props/
*/
props?: Props;

Expand All @@ -89,15 +89,15 @@ export interface JellyCommandsOptions {
* when your code is unable to handle them. Currently only handles
* an unknownCommand state.
*
* @see https://jellycommands.dev/guide/messages/
* @see https://jellycommands.dev/guides/messages/
*/
messages?: {
/**
* This is sent when your bot recieves an unknown command. This only
* happens if your user sends a command just as you re-register them
* as we respond to commands based on id rather than name currently.
*
* @see https://jellycommands.dev/guide/messages/#unknown-command
* @see https://jellycommands.dev/guides/messages#unknown-command
*/
unknownCommand?: string | MessagePayload | InteractionReplyOptions;
};
Expand All @@ -109,7 +109,7 @@ export interface JellyCommandsOptions {
* commands are only checked periodically. You should enable this
* when developing, and disable this in production.
*
* @see https://jellycommands.dev/guide/commands/dev/
* @see https://jellycommands.dev/components/commands/dev
*/
dev?: {
/**
Expand All @@ -134,6 +134,8 @@ export interface JellyCommandsOptions {
* We recommend you leave this on, at least when developing.
*
* @default true
*
* @see https://jellycommands.dev/components/commands/caching
*/
cache?: boolean;

Expand All @@ -146,11 +148,15 @@ export interface JellyCommandsOptions {
/**
* Options to control how JellyCommands reads from the
* filesystem when loading components.
*
* @see https://jellycommands.dev/guides/fs
*/
fs?: {
/**
* Only files that end in these extensions are loaded.
* @default ['.js', '.ts']
*
* @see https://jellycommands.dev/guides/fs#file-extensions
*/
extensions?: string[];
};
Expand Down

0 comments on commit b7d8ff0

Please sign in to comment.