From 2744d98d904a3c3126fcf24c2518ae6b3eebf721 Mon Sep 17 00:00:00 2001 From: "Meijer,L. (Lucas)" Date: Tue, 19 Nov 2024 22:43:41 +0100 Subject: [PATCH] Fix lambda function TypeScript errors --- server/chat-plugins/mafia.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/chat-plugins/mafia.ts b/server/chat-plugins/mafia.ts index 6eb3b5af2a27..550a713e2357 100644 --- a/server/chat-plugins/mafia.ts +++ b/server/chat-plugins/mafia.ts @@ -141,8 +141,10 @@ function writeFile(path: string, data: AnyObject) { )); } -function mafiaSearch(entries: [string, MafiaDataAlignment | MafiaDataRole | MafiaDataTheme | MafiaDataIDEA | MafiaDataTerm][], - searchTarget: string, searchType: keyof MafiaData) { +function mafiaSearch( + entries: [string, MafiaDataAlignment | MafiaDataRole | MafiaDataTheme | MafiaDataIDEA | MafiaDataTerm][], + searchTarget: string, searchType: keyof MafiaData +) { if (typeof (entries) === 'undefined') return entries; if (searchType === `aliases`) return entries; @@ -191,9 +193,8 @@ function mafiaSearch(entries: [string, MafiaDataAlignment | MafiaDataRole | Mafi entries = entries.filter(([key, data]) => MafiaData[`IDEAs`][alias].roles.map(role => toID((toID(role) in MafiaData[`aliases`]) ? MafiaData[`aliases`][toID(role)] : role)).includes(toID(key))); } else { - entries = entries.filter(([key]) => Object.keys((MafiaData[searchType][key])) - .filter((newKey: keyof MafiaData[keyof MafiaData]) => (MafiaData[searchType][key])[newKey] - .toString().toLowerCase().includes(searchTarget)).length > 0); + entries = entries.filter(([key]) => Object.entries(MafiaData[searchType][key]) + .some(([newKey, value]) => value.toString().toLowerCase().includes(searchTarget))); } return negation ? entriesCopy.filter(element => !entries.includes(element)) : entries; } @@ -4255,7 +4256,7 @@ export const commands: Chat.ChatCommands = { table += entries .map(([key, data]) => searchType === `themes` ? themeRow(MafiaData[searchType][key]) : searchType === `IDEAs` ? - ideaRow(MafiaData[searchType][key]) : row(MafiaData[searchType as "roles" | "alignments" | "terms"][key as string])) + ideaRow(MafiaData[searchType][key]) : row(MafiaData[searchType as "roles" | "alignments" | "terms"][key])) .join(''); table += ``; return this.sendReplyBox(table);