Sends a message to a specified channel when a user leaves the server. You must have privileged intents enabled in your Discord bot settings for this snippet to work.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const event = context.params.event;
// ** DEV ** Set the channel ID to post to
const channel_id = process.env.EXIT_CHANNEL_ID
await lib.discord.channels['@0.1.2'].messages.create({
channel_id, content: `<@${event.user.id}> has left the server.`,
});