-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
38 lines (29 loc) · 1000 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
37
38
import Discord from "discord.js";
import { openaiAnswer } from "./helpers.js";
import dotenv from "dotenv";
dotenv.config();
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
});
client.on("reconnecting", () => {
console.log(`Reconnecting - ${client.user.tag}!`)
});
client.on("disconnect", () => {
console.log(`Disconnect - ${client.user.tag}!`)
});
client.on("message", async message => {
if (message.author.bot) return;
if (message.content.includes("@here") || message.content.includes("@everyone") || message.type == "REPLY") return;
if (message.content === "ping") {
message.reply("pong");
return;
}
if (message.content.startsWith("!")) {
//custom commands
}
if (message.mentions.has(client.user.id) || message.content.toString().includes(process.env.ROBOT_USER_ID)) {
openaiAnswer(message, client);
}
});
client.login(process.env.CLIENT_TOKEN);