3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Show how long mutes last in mute message/cmd response

This commit is contained in:
Dragory 2018-07-12 01:38:58 +03:00
parent fcf682a039
commit 22e2dbced1

View file

@ -8,6 +8,7 @@ import {
User User
} from "eris"; } from "eris";
import * as moment from "moment-timezone"; import * as moment from "moment-timezone";
import * as humanizeDuration from "humanize-duration";
import { GuildModActions } from "../data/GuildModActions"; import { GuildModActions } from "../data/GuildModActions";
import { import {
convertDelayStringToMS, convertDelayStringToMS,
@ -284,6 +285,8 @@ export class ModActionsPlugin extends Plugin {
// Convert mute time from e.g. "2h30m" to milliseconds // Convert mute time from e.g. "2h30m" to milliseconds
const muteTime = args.time ? convertDelayStringToMS(args.time) : null; const muteTime = args.time ? convertDelayStringToMS(args.time) : null;
const timeUntilUnmute = muteTime && humanizeDuration(muteTime);
if (muteTime == null && args.time) { if (muteTime == null && args.time) {
// Invalid muteTime -> assume it's actually part of the reason // Invalid muteTime -> assume it's actually part of the reason
args.reason = `${args.time} ${args.reason ? args.reason : ""}`.trim(); args.reason = `${args.time} ${args.reason ? args.reason : ""}`.trim();
@ -303,13 +306,18 @@ export class ModActionsPlugin extends Plugin {
); );
// Message the user informing them of the mute // Message the user informing them of the mute
let messageSent = false; let messageSent = true;
if (args.reason) { if (args.reason) {
const template = muteTime
? this.configValue("timed_mute_message")
: this.configValue("mute_message");
const muteMessage = formatTemplateString( const muteMessage = formatTemplateString(
this.configValue("mute_message"), template,
{ {
guildName: this.guild.name, guildName: this.guild.name,
reason: args.reason reason: args.reason,
time: timeUntilUnmute
} }
); );
@ -324,11 +332,7 @@ export class ModActionsPlugin extends Plugin {
// Confirm the action to the moderator // Confirm the action to the moderator
let response; let response;
if (muteTime) { if (muteTime) {
const unmuteTime = moment() response = `Member muted for ${timeUntilUnmute}`;
.add(muteTime, "ms")
.format("YYYY-MM-DD HH:mm:ss");
response = `Member muted until ${unmuteTime}`;
} else { } else {
response = `Member muted indefinitely`; response = `Member muted indefinitely`;
} }