Skip to content

Commit

Permalink
compiled ts file
Browse files Browse the repository at this point in the history
  • Loading branch information
akanshaaa19 committed Oct 20, 2024
1 parent 487ef70 commit 0cb4504
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,7 @@ const writeDataToSheets = async (question, answer, category, author) => {
catch (error) { }
const service = google.sheets({ version: "v4", auth });
let values = [
[
new Date(),
author,
question,
tag1,
tag2,
tag3,
reason,
category,
answer,
],
[new Date(), author, question, tag1, tag2, tag3, reason, category, answer],
];
const requestBody = {
values,
Expand Down Expand Up @@ -163,7 +153,7 @@ const getAnswerFromOpenAIAssistant = async (message, prompt) => {
return "Sorry, I am not able to answer this question due to timeout in API. Please try again later.";
}
catch (e) {
return "Sorry, I am not able to answer this question due to timeout in API. Please try again later.";
return "Sorry, I am not able to answer this question due to timeout in API. Please try again later";
}
};
const client = new DiscordJS.Client({
Expand Down Expand Up @@ -262,8 +252,7 @@ client.on("interactionCreate", async (interaction) => {
for (let [id, message] of messages) {
lastMessage = message;
}
const timeSpanned = (lastMessage?.createdTimestamp || 0) -
value.createdTimestamp;
const timeSpanned = (lastMessage?.createdTimestamp || 0) - value.createdTimestamp;
allIDs.push({ id: key, timeSpanned: timeSpanned });
}
}
Expand All @@ -282,14 +271,10 @@ client.on("interactionCreate", async (interaction) => {
const ngoSupportForum = (await client.channels.fetch(process.env.CHANNEL_ID || ""));
const availableTags = await ngoSupportForum.availableTags;
const option = [
new StringSelectMenuOptionBuilder()
.setLabel("None")
.setValue("None"),
new StringSelectMenuOptionBuilder().setLabel("None").setValue("None"),
];
availableTags.forEach((tag) => {
option.push(new StringSelectMenuOptionBuilder()
.setLabel(tag.name)
.setValue(tag.id));
option.push(new StringSelectMenuOptionBuilder().setLabel(tag.name).setValue(tag.id));
});
const select = new StringSelectMenuBuilder()
.setCustomId("starter")
Expand Down Expand Up @@ -358,6 +343,7 @@ client.on("threadCreate", async (thread) => {
const message = firstMessage?.content || "";
const author = firstMessage?.author.username || "";
thread.sendTyping();
thread.send("Please note that from the 19th to 27th October, our team will be engaged in an in-person sprint. During this time, responses may be slower than usual. We appreciate your patience and will get back to you as soon as possible. Thank you!");
const answer = await getAnswerFromOpenAIAssistant(message, "");
const role = thread.guild.roles.cache.find((role) => role.name === "Glific Support");
thread.send(answer);
Expand Down

0 comments on commit 0cb4504

Please sign in to comment.