@antiraid-ext/events/dispatch
API reference for @antiraid-ext/events/dispatch
@antiraid-ext/events/dispatch
Functions
doesEventMatch
Function that checks if the event matches the name.
An event matches name when its ``base_name`` or ``name`` is equal to the ``name`` argument or when ``{base_name}.{name}`` is equal to the ``name`` argument.
For example, using either ``Message`` or ``Discord.Message`` as name would match a Discord Message event.
Note that this function is case-insensitive and internally converts all strings to lowercase.
Function Signature
--- Function that checks if the event matches the name.
---
--- An event matches name when its \`\`base_name\`\` or \`\`name\`\` is equal to the \`\`name\`\` argument or when \`\`{base_name}.{name}\`\` is equal to the \`\`name\`\` argument.
---
--- For example, using either \`\`Message\`\` or \`\`Discord.Message\`\` as name would match a Discord Message event.
---
--- **Note that this function is case-insensitive and internally converts all strings to lowercase.**
--- @param pat string The name to match against.
--- @param event Primitives.Event The event to check.
--- @return boolean True if the event matches the name, false otherwise.
function doesEventMatch(pat: string, event: Primitives.Event) end
Arguments
pat
string The name to match against.
event
Primitives.Event The event to check.
onEvent
Simple helper method that calls ``callback`` when the event matches the name. See ``doesEventMatch`` for more information
on how the name is matched.
Function Signature
--- Simple helper method that calls \`\`callback\`\` when the event matches the name. See \`\`doesEventMatch\`\` for more information
--- on how the name is matched.
---
--- @param event Primitives.Event The event to listen for.
--- @param pats string | {string} The name or list of names to match against.
--- @param callback function The callback to run when the event matches the name. The callback will receive the event as an argument.
--- @return nil
function onEvent(event: Primitives.Event, pats: string | {string}, callback: (Primitives.Event) -> ()) end
Arguments
event
Primitives.Event The event to listen for.
pats
string | {string} The name or list of names to match against.
Union with variants:
Variant 1
Variant 2
{string}
callback
function The callback to run when the event matches the name. The callback will receive the event as an argument.
Function Signature
callback: (Primitives.Event) -> ()
Arguments
arg1
onEventGeneric
Simple helper method that calls ``callback`` when the event matches the name. See ``doesEventMatch`` for more information
on how the name is matched.
Function Signature
--- Simple helper method that calls \`\`callback\`\` when the event matches the name. See \`\`doesEventMatch\`\` for more information
--- on how the name is matched.
function onEventGeneric<R>(event: Primitives.Event, pats: string | {string}, callback: (Primitives.Event) -> R) -> R? end
Generics
R
This generic is unconstrained and can be any type
Arguments
event
pats
Union with variants:
Variant 1
Variant 2
{string}
callback
Function Signature
callback: (Primitives.Event) -> R
Arguments
arg1
Returns
ret1
Returns
ret1
R?
Last updated on