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:
parent
0cde0d46d2
commit
ac79eb09f5
206 changed files with 727 additions and 888 deletions
|
@ -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);
|
||||
},
|
||||
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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}`);
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue