Skip to content

Commit

Permalink
Add more jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
catplvsplus committed Jul 13, 2024
1 parent 885f7a5 commit f26b677
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/decorators/src/decorators/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { RecipleModuleDecoratorMetadata } from '../types/structures.js';
/**
* Sets a context menu command decorator.
*
* ```
* ```ts
* @setRecipleModule()
* class MyModule implements RecipleModuleData {
* @setRecipleModuleStart()
Expand All @@ -15,7 +15,7 @@ import type { RecipleModuleDecoratorMetadata } from '../types/structures.js';
*
* @setContextMenuCommand({ name: 'Test', type: 'Message' })
* async handleContextMenuExecute(data: ContextMenuCommandExecuteData) {
* await data.interaction('Test');
* await data.interaction.reply('Test');
* }
* }
* ```
Expand Down Expand Up @@ -55,7 +55,7 @@ export function setContextMenuCommand<T extends ContextMenuCommandExecuteFunctio
*
* @setMessageCommand({ name: 'test', description: 'test command', aliases: ['t'] })
* async handleMessageCommandExecute(data: MessageCommandExecuteData) {
* await data.message('Test');
* await data.message.reply('Test');
* }
* }
* ```
Expand Down Expand Up @@ -84,7 +84,7 @@ export function setMessageCommand<T extends MessageCommandExecuteFunction>(data:
/**
* Sets a slash command decorator.
*
* ```
* ```ts
* @setRecipleModule()
* class MyModule implements RecipleModuleData {
* @setRecipleModuleStart()
Expand All @@ -94,7 +94,7 @@ export function setMessageCommand<T extends MessageCommandExecuteFunction>(data:
*
* @setSlashCommand({ name: 'Test', description: 'Test command' })
* async handleSlashCommandExecute(data: SlashCommandExecuteData) {
* await data.interaction('Test');
* await data.interaction.reply('Test');
* }
* }
* ```
Expand Down
78 changes: 78 additions & 0 deletions packages/decorators/src/decorators/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,32 @@ export interface RecipleModuleEventDecoratorMap {
rest: RestEvents;
}

/**
* Sets a client event
*
* ```ts
* @setRecipleModule()
* class MyModule implements RecipleModuleData {
* @setRecipleModuleStart()
* async onStart() {
* return true;
* }
*
* @setRecipleModuleLoad()
* async onLoad() {}
*
* @setRecipleModuleUnload()
* async onUnload() {}
*
* @setClientEvent('messageCreate')
* async handleMessageEvent(message: Message) {
* await message.reply('Test');
* }
* }
* ```
* @param event The event name
* @param once True if the event should only be triggered once
*/
export function setClientEvent<E extends keyof RecipleClientEvents, A extends RecipleClientEvents[E]>(event: E, once?: boolean): TypedMethodDecorator<(...args: A) => any>;
export function setClientEvent<E extends string|symbol, A extends any[]>(event: E, once?: boolean): TypedMethodDecorator<(...args: A) => any>;
export function setClientEvent<E extends string|symbol, A extends any[]>(event: E, once?: boolean): TypedMethodDecorator<(...args: A) => any> {
Expand All @@ -21,6 +47,32 @@ export function setClientEvent<E extends string|symbol, A extends any[]>(event:
}
}

/**
* Sets a websocket event
*
* ```ts
* @setRecipleModule()
* class MyModule implements RecipleModuleData {
* @setRecipleModuleStart()
* async onStart() {
* return true;
* }
*
* @setRecipleModuleLoad()
* async onLoad() {}
*
* @setRecipleModuleUnload()
* async onUnload() {}
*
* @setWebsocketEvent(GatewayDispatchEvents.MessageCreate)
* async handleWebsocketEvent(data: any) {
* console.log(data);
* }
* }
* ```
* @param event The event name
* @param once True if the event should only be triggered once
*/
export function setWebsocketEvent<E extends keyof GatewayDispatchEvents, A extends [data: any, shardId: number]>(event: E, once?: boolean): TypedMethodDecorator<(...args: A) => any>;
export function setWebsocketEvent<E extends string|symbol, A extends any[]>(event: E, once?: boolean): TypedMethodDecorator<(...args: A) => any>;
export function setWebsocketEvent<E extends string|symbol, A extends any[]>(event: E, once?: boolean): TypedMethodDecorator<(...args: A) => any> {
Expand All @@ -34,6 +86,32 @@ export function setWebsocketEvent<E extends string|symbol, A extends any[]>(even
}
}

/**
* Sets a REST event
*
* ```ts
* @setRecipleModule()
* class MyModule implements RecipleModuleData {
* @setRecipleModuleStart()
* async onStart() {
* return true;
* }
*
* @setRecipleModuleLoad()
* async onLoad() {}
*
* @setRecipleModuleUnload()
* async onUnload() {}
*
* @setRESTEvent('restDebug')
* async handleRESTEvent(info: string) {
* console.log(info);
* }
* }
* ```
* @param event The event name
* @param once True if the event should only be triggered once
*/
export function setRESTEvent<E extends keyof RestEvents, A extends RestEvents[E]>(event: E, once?: boolean): TypedMethodDecorator<(...args: A) => any>;
export function setRESTEvent<E extends string|symbol, A extends any[]>(event: E, once?: boolean): TypedMethodDecorator<(...args: A) => any>;
export function setRESTEvent<E extends string|symbol, A extends any[]>(event: E, once?: boolean): TypedMethodDecorator<(...args: A) => any> {
Expand Down

0 comments on commit f26b677

Please sign in to comment.