3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-08 00:05:01 +00:00
zeppelin/backend/src/plugins/ModActions/commands/unban/UnbanMsgCmd.ts
Dragory 45e3fe2ef0
chore: esm imports
This will make merging this into 'next' much easier.
2024-08-11 21:58:52 +03:00

45 lines
1.3 KiB
TypeScript

import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
import { hasPermission } from "../../../../pluginUtils.js";
import { resolveUser } from "../../../../utils.js";
import { modActionsMsgCmd } from "../../types.js";
import { actualUnbanCmd } from "./actualUnbanCmd.js";
const opts = {
mod: ct.member({ option: true }),
};
export const UnbanMsgCmd = modActionsMsgCmd({
trigger: "unban",
permission: "can_unban",
description: "Unban the specified member",
signature: [
{
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);
if (!user.id) {
pluginData.state.common.sendErrorMessage(msg, `User not found`);
return;
}
// The moderator who did the action is the message author or, if used, the specified -mod
let mod = msg.member;
if (args.mod) {
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg, channelId: msg.channel.id }))) {
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
return;
}
mod = args.mod;
}
actualUnbanCmd(pluginData, msg, msg.author.id, user, args.reason, [...msg.attachments.values()], mod);
},
});