Skip to main content
Version: Next

stopEvents Function

The stopEvents() function is a utility function that allows you to stop the execution of the events chain in CommandKit. This is useful when you want to prevent further event handlers from being executed after a certain point. It is typically used in the context of event handlers to control the flow of execution.

Usage

./src/app/events/messageCreate/event.ts
import { stopEvents } from 'commandkit';
import { Message } from 'discord.js';

export default async function onMessageCreate(message: Message) {
console.log('Message received:', message.content);

// Stop further event handlers of messageCreate from being executed after this point
stopEvents();
// code below will not be executed
}
info

You must not call stopEvents() in try-catch block, otherwise it will not work as expected.