Allow mute and unmute to be upgraded to their force variant (#174)

This commit is contained in:
Nils 2021-04-02 15:53:09 +02:00 committed by GitHub
parent c4a8c3014e
commit 56ade239dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 16 deletions

View file

@ -6,7 +6,7 @@ import { formatReasonWithAttachments } from "../functions/formatReasonWithAttach
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { LogType } from "../../../data/LogType";
import { CaseTypes } from "../../../data/CaseTypes";
import { errorMessage, resolveMember, resolveUser, stripObjectToScalars } from "../../../utils";
import { errorMessage, noop, resolveMember, resolveUser, stripObjectToScalars } from "../../../utils";
import { isBanned } from "../functions/isBanned";
import { waitForReaction } from "knub/dist/helpers";
import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromArgs";
@ -59,15 +59,18 @@ export const MuteCmd = modActionsCmd({
msg.channel,
`User is banned. Use \`${prefix}forcemute\` if you want to mute them anyway.`,
);
return;
} else {
sendErrorMessage(
pluginData,
msg.channel,
`User is not on the server. Use \`${prefix}forcemute\` if you want to mute them anyway.`,
);
}
// Ask the mod if we should upgrade to a forcemute as the user is not on the server
const notOnServerMsg = await msg.channel.createMessage("User not found on the server, forcemute instead?");
const reply = await waitForReaction(pluginData.client, notOnServerMsg, ["✅", "❌"], msg.author.id);
return;
notOnServerMsg.delete().catch(noop);
if (!reply || reply.name === "❌") {
sendErrorMessage(pluginData, msg.channel, "User not on server, mute cancelled by moderator");
return;
}
}
}
// Make sure we're allowed to mute this member

View file

@ -1,10 +1,11 @@
import { modActionsCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { canActOn, sendErrorMessage } from "../../../pluginUtils";
import { resolveUser, resolveMember } from "../../../utils";
import { resolveUser, resolveMember, noop } from "../../../utils";
import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin";
import { actualUnmuteCmd } from "../functions/actualUnmuteUserCmd";
import { isBanned } from "../functions/isBanned";
import { waitForReaction } from "knub/dist/helpers";
const opts = {
mod: ct.member({ option: true }),
@ -57,15 +58,18 @@ export const UnmuteCmd = modActionsCmd({
msg.channel,
`User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`,
);
return;
} else {
sendErrorMessage(
pluginData,
msg.channel,
`User is not on the server. Use \`${prefix}forceunmute\` to unmute them anyway.`,
);
}
// Ask the mod if we should upgrade to a forceunmute as the user is not on the server
const notOnServerMsg = await msg.channel.createMessage("User not found on the server, forceunmute instead?");
const reply = await waitForReaction(pluginData.client, notOnServerMsg, ["✅", "❌"], msg.author.id);
return;
notOnServerMsg.delete().catch(noop);
if (!reply || reply.name === "❌") {
sendErrorMessage(pluginData, msg.channel, "User not on server, unmute cancelled by moderator");
return;
}
}
}
// Make sure we're allowed to unmute this member