Skip to content

Commit

Permalink
Quotes API is being weird
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleylamont committed Oct 30, 2024
1 parent 187d592 commit c1e2d9d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/quotes-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function convertMessageToQuote(
}

export async function refreshQuotes() {
console.log("Refreshing quotes");
const quotesChannel = await globalThis.cssaGuild.channels.fetch(
"1169166790094491678",
);
Expand All @@ -88,13 +89,21 @@ export async function refreshQuotes() {
}
// Start fetching recent top-level messages
let hitCachedMessage = false;
let messages = await quotesChannel.messages.fetch({ limit: 100 });
let messages = await quotesChannel.messages.fetch({
limit: 100,
cache: false,
});
while (!hitCachedMessage && messages.size > 0) {
for (const message of messages.values()) {
const quote = convertMessageToQuote(message);
if (quote !== undefined) {
if (quotes.has(message.id)) {
if (!hitCachedMessage) {
console.log("Hit cached message");
}
hitCachedMessage = true;
} else {
console.log("Adding new quote");
}
quotes.set(message.id, quote);
}
Expand Down

0 comments on commit c1e2d9d

Please sign in to comment.