Skip to content

Instantly share code, notes, and snippets.

@wylie39
Last active September 21, 2021 17:04
Show Gist options
  • Save wylie39/87e34f807f88958fa8ad7d5f7480f0a7 to your computer and use it in GitHub Desktop.
Save wylie39/87e34f807f88958fa8ad7d5f7480f0a7 to your computer and use it in GitHub Desktop.
const { Client, Intents } = require('discord.js')
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGES,
],
partials: ['CHANNEL', 'MESSAGE'],
})
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on('messageCreate', (message) => {
if (message.guild === null) {
console.log('This is a DM') // if is DM
}
if (message.content.startsWith('ping')) {
message.author.send('Pong')
}
})
client.login('token')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment