-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
57 lines (50 loc) · 1.65 KB
/
bot.js
File metadata and controls
57 lines (50 loc) · 1.65 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
// require("dotenv").config();
const { Client, IntentsBitField } = require("discord.js");
const reader = require("xlsx");
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
});
client.on("ready", (c) => {
console.log(`✅ ${c.user.tag} is online.`);
});
client.on("messageCreate", (message) => {
if (message.author.bot) {
return;
}
if (message.content === "hello") {
message.reply("hello");
}
if (message.content === "getaProblem") {
// read the Excel file
// const workbook = XLSX.readFile("pramodh.xlsx");
// console.log(workbook)
// const sheet_name_list = workbook.SheetNames[0];
// console.log(sheet_name_list)
// const data = XLSX.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]]);
// // send the data as a message to the designated channel
// message.channel.send(data);
const file = reader.readFile("./pramodh.xlsx");
const temp = reader.utils.sheet_to_json(file.Sheets[file.SheetNames[0]])
console.log(temp[2])
message.channel.send({ content: temp[2].Question_Link });
// let data = [];
// const sheets = file.SheetNames;
// for (let i = 0; i < sheets.length; i++) {
// const temp = reader.utils.sheet_to_json(file.Sheets[file.SheetNames[i]]);
// temp.forEach((res) => {
// data.push(res);
// });
// }
// const temp = reader.utils.sheet_to_json(file.Sheets[file.SheetNames[i]]
// // Printing data
// console.log(data);
}
});
client.login(
"Discord Token"
);