From eed1aec44defb80d4082a2b817d74fa51406a9b2 Mon Sep 17 00:00:00 2001 From: Butterscotch! Date: Tue, 24 Oct 2023 22:02:00 -0400 Subject: [PATCH] Return only 5 results & fix mention regex (#7) --- bingus-bot/src/index.ts | 4 ++-- bingus-bot/src/util.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bingus-bot/src/index.ts b/bingus-bot/src/index.ts index fab9d69..129336d 100644 --- a/bingus-bot/src/index.ts +++ b/bingus-bot/src/index.ts @@ -96,7 +96,7 @@ client.on("threadCreate", async (thread, newly) => { const embedList = new EmbedList(); embedList.push( - ...data.map( + ...data.slice(0, 5).map( (res) => new EmbedBuilder() .setTitle(res.title) @@ -129,7 +129,7 @@ client.on("messageCreate", async (msg) => { await msg.fetch(); const lowercase = msg.content.toLowerCase(); // Check if Bingus is being mentioned in some way - if (msg.mentions.users.has(clientId) || /bot|bing\w{,4}/.test(lowercase)) { + if (msg.mentions.users.has(clientId) || /\b(bot|bing\w{0,4})\b/.test(lowercase)) { // Check if Bingus recently sent a message const lastMessages = await msg.channel.messages.fetch({ limit: 10, diff --git a/bingus-bot/src/util.ts b/bingus-bot/src/util.ts index 8e48295..ba7810a 100644 --- a/bingus-bot/src/util.ts +++ b/bingus-bot/src/util.ts @@ -18,7 +18,7 @@ import { fileURLToPath } from "url"; export async function fetchBingus(query: string) { const url = `https://bingus.bscotch.ca/api/faq/search?question=${encodeURIComponent( query, - )}&responseCount=30`; + )}&responseCount=5`; return await fetch(url).then( (res) => res.json() as Promise,