Skip to content

Commit

Permalink
Return only 5 results & fix mention regex (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterscotchV authored Oct 25, 2023
1 parent 7894422 commit eed1aec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bingus-bot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion bingus-bot/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BingusFaqResponse[]>,
Expand Down

0 comments on commit eed1aec

Please sign in to comment.