-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
45 lines (40 loc) · 1.42 KB
/
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
39
40
41
42
43
44
45
import Discord from "discord.js";
import config from "./config.json" assert { type: "json" };
import errorHandler from "./src/error.js";
import { ActivityType } from "discord.js";
import messageHandler from "./src/messageHandler.js";
async function aiChatBot() {
const client = new Discord.Client({
intents: [
"Guilds", // Allows the bot to receive information about the guilds (servers) it is in
"GuildMessages", // Allows the bot to receive messages in a guild
"MessageContent", // Allows the bot to receive message content
],
});
// success message once client is logged in
client.on("ready", () => {
// to set the bot's username
// try {
// await client.user.setUsername("Pip");
// } catch {
// console.log("Error setting username");
// }
// Set custom message and presence status
try {
client.user.setPresence({
activities: [{ name: `being cute`, type: ActivityType.Custom }], // Activity types: Competing, Custom, Listening, Playing, Streaming, Watching
status: "online",
});
console.log("Activity set successfully");
} catch (error) {
console.error("Error setting activity:", error);
}
console.log(`Logged in as ${client.user.tag}!`);
// Function to handle chat messages incoming from Discord user
messageHandler(client);
});
//error handler
errorHandler();
client.login(config.token);
}
aiChatBot();