mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Allow automod to issue tempbans (#189)
This commit is contained in:
parent
3d549b4e78
commit
903a2369c8
5 changed files with 36 additions and 15 deletions
|
@ -166,8 +166,8 @@ export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()("mod
|
|||
},
|
||||
|
||||
banUserId(pluginData) {
|
||||
return (userId: string, reason?: string, banOptions?: BanOptions) => {
|
||||
banUserId(pluginData, userId, reason, banOptions);
|
||||
return (userId: string, reason?: string, banOptions?: BanOptions, banTime?: number) => {
|
||||
banUserId(pluginData, userId, reason, banOptions, banTime);
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ export const BanCmd = modActionsCmd({
|
|||
ppId: mod.id !== msg.author.id ? msg.author.id : undefined,
|
||||
},
|
||||
deleteMessageDays,
|
||||
modId: mod.id,
|
||||
},
|
||||
time,
|
||||
);
|
||||
|
@ -184,12 +185,6 @@ export const BanCmd = modActionsCmd({
|
|||
|
||||
let forTime = "";
|
||||
if (time && time > 0) {
|
||||
if (existingTempban) {
|
||||
pluginData.state.tempbans.updateExpiryTime(user.id, time, mod.id);
|
||||
} else {
|
||||
pluginData.state.tempbans.addTempban(user.id, time, mod.id);
|
||||
}
|
||||
|
||||
forTime = `for ${humanizeDuration(time)} `;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,16 @@ export async function banUserId(
|
|||
};
|
||||
}
|
||||
|
||||
const existingTempban = await pluginData.state.tempbans.findExistingTempbanForUserId(user.id);
|
||||
if (banTime && banTime > 0) {
|
||||
const selfId = pluginData.client.user.id;
|
||||
if (existingTempban) {
|
||||
pluginData.state.tempbans.updateExpiryTime(user.id, banTime, banOptions.modId ?? selfId);
|
||||
} else {
|
||||
pluginData.state.tempbans.addTempban(user.id, banTime, banOptions.modId ?? selfId);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a case for this action
|
||||
const modId = banOptions.caseArgs?.modId || pluginData.client.user.id;
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
|
|
|
@ -139,6 +139,7 @@ export interface BanOptions {
|
|||
caseArgs?: Partial<CaseArgs>;
|
||||
contactMethods?: UserNotificationMethod[];
|
||||
deleteMessageDays?: number;
|
||||
modId?: string;
|
||||
isAutomodAction?: boolean;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue