Event Listeners
Event Listeners are modules that are basically passed onto Discord.JS's Events.
Event listeners live in the events
directory, and use the defineEvent
Definition Function for type support.
TIP
For more advanced uses, visit the Setup Method guide.
Basic Listeners
import { defineEvent } from 'chooksie'
export default defineEvent({
name: 'guildCreate',
execute(ctx, guild) {
ctx.logger.info(`Joined a new server with ${guild.memberCount} user!`)
},
})
import { defineEvent } from 'chooksie'
export default defineEvent({
name: 'guildCreate',
execute(ctx, guild) {
ctx.logger.info(`Joined a new server with ${guild.memberCount} user!`)
},
})
const { defineEvent } = require('chooksie')
module.exports = defineEvent({
name: 'guildCreate',
execute(ctx, guild) {
ctx.logger.info(`Joined a new server with ${guild.memberCount} user!`)
},
})
One-time Listeners
import { defineEvent } from 'chooksie'
export default defineEvent({
name: 'ready',
once: true,
execute(ctx) {
ctx.logger.info(`Logged in as ${ctx.client.user.username}!`)
},
})
import { defineEvent } from 'chooksie'
export default defineEvent({
name: 'ready',
once: true,
execute(ctx) {
ctx.logger.info(`Logged in as ${ctx.client.user.username}!`)
},
})
const { defineEvent } = require('chooksie')
module.exports = defineEvent({
name: 'ready',
once: true,
execute(ctx) {
ctx.logger.info(`Logged in as ${ctx.client.user.username}!`)
},
})