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

feat: first batch of emojis 🎉

This commit is contained in:
Lily Bergonzat 2024-02-14 09:17:11 +01:00
parent dfb0e2c19d
commit a4c4b17a14
91 changed files with 3659 additions and 2032 deletions

View file

@ -0,0 +1,112 @@
import { commandTypeHelpers as ct } from "../../../../commandTypes";
import { canActOn, hasPermission, sendErrorMessage } from "../../../../pluginUtils";
import { resolveMember, resolveUser } from "../../../../utils";
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
import { actualUnmuteCmd } from "../../functions/actualCommands/actualUnmuteCmd";
import { isBanned } from "../../functions/isBanned";
import { modActionsMsgCmd } from "../../types";
const opts = {
mod: ct.member({ option: true }),
};
export const UnmuteMsgCmd = modActionsMsgCmd({
trigger: "unmute",
permission: "can_mute",
description: "Unmute the specified member",
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);
if (!user.id) {
sendErrorMessage(pluginData, msg.channel, `User not found`);
return;
}
const memberToUnmute = await resolveMember(pluginData.client, pluginData.guild, user.id);
const mutesPlugin = pluginData.getPlugin(MutesPlugin);
const hasMuteRole = memberToUnmute && mutesPlugin.hasMutedRole(memberToUnmute);
// Check if they're muted in the first place
if (
!(await pluginData.state.mutes.isMuted(user.id)) &&
!hasMuteRole &&
!memberToUnmute?.isCommunicationDisabled()
) {
sendErrorMessage(pluginData, msg.channel, "Cannot unmute: member is not muted");
return;
}
if (!memberToUnmute) {
const banned = await isBanned(pluginData, user.id);
const prefix = pluginData.fullConfig.prefix;
if (banned) {
sendErrorMessage(
pluginData,
msg.channel,
`User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`,
);
return;
} else {
// Ask the mod if we should upgrade to a forceunmute as the user is not on the server
const reply = await waitForButtonConfirm(
msg.channel,
{ content: "User not on server, forceunmute instead?" },
{ confirmText: "Yes", cancelText: "No", restrictToId: msg.member.id },
);
if (!reply) {
sendErrorMessage(pluginData, msg.channel, "User not on server, unmute cancelled by moderator");
return;
}
}
}
// 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;
}
// The moderator who did the action is the message author or, if used, the specified -mod
let mod = msg.member;
let ppId: string | undefined;
if (args.mod) {
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
sendErrorMessage(pluginData, msg.channel, "You don't have permission to use -mod");
return;
}
mod = args.mod;
ppId = msg.author.id;
}
actualUnmuteCmd(
pluginData,
msg.channel,
user,
[...msg.attachments.values()],
mod,
ppId,
"time" in args ? args.time ?? undefined : undefined,
args.reason,
);
},
});