-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
43 lines (36 loc) · 856 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
39
40
41
42
43
const Eris = require("eris");
const GPT4 = require('./gpt.js');
let token = "";
let GPT = new GPT4('./gpt4all-lora-quantized-win64');
GPT.on('ready', async () => {
new Bot(token).start();
});
class Bot {
constructor(token){
this.token = token;
this.bot = new Eris(this.token, {
intents: [
"guildMessages"
]
});
}
async start(){
this.bot.on("ready", () => {
console.log(`Logged into (${this.bot.user.id})`);
});
this.bot.on("messageCreate", async (msg) => {
try{
if(msg.author.id != this.bot.user.id){
this.bot.sendChannelTyping(msg.channel.id);
let response = await GPT.ask(msg.content);
response = response.replace(`[1m[32m[0m`,"");
this.bot.createMessage(msg.channel.id, response);
}
}catch(err){
console.log(err);
return;
}
});
this.bot.connect();
}
}