-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (27 loc) · 917 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
"use strict";
require("dotenv").config();
const { Client, Intents } = require("discord.js");
console.log("Here we go again 🕶");
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
const TOKEN = process.env.TOKEN;
// When the client is ready, run this code (only once)
client.once("ready", () => {
console.log("Ready! 🤖");
});
const MESSAGE_RESPONSE = ["Mundo 🌍", "Como estas ?", "Que tal"];
//
function gotMessage(message) {
/* This function handler all new messages
include the messages created by the bot
be carefull of who & what reply
*/
if (message.content === "hola" && !message.author.bot) {
let randomIndex = Math.floor(Math.random() * MESSAGE_RESPONSE.length);
message.channel.send(MESSAGE_RESPONSE[randomIndex]);
}
}
client.on("messageCreate", gotMessage);
// Login to Discord with your client's token
client.login(TOKEN);