mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
Add option for default duration of mutes
This commit is contained in:
parent
459020eab7
commit
75e6687064
4 changed files with 16 additions and 7 deletions
|
@ -36,7 +36,6 @@ export async function actualMuteUserCmd(
|
||||||
pp = msg.author;
|
pp = msg.author;
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeUntilUnmute = args.time && humanizeDuration(args.time);
|
|
||||||
const reason = args.reason ? formatReasonWithAttachments(args.reason, msg.attachments) : undefined;
|
const reason = args.reason ? formatReasonWithAttachments(args.reason, msg.attachments) : undefined;
|
||||||
|
|
||||||
let muteResult: MuteResult;
|
let muteResult: MuteResult;
|
||||||
|
@ -77,16 +76,16 @@ export async function actualMuteUserCmd(
|
||||||
|
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
let response;
|
let response;
|
||||||
if (args.time) {
|
if (muteResult.timeUntilUnmute) {
|
||||||
if (muteResult.updatedExistingMute) {
|
if (muteResult.updatedExistingMute) {
|
||||||
response = asSingleLine(`
|
response = asSingleLine(`
|
||||||
Updated **${user.username}#${user.discriminator}**'s
|
Updated **${user.username}#${user.discriminator}**'s
|
||||||
mute to ${timeUntilUnmute} (Case #${muteResult.case.case_number})
|
mute to ${muteResult.timeUntilUnmute} (Case #${muteResult.case.case_number})
|
||||||
`);
|
`);
|
||||||
} else {
|
} else {
|
||||||
response = asSingleLine(`
|
response = asSingleLine(`
|
||||||
Muted **${user.username}#${user.discriminator}**
|
Muted **${user.username}#${user.discriminator}**
|
||||||
for ${timeUntilUnmute} (Case #${muteResult.case.case_number})
|
for ${muteResult.timeUntilUnmute} (Case #${muteResult.case.case_number})
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,6 +26,7 @@ const defaultOptions = {
|
||||||
mute_role: null,
|
mute_role: null,
|
||||||
move_to_voice_channel: null,
|
move_to_voice_channel: null,
|
||||||
kick_from_voice_channel: false,
|
kick_from_voice_channel: false,
|
||||||
|
default_duration: null,
|
||||||
|
|
||||||
dm_on_mute: false,
|
dm_on_mute: false,
|
||||||
dm_on_update: false,
|
dm_on_update: false,
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
UserNotificationResult,
|
UserNotificationResult,
|
||||||
resolveMember,
|
resolveMember,
|
||||||
UserNotificationMethod,
|
UserNotificationMethod,
|
||||||
|
convertDelayStringToMS,
|
||||||
} from "../../../utils";
|
} from "../../../utils";
|
||||||
import { renderTemplate } from "../../../templateFormatter";
|
import { renderTemplate } from "../../../templateFormatter";
|
||||||
import { MemberOptions, TextChannel, User } from "eris";
|
import { MemberOptions, TextChannel, User } from "eris";
|
||||||
|
@ -37,8 +38,6 @@ export async function muteUser(
|
||||||
throw new RecoverablePluginError(ERRORS.NO_MUTE_ROLE_IN_CONFIG);
|
throw new RecoverablePluginError(ERRORS.NO_MUTE_ROLE_IN_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeUntilUnmute = muteTime ? humanizeDuration(muteTime) : "indefinite";
|
|
||||||
|
|
||||||
// No mod specified -> mark Zeppelin as the mod
|
// No mod specified -> mark Zeppelin as the mod
|
||||||
if (!muteOptions.caseArgs?.modId) {
|
if (!muteOptions.caseArgs?.modId) {
|
||||||
muteOptions.caseArgs = muteOptions.caseArgs ?? {};
|
muteOptions.caseArgs = muteOptions.caseArgs ?? {};
|
||||||
|
@ -54,6 +53,13 @@ export async function muteUser(
|
||||||
const member = await resolveMember(pluginData.client, pluginData.guild, user.id, true); // Grab the fresh member so we don't have stale role info
|
const member = await resolveMember(pluginData.client, pluginData.guild, user.id, true); // Grab the fresh member so we don't have stale role info
|
||||||
const config = pluginData.config.getMatchingConfig({ member, userId });
|
const config = pluginData.config.getMatchingConfig({ member, userId });
|
||||||
|
|
||||||
|
muteTime = muteTime !== undefined
|
||||||
|
? muteTime
|
||||||
|
: config.default_duration
|
||||||
|
? convertDelayStringToMS(config.default_duration)!
|
||||||
|
: undefined;
|
||||||
|
const timeUntilUnmute = muteTime ? humanizeDuration(muteTime) : "indefinite";
|
||||||
|
|
||||||
let rolesToRestore: string[] = [];
|
let rolesToRestore: string[] = [];
|
||||||
if (member) {
|
if (member) {
|
||||||
const logs = pluginData.getPlugin(LogsPlugin);
|
const logs = pluginData.getPlugin(LogsPlugin);
|
||||||
|
@ -245,6 +251,7 @@ export async function muteUser(
|
||||||
|
|
||||||
return {
|
return {
|
||||||
case: theCase,
|
case: theCase,
|
||||||
|
timeUntilUnmute: timeUntilUnmute,
|
||||||
notifyResult,
|
notifyResult,
|
||||||
updatedExistingMute: !!existingMute,
|
updatedExistingMute: !!existingMute,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { tNullable, UserNotificationMethod, UserNotificationResult } from "../../utils";
|
import { tDelayString, tNullable, UserNotificationMethod, UserNotificationResult } from "../../utils";
|
||||||
import { Mute } from "../../data/entities/Mute";
|
import { Mute } from "../../data/entities/Mute";
|
||||||
import { Member } from "eris";
|
import { Member } from "eris";
|
||||||
import { Case } from "../../data/entities/Case";
|
import { Case } from "../../data/entities/Case";
|
||||||
|
@ -16,6 +16,7 @@ export const ConfigSchema = t.type({
|
||||||
mute_role: tNullable(t.string),
|
mute_role: tNullable(t.string),
|
||||||
move_to_voice_channel: tNullable(t.string),
|
move_to_voice_channel: tNullable(t.string),
|
||||||
kick_from_voice_channel: t.boolean,
|
kick_from_voice_channel: t.boolean,
|
||||||
|
default_duration: tNullable(tDelayString),
|
||||||
|
|
||||||
dm_on_mute: t.boolean,
|
dm_on_mute: t.boolean,
|
||||||
dm_on_update: t.boolean,
|
dm_on_update: t.boolean,
|
||||||
|
@ -64,6 +65,7 @@ export interface IMuteWithDetails extends Mute {
|
||||||
|
|
||||||
export type MuteResult = {
|
export type MuteResult = {
|
||||||
case: Case;
|
case: Case;
|
||||||
|
timeUntilUnmute: string;
|
||||||
notifyResult: UserNotificationResult;
|
notifyResult: UserNotificationResult;
|
||||||
updatedExistingMute: boolean;
|
updatedExistingMute: boolean;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue