Skip to content

Instantly share code, notes, and snippets.

@trezy
Last active March 6, 2022 05:03
Show Gist options
  • Save trezy/f085454ea6baa68701f88a532fd88eb4 to your computer and use it in GitHub Desktop.
Save trezy/f085454ea6baa68701f88a532fd88eb4 to your computer and use it in GitHub Desktop.
// Module imports
import 'dotenv/config'
import {
Client,
Intents,
} from 'discord.js'
// Create a new client instance
const client = new Client({
intents: [
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGES,
],
partials: [
'CHANNEL',
'MESSAGE',
'REACTION',
],
})
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!')
})
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return
const { commandName } = interaction
if (commandName === 'ping') {
console.log('Executing \'ping\' command...')
await interaction.reply('Pong!')
console.log(`Done.`)
}
})
client.login(process.env.DISCORD_TOKEN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment