2020-07-23 00:37:33 +03:00
|
|
|
import { PluginData } from "knub";
|
|
|
|
import { IgnoredEventType, ModActionsPluginType } from "../types";
|
|
|
|
import { SECONDS } from "../../../utils";
|
2020-07-24 02:25:33 +02:00
|
|
|
import { clearIgnoredEvents } from "./clearIgnoredEvents";
|
2020-07-23 00:37:33 +03:00
|
|
|
|
|
|
|
const DEFAULT_TIMEOUT = 15 * SECONDS;
|
|
|
|
|
|
|
|
export function ignoreEvent(
|
|
|
|
pluginData: PluginData<ModActionsPluginType>,
|
|
|
|
type: IgnoredEventType,
|
|
|
|
userId: string,
|
|
|
|
timeout = DEFAULT_TIMEOUT,
|
|
|
|
) {
|
|
|
|
pluginData.state.ignoredEvents.push({ type, userId });
|
|
|
|
|
|
|
|
// Clear after expiry (15sec by default)
|
|
|
|
setTimeout(() => {
|
2020-07-24 02:25:33 +02:00
|
|
|
clearIgnoredEvents(pluginData, type, userId);
|
2020-07-23 00:37:33 +03:00
|
|
|
}, timeout);
|
|
|
|
}
|