3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

Reformat all files with Prettier

This commit is contained in:
Dragory 2021-09-11 19:06:51 +03:00
parent 0cde0d46d2
commit ac79eb09f5
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
206 changed files with 727 additions and 888 deletions

View file

@ -82,7 +82,7 @@ export const SpamPlugin = zeppelinGuildPlugin<SpamPluginType>()({
const { state } = pluginData;
state.expiryInterval = setInterval(() => clearOldRecentActions(pluginData), 1000 * 60);
state.onMessageCreateFn = msg => onMessageCreate(pluginData, msg);
state.onMessageCreateFn = (msg) => onMessageCreate(pluginData, msg);
state.savedMessages.events.on("create", state.onMessageCreateFn);
},

View file

@ -6,5 +6,7 @@ const MAX_INTERVAL = 300;
export function clearOldRecentActions(pluginData: GuildPluginData<SpamPluginType>) {
// TODO: Figure out expiry time from longest interval in the config?
const expiryTimestamp = Date.now() - 1000 * MAX_INTERVAL;
pluginData.state.recentActions = pluginData.state.recentActions.filter(action => action.timestamp >= expiryTimestamp);
pluginData.state.recentActions = pluginData.state.recentActions.filter(
(action) => action.timestamp >= expiryTimestamp,
);
}

View file

@ -7,7 +7,7 @@ export function clearRecentUserActions(
userId: string,
actionGroupId: string,
) {
pluginData.state.recentActions = pluginData.state.recentActions.filter(action => {
pluginData.state.recentActions = pluginData.state.recentActions.filter((action) => {
return action.type !== type || action.userId !== userId || action.actionGroupId !== actionGroupId;
});
}

View file

@ -8,7 +8,7 @@ export function getRecentActions(
actionGroupId: string,
since: number,
) {
return pluginData.state.recentActions.filter(action => {
return pluginData.state.recentActions.filter((action) => {
if (action.timestamp < since) return false;
if (action.type !== type) return false;
if (action.actionGroupId !== actionGroupId) return false;

View file

@ -103,8 +103,8 @@ export async function logAndDetectMessageSpam(
// Get the offending message IDs
// We also get the IDs of any messages after the last offending message, to account for lag before detection
const savedMessages = recentActions.map(a => a.extraData as SavedMessage);
const msgIds = savedMessages.map(m => m.id);
const savedMessages = recentActions.map((a) => a.extraData as SavedMessage);
const msgIds = savedMessages.map((m) => m.id);
const lastDetectedMsgId = msgIds[msgIds.length - 1];
const additionalMessages = await pluginData.state.savedMessages.getUserMessagesByChannelAfterId(
@ -112,11 +112,11 @@ export async function logAndDetectMessageSpam(
savedMessage.channel_id,
lastDetectedMsgId,
);
additionalMessages.forEach(m => msgIds.push(m.id));
additionalMessages.forEach((m) => msgIds.push(m.id));
// Then, if enabled, remove the spam messages
if (spamConfig.clean !== false) {
msgIds.forEach(id => pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id));
msgIds.forEach((id) => pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id));
(pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake)! as TextChannel | undefined)
?.bulkDelete(msgIds as Snowflake[])
.catch(noop);
@ -126,7 +126,7 @@ export async function logAndDetectMessageSpam(
const uniqueMessages = Array.from(new Set([...savedMessages, ...additionalMessages]));
uniqueMessages.sort((a, b) => (a.id > b.id ? 1 : -1));
const lastHandledMsgId = uniqueMessages
.map(m => m.id)
.map((m) => m.id)
.reduce((last, id): string => {
return id > last ? id : last;
});
@ -188,7 +188,7 @@ export async function logAndDetectMessageSpam(
});
}
},
err => {
(err) => {
logger.error(`Error while detecting spam:\n${err}`);
},
);