-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (42 loc) · 1.34 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
46
require("dotenv").config();
const { Client } = require("discord.js");
const { Bot } = require("cathy.js");
const client = new Client({
disableMentions: "all"
});
const cathy = new Bot(); // create new chatbot client
const errorMessages = [
"Sorry, I can't understand.",
"What do you mean?",
"uh",
"I love you :D",
"Why D:",
"Wut?",
"Hmm.",
"idot",
"idot, wdym?"
]; // messages to send if there's error
client.on("ready", () => {
console.log("Bot is ready!");
cathy.load(); // load cathy
});
cathy.on("ready", () => {
console.log("Cathy is ready!");
});
client.on("message", async message => {
if (message.author.bot || !message.guild) return;
if (message.channel.id === "738092276051607703") {
message.channel.startTyping();
cathy.chat(message.content) // chat
.then(msg => {
if (!msg.content) return message.channel.send(errorMessages[Math.floor(Math.random() * errorMessages.length)]);
message.channel.stopTyping(true);
return message.channel.send(msg.content);
})
.catch(e => {
message.channel.stopTyping(true);
return message.channel.send(errorMessages[Math.floor(Math.random() * errorMessages.length)]);
});
}
});
client.login(process.env.TOKEN);