-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
76 lines (66 loc) · 2.33 KB
/
index.js
File metadata and controls
76 lines (66 loc) · 2.33 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// import { REST, Routes } from 'discord.js';
require('dotenv').config();
const { Insults } = require("./src/datastore");
const Discord = require("discord.js");
const token = process.env.CLIENT_TOKEN;
const prefix = process.env.PREFIX;
client.on('ready', async () => {
console.log(`I'M READY! ${client.user.username}`)
});
function getRandomInsult() {
const insults = Object.values(Insults);
return insults[Math.floor(Math.random() * insults.length)];
//TODO: instead of an enum, will use an LLM!
}
// const LLM_client = new InferenceClient(process.env.HUGGING_FACE_API);
const LLM_client = process.env.HUGGING_FACE_API;
// async function generateLLMInsult() {
// try {
// const prompt = `Roast someone in a creative way:`;
// const response = await fetch(
// 'https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-R1',
// {
// method: 'POST',
// headers: {
// 'Authorization': `Bearer ${LLM_client}`,
// 'Content-Type': 'application/json'
// },
// body: JSON.stringify({ inputs: prompt,
// parameters: {
// max_length: 60,
// temperature: 0.9
// }
// }),
// timeout: 6000
// }
// );
// if (!response.ok) throw new Error(`API error: ${response.status}`);
// const data = await response.json();
// console.log(data);
// return data[0]?.generated_text || "I'm too nice to insult you!";
// } catch (e) {
// console.error("LLM Error:", e);
// return getRandomInsult(); // Fallback to local insults
// }
// }
// generateLLMInsult();
function textToMessage(message) {
//TODO: takes input from terminal --> sends as message via bot
message = 'you suck';
return message;
}
client.on('messageCreate', async (message) => {
if (message.content.toLowerCase() === prefix + "test") {
message.reply("Test successful!");
}
if (message.content.toLowerCase().includes('mean')) {
message.reply(getRandomInsult());
// message.reply(generateLLMInsult());
}
if (message.content.toLowerCase() === prefix + "ping") {
message.channel.send("PONG \n" + `🏓Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms` + "\nPING");
}
//TODO: features
//
});
client.login(token);