2020-10-01 01:43:38 +03:00
|
|
|
import { modActionsCmd } from "../types";
|
2020-07-24 02:25:33 +02:00
|
|
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
|
|
|
import { canActOn, sendErrorMessage } from "../../../pluginUtils";
|
|
|
|
import { resolveMember, resolveUser } from "../../../utils";
|
|
|
|
import { actualMuteUserCmd } from "../functions/actualMuteUserCmd";
|
|
|
|
|
|
|
|
const opts = {
|
|
|
|
mod: ct.member({ option: true }),
|
|
|
|
notify: ct.string({ option: true }),
|
|
|
|
"notify-channel": ct.textChannel({ option: true }),
|
|
|
|
};
|
|
|
|
|
2020-10-01 01:43:38 +03:00
|
|
|
export const ForcemuteCmd = modActionsCmd({
|
2020-07-24 02:25:33 +02:00
|
|
|
trigger: "forcemute",
|
|
|
|
permission: "can_mute",
|
|
|
|
description: "Force-mute the specified user, even if they're not on the server",
|
|
|
|
|
|
|
|
signature: [
|
|
|
|
{
|
|
|
|
user: ct.string(),
|
|
|
|
time: ct.delay(),
|
|
|
|
reason: ct.string({ required: false, catchAll: true }),
|
|
|
|
|
|
|
|
...opts,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
user: ct.string(),
|
|
|
|
reason: ct.string({ required: false, catchAll: true }),
|
|
|
|
|
|
|
|
...opts,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
async run({ pluginData, message: msg, args }) {
|
|
|
|
const user = await resolveUser(pluginData.client, args.user);
|
2020-12-17 04:12:49 +02:00
|
|
|
if (!user.id) {
|
|
|
|
return sendErrorMessage(pluginData, msg.channel, `User not found`);
|
|
|
|
}
|
2020-07-24 02:25:33 +02:00
|
|
|
|
|
|
|
const memberToMute = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
|
|
|
|
|
|
|
// Make sure we're allowed to mute this user
|
|
|
|
if (memberToMute && !canActOn(pluginData, msg.member, memberToMute)) {
|
|
|
|
sendErrorMessage(pluginData, msg.channel, "Cannot mute: insufficient permissions");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-29 01:04:17 +02:00
|
|
|
actualMuteUserCmd(pluginData, user, msg, { ...args, notify: "none" });
|
2020-07-24 02:25:33 +02:00
|
|
|
},
|
|
|
|
});
|