-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
50 lines (46 loc) · 1.45 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
47
48
49
50
const Discord = require('discord.js');
const client = new Discord.Client();
require('discord-reply');
const cwk = require ("cwk-api");
const { readdirSync } = require("fs");
const { token , default_prefix } = require ("./config.json")
const db = require ("quick.db");
// handelr
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
["command", "events"].forEach(handler => {
require(`./handler/${handler}`)(client);
});
client.on('ready', () => {
client.user.setActivity("chatbot by cwkhan | YouTube.com/cwkhan")
console.log(`Logged in as ${client.user.tag}!`);
});
// Chatbot event
client.on("message", async messag => {
const cchann = db.get(`cwkchatbotch_${message.guild.id}`);
if (cchann === null) return;
if (!cchann) return;
const sender = client.channels.cache.get(cchann);
if (message.channel.name == sender.name) {
if (message.author.bot) return;
message.content = message.content
.replace(/@(everyone)/gi, "everyone")
.replace(/@(here)/gi, "here");
message.channel.stopTyping();
message.channel.startTyping();
fetch(`https://api.snowflake107.repl.co/api/chatbot?message=${encodeURIComponent(message.content)}&name=automodbot`, {
headers: {
"Authorization": ""
}
})
.then(res => res.json())
.then(data => {
message.lineReply(data.message);
});
message.channel.stopTyping();
}
});
}
});
// login into bot
client.login(token)