Skip to content

Commit

Permalink
Fix FAQ fetching (Discord wants < 100 length)
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterscotchV committed Jan 12, 2024
1 parent c305f30 commit c3aaba0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions bingus-bot/src/commands/ask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import {
import { Command } from "../index.js";
import { EmbedList, fetchBingus, fetchBingusData } from "../util.js";

let faqConfig = (await fetchBingusData()).faqs.flatMap(
(x) => x.matched_questions,
);
async function getFaqConfig() {
return (await fetchBingusData()).faqs.flatMap(
(x) => x.matched_questions.filter((x) => x.length > 0 && x.length <= 100),
)
}

let faqConfig = await getFaqConfig();

setInterval(async () => {
faqConfig = (await fetchBingusData()).faqs.flatMap(
(x) => x.matched_questions,
);
faqConfig = await getFaqConfig();
}, 60 * 60 * 1000); // Do it every hour

export const askCommand: Command = {
Expand Down

0 comments on commit c3aaba0

Please sign in to comment.