-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (27 loc) · 800 Bytes
/
app.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
require("dotenv").config();
const { Client, GatewayIntentBits } = require("discord.js");
const { ask } = require("./services/ai");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
if (message.content.startsWith("!")) {
await message.reply({
content: "Please wait your message is processing!",
});
const messageContent = await message.content.replace("!", "");
const answer = await ask(messageContent);
message.reply({
content: answer,
});
}
});
client.login(process.env.DISCORD_TOKEN);