mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
27 lines
863 B
TypeScript
27 lines
863 B
TypeScript
import { GuildPluginData } from "knub";
|
|
import { RecentActionType } from "../constants";
|
|
import { AutomodPluginType } from "../types";
|
|
import { startProfiling } from "../../../utils/easyProfiler";
|
|
|
|
export function getMatchingRecentActions(
|
|
pluginData: GuildPluginData<AutomodPluginType>,
|
|
type: RecentActionType,
|
|
identifier: string | null,
|
|
since: number,
|
|
to?: number,
|
|
) {
|
|
const stopProfiling = startProfiling(pluginData.getKnubInstance().profiler, "automod:fns:getMatchingRecentActions");
|
|
to = to || Date.now();
|
|
|
|
const result = pluginData.state.recentActions.filter((action) => {
|
|
return (
|
|
action.type === type &&
|
|
(!identifier || action.identifier === identifier) &&
|
|
action.context.timestamp >= since &&
|
|
action.context.timestamp <= to! &&
|
|
!action.context.actioned
|
|
);
|
|
});
|
|
stopProfiling();
|
|
return result;
|
|
}
|