-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (30 loc) · 952 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { Client, GatewayIntentBits } = require('discord.js')
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
})
require('dotenv').config()
const TOKEN = process.env.TOKEN
client.on('ready', () => {
console.log(`¡El bot (${client.user.tag}) se conecto!`)
})
client.on('messageCreate', async (message) => {
if (message.author.bot || !message.guild || message.channel.type === 'dm') return
const prefix = '!'
if (message.content.startsWith(prefix)) {
const args = message.content.replace(prefix, '').trim()
const command = args.toLowerCase()
if (command === 'ping') {
message.channel.send('Pong')
} else if (command === 'hola') {
message.channel.send('Hola, ¿como estas?')
} else {
console.log('El comando ingresado no es valido.')
}
}
})
client.login(TOKEN)