mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
automod: add triggers for mod actions
This commit is contained in:
parent
5ffc3e7cc4
commit
93912541b4
34 changed files with 412 additions and 3 deletions
|
@ -38,5 +38,7 @@ export async function clearExpiredMutes(pluginData: GuildPluginData<MutesPluginT
|
|||
? stripObjectToScalars(member, ["user", "roles"])
|
||||
: { id: mute.user_id, user: new UnknownUser({ id: mute.user_id }) },
|
||||
});
|
||||
|
||||
pluginData.state.events.emit("unmute", mute.user_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,6 +246,8 @@ export async function muteUser(
|
|||
|
||||
lock.unlock();
|
||||
|
||||
pluginData.state.events.emit("mute", user.id, reason);
|
||||
|
||||
return {
|
||||
case: theCase,
|
||||
notifyResult,
|
||||
|
|
10
backend/src/plugins/Mutes/functions/offMutesEvent.ts
Normal file
10
backend/src/plugins/Mutes/functions/offMutesEvent.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { MutesEvents, MutesPluginType } from "../types";
|
||||
|
||||
export function offMutesEvent<TEvent extends keyof MutesEvents>(
|
||||
pluginData: GuildPluginData<MutesPluginType>,
|
||||
event: TEvent,
|
||||
listener: MutesEvents[TEvent],
|
||||
) {
|
||||
return pluginData.state.events.off(event, listener);
|
||||
}
|
10
backend/src/plugins/Mutes/functions/onMutesEvent.ts
Normal file
10
backend/src/plugins/Mutes/functions/onMutesEvent.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { MutesEvents, MutesPluginType } from "../types";
|
||||
|
||||
export function onMutesEvent<TEvent extends keyof MutesEvents>(
|
||||
pluginData: GuildPluginData<MutesPluginType>,
|
||||
event: TEvent,
|
||||
listener: MutesEvents[TEvent],
|
||||
) {
|
||||
return pluginData.state.events.on(event, listener);
|
||||
}
|
|
@ -45,6 +45,7 @@ export async function unmuteUser(
|
|||
member.edit(memberOptions);
|
||||
}
|
||||
} else {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.warn(
|
||||
`Member ${userId} not found in guild ${pluginData.guild.name} (${pluginData.guild.id}) when attempting to unmute`,
|
||||
);
|
||||
|
@ -95,6 +96,12 @@ export async function unmuteUser(
|
|||
});
|
||||
}
|
||||
|
||||
if (!unmuteTime) {
|
||||
// If the member was unmuted, not just scheduled to be unmuted, fire the unmute event as well
|
||||
// Scheduled unmutes have their event fired in clearExpiredMutes()
|
||||
pluginData.state.events.emit("unmute", user.id, caseArgs.reason);
|
||||
}
|
||||
|
||||
return {
|
||||
case: createdCase,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue