From 7fb169789bc86e3c217fee1d88cd01875f57b6c6 Mon Sep 17 00:00:00 2001 From: JasperAtSchool Date: Tue, 21 Jan 2025 12:05:36 +0100 Subject: [PATCH] Added new API comments (part 6) --- src/core/api/modules/responder.ts | 72 +++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/core/api/modules/responder.ts b/src/core/api/modules/responder.ts index 0f42eb5..b5d3a2d 100644 --- a/src/core/api/modules/responder.ts +++ b/src/core/api/modules/responder.ts @@ -33,12 +33,33 @@ export class ODResponderImplementation ex } } +/**## ODResponderTimeoutErrorCallback `type` + * This is the callback for the responder timeout function. It will be executed when something went wrong or the action takes too much time. + */ export type ODResponderTimeoutErrorCallback = (instance:Instance, source:Source) => void|Promise +/**## ODResponderManager `class` + * This is an open ticket responder manager. + * + * It contains all Open Ticket responders. Responders can respond to an interaction, button, dropdown, modal or command. + * + * Using the Open Ticket responder system has a few advantages compared to vanilla discord.js: + * - plugins can extend/edit replies + * - automatically reply on error + * - independent workers (with priority) + * - fail-safe design using try-catch + * - write code once => reply to both slash & text commands at the same time! + * - know where the request came from & parse options/subcommands & without errors! + * - And so much more! + */ export class ODResponderManager { + /**A manager for all (text & slash) command responders. */ commands: ODCommandResponderManager + /**A manager for all button responders. */ buttons: ODButtonResponderManager + /**A manager for all dropdown/select menu responders. */ dropdowns: ODDropdownResponderManager + /**A manager for all modal responders. */ modals: ODModalResponderManager constructor(debug:ODDebugger, client:ODClientManager){ @@ -49,9 +70,26 @@ export class ODResponderManager { } } +/**## ODCommandResponderManager `class` + * This is an open ticket command responder manager. + * + * It contains all Open Ticket command responders. These can respond to text & slash commands. + * + * Using the Open Ticket responder system has a few advantages compared to vanilla discord.js: + * - plugins can extend/edit replies + * - automatically reply on error + * - independent workers (with priority) + * - fail-safe design using try-catch + * - write code once => reply to both slash & text commands at the same time! + * - know where the request came from & parse options/subcommands & without errors! + * - And so much more! + */ export class ODCommandResponderManager extends ODManager> { + /**An alias to the Open Ticket client manager. */ #client: ODClientManager + /**The callback executed when the default workers take too much time to reply. */ #timeoutErrorCallback: ODResponderTimeoutErrorCallback|null = null + /**The amount of milliseconds before the timeout error callback is executed. */ #timeoutMs: number|null = null constructor(debug:ODDebugger, debugname:string, client:ODClientManager){ @@ -86,9 +124,17 @@ export class ODCommandResponderManager extends ODManager|null, timeoutMs:number|null, options?:ODTextCommandInteractionOption[]){