mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-16 06:35:03 +00:00
chore: fix lint errors; tweak lint rules
This commit is contained in:
parent
9b3d6f5d68
commit
5f194bf1ef
115 changed files with 176 additions and 264 deletions
|
@ -248,7 +248,7 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
|||
},
|
||||
|
||||
async afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
const { state } = pluginData;
|
||||
|
||||
state.clearRecentActionsInterval = setInterval(() => clearOldRecentActions(pluginData), 1 * MINUTES);
|
||||
state.clearRecentSpamInterval = setInterval(() => clearOldRecentSpam(pluginData), 1 * SECONDS);
|
||||
|
|
|
@ -11,7 +11,7 @@ export const AddToCounterAction = automodAction({
|
|||
|
||||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) {
|
||||
async apply({ pluginData, contexts, actionConfig, ruleName }) {
|
||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||
if (!countersPlugin.counterExists(actionConfig.counter)) {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
|
|
|
@ -20,7 +20,7 @@ export const ChangeNicknameAction = automodAction({
|
|||
if (pluginData.state.recentNicknameChanges.has(member.id)) continue;
|
||||
const newName = typeof actionConfig === "string" ? actionConfig : actionConfig.name;
|
||||
|
||||
member.edit({ nick: newName }).catch((err) => {
|
||||
member.edit({ nick: newName }).catch(() => {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Failed to change the nickname of \`${member.id}\``,
|
||||
});
|
||||
|
|
|
@ -70,7 +70,7 @@ export const ChangePermsAction = automodAction({
|
|||
}),
|
||||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, ruleName }) {
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
const user = contexts.find((c) => c.user)?.user;
|
||||
const message = contexts.find((c) => c.message)?.message;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ export const ExampleAction = automodAction({
|
|||
|
||||
defaultConfig: {},
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
// TODO: Everything
|
||||
},
|
||||
|
|
|
@ -7,7 +7,7 @@ export const SetAntiraidLevelAction = automodAction({
|
|||
configType: tNullable(t.string),
|
||||
defaultConfig: "",
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
async apply({ pluginData, actionConfig }) {
|
||||
setAntiraidLevel(pluginData, actionConfig ?? null);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ export const SetCounterAction = automodAction({
|
|||
|
||||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) {
|
||||
async apply({ pluginData, contexts, actionConfig, ruleName }) {
|
||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||
if (!countersPlugin.counterExists(actionConfig.counter)) {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
|
|
|
@ -31,7 +31,7 @@ export const StartThreadAction = automodAction({
|
|||
limit_per_channel: 5,
|
||||
},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, ruleName }) {
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
// check if the message still exists, we don't want to create threads for deleted messages
|
||||
const threads = contexts.filter((c) => {
|
||||
if (!c.message || !c.user) return false;
|
||||
|
|
|
@ -9,7 +9,7 @@ export async function runAutomodOnModAction(
|
|||
modAction: ModActionType,
|
||||
userId: string,
|
||||
reason?: string,
|
||||
isAutomodAction: boolean = false,
|
||||
isAutomodAction = false,
|
||||
) {
|
||||
const [user, member] = await Promise.all([
|
||||
resolveUser(pluginData.client, userId),
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { getEmojiInString, getRoleMentions, getUrlsInString, getUserMentions } from "../../../utils";
|
||||
import { RECENT_ACTION_EXPIRY_TIME, RecentActionType } from "../constants";
|
||||
import { RecentActionType } from "../constants";
|
||||
import { AutomodContext, AutomodPluginType } from "../types";
|
||||
|
||||
export function addRecentActionsFromMessage(pluginData: GuildPluginData<AutomodPluginType>, context: AutomodContext) {
|
||||
const message = context.message!;
|
||||
const globalIdentifier = message.user_id;
|
||||
const perChannelIdentifier = `${message.channel_id}-${message.user_id}`;
|
||||
const expiresAt = Date.now() + RECENT_ACTION_EXPIRY_TIME;
|
||||
|
||||
pluginData.state.recentActions.push({
|
||||
context,
|
||||
|
|
|
@ -14,7 +14,6 @@ const MessageSpamTriggerConfig = t.type({
|
|||
within: tDelayString,
|
||||
per_channel: tNullable(t.boolean),
|
||||
});
|
||||
type TMessageSpamTriggerConfig = t.TypeOf<typeof MessageSpamTriggerConfig>;
|
||||
|
||||
interface TMessageSpamMatchResultType {
|
||||
archiveId: string;
|
||||
|
|
|
@ -12,7 +12,7 @@ interface BaseAutomodTriggerMatchResult {
|
|||
fullSummary?: string;
|
||||
}
|
||||
|
||||
export type AutomodTriggerMatchResult<TExtra extends any = unknown> = unknown extends TExtra
|
||||
export type AutomodTriggerMatchResult<TExtra = unknown> = unknown extends TExtra
|
||||
? BaseAutomodTriggerMatchResult
|
||||
: BaseAutomodTriggerMatchResult & { extra: TExtra };
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import * as t from "io-ts";
|
|||
import { tNullable } from "../../../utils";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
||||
// tslint:disable-next-line
|
||||
interface AntiraidLevelTriggerResult {}
|
||||
|
||||
export const AntiraidLevelTrigger = automodTrigger<AntiraidLevelTriggerResult>()({
|
||||
|
@ -12,7 +11,7 @@ export const AntiraidLevelTrigger = automodTrigger<AntiraidLevelTriggerResult>()
|
|||
|
||||
defaultConfig: {},
|
||||
|
||||
async match({ triggerConfig, context, pluginData }) {
|
||||
async match({ triggerConfig, context }) {
|
||||
if (!context.antiraid) {
|
||||
return;
|
||||
}
|
||||
|
@ -26,7 +25,7 @@ export const AntiraidLevelTrigger = automodTrigger<AntiraidLevelTriggerResult>()
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult, pluginData, contexts, triggerConfig }) {
|
||||
renderMatchInformation({ contexts }) {
|
||||
const newLevel = contexts[0].antiraid!.level;
|
||||
return newLevel ? `Antiraid level was set to ${newLevel}` : `Antiraid was turned off`;
|
||||
},
|
||||
|
|
|
@ -3,7 +3,6 @@ import * as t from "io-ts";
|
|||
import { verboseChannelMention } from "../../../utils";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
interface AnyMessageResultType {}
|
||||
|
||||
export const AnyMessageTrigger = automodTrigger<AnyMessageResultType>()({
|
||||
|
@ -11,7 +10,7 @@ export const AnyMessageTrigger = automodTrigger<AnyMessageResultType>()({
|
|||
|
||||
defaultConfig: {},
|
||||
|
||||
async match({ pluginData, context, triggerConfig: trigger }) {
|
||||
async match({ context }) {
|
||||
if (!context.message) {
|
||||
return;
|
||||
}
|
||||
|
@ -21,7 +20,7 @@ export const AnyMessageTrigger = automodTrigger<AnyMessageResultType>()({
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ pluginData, contexts, matchResult }) {
|
||||
renderMatchInformation({ pluginData, contexts }) {
|
||||
const channel = pluginData.guild.channels.cache.get(contexts[0].message!.channel_id as Snowflake);
|
||||
return `Matched message (\`${contexts[0].message!.id}\`) in ${
|
||||
channel ? verboseChannelMention(channel) : "Unknown Channel"
|
||||
|
|
|
@ -30,7 +30,7 @@ export const BanTrigger = automodTrigger<BanTriggerResultType>()({
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult }) {
|
||||
renderMatchInformation() {
|
||||
return `User was banned`;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@ export const CounterTrigger = automodTrigger<CounterTriggerResult>()({
|
|||
|
||||
defaultConfig: {},
|
||||
|
||||
async match({ triggerConfig, context, pluginData }) {
|
||||
async match({ triggerConfig, context }) {
|
||||
if (!context.counterTrigger) {
|
||||
return;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ export const CounterTrigger = automodTrigger<CounterTriggerResult>()({
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult, pluginData, contexts, triggerConfig }) {
|
||||
renderMatchInformation({ contexts }) {
|
||||
let str = `Matched counter trigger \`${contexts[0].counterTrigger!.prettyCounter} / ${
|
||||
contexts[0].counterTrigger!.prettyTrigger
|
||||
}\``;
|
||||
|
|
|
@ -29,7 +29,7 @@ export const KickTrigger = automodTrigger<KickTriggerResultType>()({
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult }) {
|
||||
renderMatchInformation() {
|
||||
return `User was kicked`;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@ export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
|
|||
whitelist_enabled: false,
|
||||
},
|
||||
|
||||
async match({ pluginData, context, triggerConfig: trigger }) {
|
||||
async match({ context, triggerConfig: trigger }) {
|
||||
if (!context.message) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ export const MemberJoinTrigger = automodTrigger<unknown>()({
|
|||
new_threshold: "1h",
|
||||
},
|
||||
|
||||
async match({ pluginData, context, triggerConfig }) {
|
||||
async match({ context, triggerConfig }) {
|
||||
if (!context.joined || !context.member) {
|
||||
return;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export const MemberJoinTrigger = automodTrigger<unknown>()({
|
|||
return {};
|
||||
},
|
||||
|
||||
renderMatchInformation({ pluginData, contexts, triggerConfig }) {
|
||||
renderMatchInformation() {
|
||||
return "";
|
||||
},
|
||||
});
|
||||
|
|
|
@ -45,7 +45,7 @@ export const MemberJoinSpamTrigger = automodTrigger<unknown>()({
|
|||
}
|
||||
},
|
||||
|
||||
renderMatchInformation({ pluginData, contexts, triggerConfig }) {
|
||||
renderMatchInformation() {
|
||||
return "";
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ export const MemberLeaveTrigger = automodTrigger<unknown>()({
|
|||
|
||||
defaultConfig: {},
|
||||
|
||||
async match({ pluginData, context, triggerConfig }) {
|
||||
async match({ context }) {
|
||||
if (!context.joined || !context.member) {
|
||||
return;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ export const MemberLeaveTrigger = automodTrigger<unknown>()({
|
|||
return {};
|
||||
},
|
||||
|
||||
renderMatchInformation({ pluginData, contexts, triggerConfig }) {
|
||||
renderMatchInformation() {
|
||||
return "";
|
||||
},
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@ export const MuteTrigger = automodTrigger<MuteTriggerResultType>()({
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult }) {
|
||||
renderMatchInformation() {
|
||||
return `User was muted`;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ export const NoteTrigger = automodTrigger<NoteTriggerResultType>()({
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult }) {
|
||||
renderMatchInformation() {
|
||||
return `Note was added on user`;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -45,7 +45,7 @@ export const ThreadCreateSpamTrigger = automodTrigger<unknown>()({
|
|||
}
|
||||
},
|
||||
|
||||
renderMatchInformation({ pluginData, contexts, triggerConfig }) {
|
||||
renderMatchInformation() {
|
||||
return "";
|
||||
},
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ export const UnbanTrigger = automodTrigger<UnbanTriggerResultType>()({
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult }) {
|
||||
renderMatchInformation() {
|
||||
return `User was unbanned`;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ export const UnmuteTrigger = automodTrigger<UnmuteTriggerResultType>()({
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult }) {
|
||||
renderMatchInformation() {
|
||||
return `User was unmuted`;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@ export const WarnTrigger = automodTrigger<WarnTriggerResultType>()({
|
|||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult }) {
|
||||
renderMatchInformation() {
|
||||
return `User was warned`;
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue