DMs users who join your server with a friendly welcome embed message. You must have privileged intents enabled for your Discord bot settings for this snippet to work.
// authenticates you with the API standard library
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
await lib.discord.users['@0.1.2'].dms.create({
recipient_id: `${context.params.event.user.id}`,
content: `Welcome to this server!`,
embed: {
title: 'Guild Rules',
type: 'rich',
color: 0x0000AA,
description: 'Here are some things to know about this guild:',
fields: [{
name: 'Rule #1',
value: `Introduce yourself!`
}, {
name: 'Rule #2',
value: 'Be yourself!'
}, {
name: 'Rule #3',
value: `Don't be evil.`
}, {
name: 'More Important Information',
value: [
'You could put a link with more important information about this guild here:',
`https://autocode.com/`
].join('\n')
}]
}
});