wc.event() - shysolocup/willclient GitHub Wiki
- Description: Creates a new event listener.
Parts
- ctx
Event
: Context of the event
Parameters
- Event
String
: The name of the event (for a full list go here) - Action
Function
: What it does when the event occurs
Setup
wc.event("event", async (ctx) => {
// action
})
Examples
discord.js comparison
// discord.js
client.on("ready", async (ctx) => {
console.log(`Logged in as @${ctx.user.username} (${ctx.user.id})`);
});
// willclient
wc.event("ready", async (ctx) => {
console.log(`Logged in as @${ctx.user.username} (${ctx.user.id})`);
});
welcome message
wc.event("join", async (ctx) => {
let channel = await wc.fetchChannel("welcome channel ID")
channel.send(`Welcome ${ctx.user}!`)
})
button press
wc.event("buttonPress", async (ctx) => {
if (ctx.customId == "accept") {
ctx.reply("Accepted!")
}
});