3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-14 05:57:18 +00:00

Bring temporary bans in line with temporary mutes

This commit is contained in:
Dark 2020-12-29 18:01:05 +01:00
parent 87c4baf6b6
commit 3032c51aad
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8

View file

@ -27,7 +27,13 @@ export const BanCmd = modActionsCmd({
signature: [ signature: [
{ {
user: ct.string(), user: ct.string(),
time: ct.delay({ required: false, option: true, shortcut: "d" }), time: ct.delay(),
reason: ct.string({ required: false, catchAll: true }),
...opts,
},
{
user: ct.string(),
reason: ct.string({ required: false, catchAll: true }), reason: ct.string({ required: false, catchAll: true }),
...opts, ...opts,
@ -39,6 +45,8 @@ export const BanCmd = modActionsCmd({
if (!user.id) { if (!user.id) {
return sendErrorMessage(pluginData, msg.channel, `User not found`); return sendErrorMessage(pluginData, msg.channel, `User not found`);
} }
const time = args["time"] ? args["time"] : null;
console.log(time);
const reason = formatReasonWithAttachments(args.reason, msg.attachments); const reason = formatReasonWithAttachments(args.reason, msg.attachments);
const memberToBan = await resolveMember(pluginData.client, pluginData.guild, user.id); const memberToBan = await resolveMember(pluginData.client, pluginData.guild, user.id);
@ -61,7 +69,7 @@ export const BanCmd = modActionsCmd({
if (!memberToBan) { if (!memberToBan) {
if (banned) { if (banned) {
// Abort if trying to ban user indefinitely if they are already banned indefinitely // Abort if trying to ban user indefinitely if they are already banned indefinitely
if (!existingTempban && !args.time) { if (!existingTempban && !time) {
sendErrorMessage(pluginData, msg.channel, `User is already banned indefinitely.`); sendErrorMessage(pluginData, msg.channel, `User is already banned indefinitely.`);
return; return;
} }
@ -77,11 +85,11 @@ export const BanCmd = modActionsCmd({
return; return;
} else { } else {
// Update or add new tempban / remove old tempban // Update or add new tempban / remove old tempban
if (args.time && args.time > 0) { if (time && time > 0) {
if (existingTempban) { if (existingTempban) {
pluginData.state.tempbans.updateExpiryTime(user.id, args.time, mod.id); pluginData.state.tempbans.updateExpiryTime(user.id, time, mod.id);
} else { } else {
pluginData.state.tempbans.addTempban(user.id, args.time, mod.id); pluginData.state.tempbans.addTempban(user.id, time, mod.id);
} }
} else if (existingTempban) { } else if (existingTempban) {
pluginData.state.tempbans.clear(user.id); pluginData.state.tempbans.clear(user.id);
@ -94,21 +102,21 @@ export const BanCmd = modActionsCmd({
type: CaseTypes.Ban, type: CaseTypes.Ban,
userId: user.id, userId: user.id,
reason, reason,
noteDetails: [`Ban updated to ${args.time ? humanizeDuration(args.time) : "indefinite"}`], noteDetails: [`Ban updated to ${time ? humanizeDuration(time) : "indefinite"}`],
}); });
const logtype = args.time ? LogType.MEMBER_TIMED_BAN : LogType.MEMBER_BAN; const logtype = time ? LogType.MEMBER_TIMED_BAN : LogType.MEMBER_BAN;
pluginData.state.serverLogs.log(logtype, { pluginData.state.serverLogs.log(logtype, {
mod: stripObjectToScalars(mod.user), mod: stripObjectToScalars(mod.user),
user: stripObjectToScalars(user), user: stripObjectToScalars(user),
caseNumber: createdCase.case_number, caseNumber: createdCase.case_number,
reason, reason,
banTime: args.time ? humanizeDuration(args.time) : null, banTime: time ? humanizeDuration(time) : null,
}); });
sendSuccessMessage( sendSuccessMessage(
pluginData, pluginData,
msg.channel, msg.channel,
`Ban updated to ${args.time ? "expire in " + humanizeDuration(args.time) + " from now" : "indefinite"}`, `Ban updated to ${time ? "expire in " + humanizeDuration(time) + " from now" : "indefinite"}`,
); );
lock.unlock(); lock.unlock();
return; return;
@ -164,7 +172,7 @@ export const BanCmd = modActionsCmd({
}, },
deleteMessageDays, deleteMessageDays,
}, },
args.time, time,
); );
if (banResult.status === "failed") { if (banResult.status === "failed") {
@ -174,14 +182,14 @@ export const BanCmd = modActionsCmd({
} }
let forTime = ""; let forTime = "";
if (args.time && args.time > 0) { if (time && time > 0) {
if (existingTempban) { if (existingTempban) {
pluginData.state.tempbans.updateExpiryTime(user.id, args.time, mod.id); pluginData.state.tempbans.updateExpiryTime(user.id, time, mod.id);
} else { } else {
pluginData.state.tempbans.addTempban(user.id, args.time, mod.id); pluginData.state.tempbans.addTempban(user.id, time, mod.id);
} }
forTime = `for ${humanizeDuration(args.time)} `; forTime = `for ${humanizeDuration(time)} `;
} }
// Confirm the action to the moderator // Confirm the action to the moderator