File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
apps/website/docs/guide/03-events Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : stopEvents function
3+ ---
4+
5+ The ` stopEvents() ` function is a utility function that allows you to
6+ stop the execution of the events chain in CommandKit. This is useful
7+ when you want to prevent further event handlers from being executed
8+ after a certain point. It is typically used in the context of event
9+ handlers to control the flow of execution.
10+
11+ ## Usage
12+
13+ ``` ts title="src/app/events/messageCreate/event.ts"
14+ import type { Message } from ' discord.js' ;
15+ import { stopEvents } from ' commandkit' ;
16+
17+ export default async function (message : Message ) {
18+ console .log (' Message received:' , message .content );
19+
20+ // Stop further event handlers of messageCreate from being executed after this point
21+ stopEvents ();
22+ // code below will not be executed
23+ }
24+ ```
25+
26+ :::warning
27+
28+ Calling ` stopEvents() ` in a try/catch block may lead to unexpected
29+ behavior.
30+
31+ :::
32+
33+ :::info
34+
35+ At this time, the ` stopEvents() ` function is only available for
36+ [ Discord.js events] ( ./01-discordjs-events.mdx ) , and not for custom
37+ namespaced events.
38+
39+ :::
You can’t perform that action at this time.
0 commit comments