event()
Popii / event
Function: event()
Section titled “Function: event()”event<
K>(handler):PopiiEventFunction<K>
Defined in: define/event.ts:52
Wraps a Discord.js event handler with the Popii EventPop context.
Name the file after the Discord.js event you want to handle (e.g. guildMemberAdd.ts)
and drop it in src/events/. Popii loads it automatically and infers the required
Gateway intents from the filename — no manual intent configuration needed.
The first argument is always EventPop (the Popii context object). The remaining
arguments match the Discord.js event signature exactly.
Type Parameters
Section titled “Type Parameters”K extends keyof ClientEvents
Parameters
Section titled “Parameters”handler
Section titled “handler”The asynchronous function to run when the event fires.
Returns
Section titled “Returns”Examples
Section titled “Examples”import { event } from "popii";
export default event(async (pop, member) => { const channel = member.guild.systemChannel; await channel?.send(`Welcome to the server, ${member}! 👋`);});import { event } from "popii";
export default event(async (pop, guild) => { pop.log.info(`Joined "${guild.name}" (${guild.memberCount} members)`);});import { event } from "popii";
export default event(async (pop, message) => { if (message.author.bot) return; if (message.content.toLowerCase() === "hello") { await message.reply("Hello there!"); }});