Migrate ModActions to new Plugin structure !!mutes dont work!!

This commit is contained in:
Dark 2020-07-24 02:25:33 +02:00
parent ebcb28261b
commit fd56664984
29 changed files with 1213 additions and 16 deletions

View file

@ -1,7 +1,7 @@
import { eventListener } from "knub";
import { IgnoredEventType, ModActionsPluginType } from "../types";
import { isEventIgnored } from "../functions/isEventIgnored";
import { clearIgnoredEvent } from "../functions/clearIgnoredEvents";
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
import { Constants as ErisConstants } from "eris";
import { safeFindRelevantAuditLogEntry } from "../functions/safeFindRelevantAuditLogEntry";
import { CasesPlugin } from "../../Cases/CasesPlugin";
@ -15,7 +15,7 @@ export const CreateBanCaseOnManualBanEvt = eventListener<ModActionsPluginType>()
"guildBanAdd",
async ({ pluginData, args: { guild, user } }) => {
if (isEventIgnored(pluginData, IgnoredEventType.Ban, user.id)) {
clearIgnoredEvent(pluginData, IgnoredEventType.Ban, user.id);
clearIgnoredEvents(pluginData, IgnoredEventType.Ban, user.id);
return;
}

View file

@ -1,7 +1,7 @@
import { eventListener } from "knub";
import { IgnoredEventType, ModActionsPluginType } from "../types";
import { isEventIgnored } from "../functions/isEventIgnored";
import { clearIgnoredEvent } from "../functions/clearIgnoredEvents";
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
import { Constants as ErisConstants } from "eris";
import { safeFindRelevantAuditLogEntry } from "../functions/safeFindRelevantAuditLogEntry";
import { CasesPlugin } from "../../Cases/CasesPlugin";
@ -18,7 +18,7 @@ export const CreateKickCaseOnManualKickEvt = eventListener<ModActionsPluginType>
"guildMemberRemove",
async ({ pluginData, args: { member } }) => {
if (isEventIgnored(pluginData, IgnoredEventType.Kick, member.id)) {
clearIgnoredEvent(pluginData, IgnoredEventType.Kick, member.id);
clearIgnoredEvents(pluginData, IgnoredEventType.Kick, member.id);
return;
}

View file

@ -1,7 +1,7 @@
import { eventListener } from "knub";
import { IgnoredEventType, ModActionsPluginType } from "../types";
import { isEventIgnored } from "../functions/isEventIgnored";
import { clearIgnoredEvent } from "../functions/clearIgnoredEvents";
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
import { Constants as ErisConstants } from "eris";
import { safeFindRelevantAuditLogEntry } from "../functions/safeFindRelevantAuditLogEntry";
import { CasesPlugin } from "../../Cases/CasesPlugin";
@ -15,7 +15,7 @@ export const CreateUnbanCaseOnManualUnbanEvt = eventListener<ModActionsPluginTyp
"guildBanRemove",
async ({ pluginData, args: { guild, user } }) => {
if (isEventIgnored(pluginData, IgnoredEventType.Unban, user.id)) {
clearIgnoredEvent(pluginData, IgnoredEventType.Unban, user.id);
clearIgnoredEvents(pluginData, IgnoredEventType.Unban, user.id);
return;
}

View file

@ -0,0 +1,26 @@
import { eventListener } from "knub";
import { ModActionsPluginType } from "../types";
/**
* Show an alert if a member with prior notes joins the server
*/
export const PostAlertOnMemberJoinEvt = eventListener<ModActionsPluginType>()(
"guildMemberAdd",
async ({ pluginData, args: { guild, member } }) => {
const config = pluginData.config.get();
if (!config.alert_on_rejoin) return;
const alertChannelId = config.alert_channel;
if (!alertChannelId) return;
const actions = await pluginData.state.cases.getByUserId(member.id);
if (actions.length) {
const alertChannel: any = pluginData.guild.channels.get(alertChannelId);
alertChannel.send(
`<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${member.id}\`) joined with ${actions.length} prior record(s)`,
);
}
},
);