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 { resolveUser, resolveMember } from "../../../utils";
|
|
|
|
import { actualUnmuteCmd } from "../functions/actualUnmuteUserCmd";
|
|
|
|
|
|
|
|
const opts = {
|
|
|
|
mod: ct.member({ option: true }),
|
|
|
|
};
|
|
|
|
|
2020-10-01 01:43:38 +03:00
|
|
|
export const ForceUnmuteCmd = modActionsCmd({
|
2020-07-24 02:25:33 +02:00
|
|
|
trigger: "forceunmute",
|
|
|
|
permission: "can_mute",
|
|
|
|
description: "Force-unmute 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) {
|
2021-01-17 21:21:18 +02:00
|
|
|
sendErrorMessage(pluginData, msg.channel, `User not found`);
|
|
|
|
return;
|
2020-12-17 04:12:49 +02:00
|
|
|
}
|
2020-07-24 02:25:33 +02:00
|
|
|
|
|
|
|
// Check if they're muted in the first place
|
|
|
|
if (!(await pluginData.state.mutes.isMuted(user.id))) {
|
|
|
|
sendErrorMessage(pluginData, msg.channel, "Cannot unmute: member is not muted");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the server member to unmute
|
|
|
|
const memberToUnmute = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
|
|
|
|
|
|
|
// Make sure we're allowed to unmute this member
|
|
|
|
if (memberToUnmute && !canActOn(pluginData, msg.member, memberToUnmute)) {
|
|
|
|
sendErrorMessage(pluginData, msg.channel, "Cannot unmute: insufficient permissions");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
actualUnmuteCmd(pluginData, user, msg, args);
|
|
|
|
},
|
|
|
|
});
|