mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-08 08:05:03 +00:00
feat: update to djs 14.19.3, node 22, zod 4
This commit is contained in:
parent
595e1a0556
commit
09eb8e92f2
189 changed files with 1244 additions and 900 deletions
|
@ -31,8 +31,10 @@ export const AddCaseMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const member = msg.member || await msg.guild.members.fetch(msg.author.id);
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
let mod = member;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
|
@ -52,7 +54,7 @@ export const AddCaseMsgCmd = modActionsMsgCmd({
|
|||
actualAddCaseCmd(
|
||||
pluginData,
|
||||
msg,
|
||||
msg.member,
|
||||
member,
|
||||
mod,
|
||||
[...msg.attachments.values()],
|
||||
user,
|
||||
|
|
|
@ -41,8 +41,10 @@ export const BanMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const member = msg.member || await msg.guild.members.fetch(msg.author.id);
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
let mod = member;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
|
@ -67,7 +69,7 @@ export const BanMsgCmd = modActionsMsgCmd({
|
|||
args["time"] ? args["time"] : null,
|
||||
args.reason || "",
|
||||
[...msg.attachments.values()],
|
||||
msg.member,
|
||||
member,
|
||||
mod,
|
||||
contactMethods,
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@ export async function actualCaseCmd(
|
|||
}
|
||||
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const embed = await casesPlugin.getCaseEmbed(theCase.id, authorId);
|
||||
const content = await casesPlugin.getCaseEmbed(theCase.id, authorId);
|
||||
|
||||
void sendContextResponse(context, { ...embed, ephemeral: show !== true });
|
||||
void sendContextResponse(context, content, show !== true);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualCasesCmd } from "./actualCasesCmd.js";
|
||||
|
||||
|
@ -29,12 +30,13 @@ export const CasesModMsgCmd = modActionsMsgCmd({
|
|||
],
|
||||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
const member = await resolveMessageMember(msg);
|
||||
return actualCasesCmd(
|
||||
pluginData,
|
||||
msg,
|
||||
args.mod,
|
||||
null,
|
||||
msg.member,
|
||||
member,
|
||||
args.notes,
|
||||
args.warns,
|
||||
args.mutes,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { resolveMember, resolveUser, UnknownUser } from "../../../../utils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualCasesCmd } from "./actualCasesCmd.js";
|
||||
|
@ -40,13 +41,15 @@ export const CasesUserMsgCmd = modActionsMsgCmd({
|
|||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
const member = await resolveMessageMember(msg);
|
||||
|
||||
return actualCasesCmd(
|
||||
pluginData,
|
||||
msg,
|
||||
args.mod,
|
||||
user,
|
||||
msg.member,
|
||||
member,
|
||||
args.notes,
|
||||
args.warns,
|
||||
args.mutes,
|
||||
|
|
|
@ -41,8 +41,8 @@ async function sendExpandedCases(
|
|||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
|
||||
for (const theCase of cases) {
|
||||
const embed = await casesPlugin.getCaseEmbed(theCase.id);
|
||||
await sendContextResponse(context, { ...embed, ephemeral: !show });
|
||||
const content = await casesPlugin.getCaseEmbed(theCase.id);
|
||||
await sendContextResponse(context, content, !show);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { trimLines } from "../../../../utils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualDeleteCaseCmd } from "./actualDeleteCaseCmd.js";
|
||||
|
@ -18,6 +19,7 @@ export const DeleteCaseMsgCmd = modActionsMsgCmd({
|
|||
},
|
||||
|
||||
async run({ pluginData, message, args }) {
|
||||
actualDeleteCaseCmd(pluginData, message, message.member, args.caseNumber, args.force);
|
||||
const member = await resolveMessageMember(message);
|
||||
actualDeleteCaseCmd(pluginData, message, member, args.caseNumber, args.force);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -36,6 +36,11 @@ export async function actualDeleteCaseCmd(
|
|||
|
||||
for (const theCase of validCases) {
|
||||
if (!force) {
|
||||
const channel = await getContextChannel(context);
|
||||
if (!channel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cases = pluginData.getPlugin(CasesPlugin);
|
||||
const embedContent = await cases.getCaseEmbed(theCase);
|
||||
sendContextResponse(context, {
|
||||
|
@ -45,7 +50,7 @@ export async function actualDeleteCaseCmd(
|
|||
|
||||
const reply = await helpers.waitForReply(
|
||||
pluginData.client,
|
||||
await getContextChannel(context),
|
||||
channel,
|
||||
author.id,
|
||||
15 * SECONDS,
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils.js";
|
||||
import { canActOn, hasPermission, resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { resolveMember, resolveUser } from "../../../../utils.js";
|
||||
import { isBanned } from "../../functions/isBanned.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
|
@ -31,8 +31,9 @@ export const ForceBanMsgCmd = modActionsMsgCmd({
|
|||
}
|
||||
|
||||
// If the user exists as a guild member, make sure we can act on them first
|
||||
const member = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||
if (member && !canActOn(pluginData, msg.member, member)) {
|
||||
const authorMember = await resolveMessageMember(msg);
|
||||
const targetMember = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||
if (targetMember && !canActOn(pluginData, authorMember, targetMember)) {
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot forceban this user: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
@ -45,7 +46,7 @@ export const ForceBanMsgCmd = modActionsMsgCmd({
|
|||
}
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
let mod = authorMember;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils.js";
|
||||
import { canActOn, hasPermission, resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { resolveMember, resolveUser } from "../../../../utils.js";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
|
@ -39,16 +39,17 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const authorMember = await resolveMessageMember(msg)
|
||||
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)) {
|
||||
if (memberToMute && !canActOn(pluginData, authorMember, memberToMute)) {
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot mute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
let mod = authorMember;
|
||||
let ppId: string | undefined;
|
||||
|
||||
if (args.mod) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils.js";
|
||||
import { canActOn, hasPermission, resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { resolveMember, resolveUser } from "../../../../utils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualUnmuteCmd } from "../unmute/actualUnmuteCmd.js";
|
||||
|
@ -42,17 +42,17 @@ export const ForceUnmuteMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
// Find the server member to unmute
|
||||
const authorMember = await resolveMessageMember(msg);
|
||||
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)) {
|
||||
if (memberToUnmute && !canActOn(pluginData, authorMember, memberToUnmute)) {
|
||||
pluginData.state.common.sendErrorMessage(msg, "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 mod = authorMember;
|
||||
let ppId: string | undefined;
|
||||
|
||||
if (args.mod) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import { resolveUser } from "../../../../utils.js";
|
|||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualKickCmd } from "./actualKickCmd.js";
|
||||
import { resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -33,8 +34,10 @@ export const KickMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const authorMember = await resolveMessageMember(msg);
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
let mod = authorMember;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(await pluginData.config.getForMessage(msg), "can_act_as_other"))) {
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
|
@ -55,7 +58,7 @@ export const KickMsgCmd = modActionsMsgCmd({
|
|||
actualKickCmd(
|
||||
pluginData,
|
||||
msg,
|
||||
msg.member,
|
||||
authorMember,
|
||||
user,
|
||||
args.reason,
|
||||
[...msg.attachments.values()],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { getContextChannel, resolveMessageMember, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualMassBanCmd } from "./actualMassBanCmd.js";
|
||||
|
||||
|
@ -17,15 +17,16 @@ export const MassBanMsgCmd = modActionsMsgCmd({
|
|||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
// Ask for ban reason (cleaner this way instead of trying to cram it into the args)
|
||||
sendContextResponse(msg, "Ban reason? `cancel` to cancel");
|
||||
const banReasonReply = await waitForReply(pluginData.client, await getContextChannel(msg), msg.author.id);
|
||||
msg.reply("Ban reason? `cancel` to cancel");
|
||||
const banReasonReply = await waitForReply(pluginData.client, msg.channel, msg.author.id);
|
||||
|
||||
if (!banReasonReply || !banReasonReply.content || banReasonReply.content.toLowerCase().trim() === "cancel") {
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
actualMassBanCmd(pluginData, msg, args.userIds, msg.member, banReasonReply.content, [
|
||||
const authorMember = await resolveMessageMember(msg);
|
||||
actualMassBanCmd(pluginData, msg, args.userIds, authorMember, banReasonReply.content, [
|
||||
...banReasonReply.attachments.values(),
|
||||
]);
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@ import { GuildPluginData } from "knub";
|
|||
import { CaseTypes } from "../../../../data/CaseTypes.js";
|
||||
import { LogType } from "../../../../data/LogType.js";
|
||||
import { humanizeDurationShort } from "../../../../humanizeDuration.js";
|
||||
import { canActOn, getContextChannel, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { canActOn, deleteContextResponse, editContextResponse, getConfigForContext, getContextChannel, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { DAYS, MINUTES, SECONDS, noop } from "../../../../utils.js";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin.js";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin.js";
|
||||
|
@ -52,46 +52,31 @@ export async function actualMassBanCmd(
|
|||
pluginData.state.massbanQueue.length === 0
|
||||
? "Banning..."
|
||||
: `Massban queued. Waiting for previous massban to finish (max wait ${maxWaitTimeFormatted}).`;
|
||||
const loadingMsg = await sendContextResponse(context, { content: initialLoadingText, ephemeral: true });
|
||||
const loadingMsg = await sendContextResponse(context, initialLoadingText, true);
|
||||
|
||||
const waitTimeStart = performance.now();
|
||||
const waitingInterval = setInterval(() => {
|
||||
const waitTime = humanizeDurationShort(performance.now() - waitTimeStart, { round: true });
|
||||
const waitMessageContent = `Massban queued. Still waiting for previous massban to finish (waited ${waitTime}).`;
|
||||
|
||||
if (isContextInteraction(context)) {
|
||||
context.editReply(waitMessageContent).catch(() => clearInterval(waitingInterval));
|
||||
} else {
|
||||
loadingMsg.edit(waitMessageContent).catch(() => clearInterval(waitingInterval));
|
||||
}
|
||||
editContextResponse(loadingMsg, waitMessageContent).catch(() => clearInterval(waitingInterval));
|
||||
}, 1 * MINUTES);
|
||||
|
||||
pluginData.state.massbanQueue.add(async () => {
|
||||
clearInterval(waitingInterval);
|
||||
|
||||
if (pluginData.state.unloaded) {
|
||||
if (isContextInteraction(context)) {
|
||||
void context.deleteReply().catch(noop);
|
||||
} else {
|
||||
void loadingMsg.delete().catch(noop);
|
||||
}
|
||||
|
||||
await deleteContextResponse(loadingMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isContextInteraction(context)) {
|
||||
void context.editReply("Banning...").catch(noop);
|
||||
} else {
|
||||
void loadingMsg.edit("Banning...").catch(noop);
|
||||
}
|
||||
editContextResponse(loadingMsg, "Banning...").catch(noop);
|
||||
|
||||
// Ban each user and count failed bans (if any)
|
||||
const startTime = performance.now();
|
||||
const failedBans: string[] = [];
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const messageConfig = isContextInteraction(context)
|
||||
? await pluginData.config.getForInteraction(context)
|
||||
: await pluginData.config.getForChannel(await getContextChannel(context));
|
||||
const messageConfig = await getConfigForContext(pluginData.config, context);
|
||||
const deleteDays = messageConfig.ban_delete_message_days;
|
||||
|
||||
for (const [i, userId] of userIds.entries()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { getContextChannel, resolveMessageMember, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualMassMuteCmd } from "./actualMassMuteCmd.js";
|
||||
|
||||
|
@ -17,8 +17,8 @@ export const MassMuteMsgCmd = modActionsMsgCmd({
|
|||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
// Ask for mute reason
|
||||
sendContextResponse(msg, "Mute reason? `cancel` to cancel");
|
||||
const muteReasonReceived = await waitForReply(pluginData.client, await getContextChannel(msg), msg.author.id);
|
||||
msg.reply("Mute reason? `cancel` to cancel");
|
||||
const muteReasonReceived = await waitForReply(pluginData.client, msg.channel, msg.author.id);
|
||||
if (
|
||||
!muteReasonReceived ||
|
||||
!muteReasonReceived.content ||
|
||||
|
@ -28,7 +28,8 @@ export const MassMuteMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
actualMassMuteCmd(pluginData, msg, args.userIds, msg.member, muteReasonReceived.content, [
|
||||
const member = await resolveMessageMember(msg);
|
||||
actualMassMuteCmd(pluginData, msg, args.userIds, member, muteReasonReceived.content, [
|
||||
...muteReasonReceived.attachments.values(),
|
||||
]);
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Attachment, ChatInputCommandInteraction, GuildMember, Message, Snowflak
|
|||
import { GuildPluginData } from "knub";
|
||||
import { LogType } from "../../../../data/LogType.js";
|
||||
import { logger } from "../../../../logger.js";
|
||||
import { canActOn, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { canActOn, deleteContextResponse, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin.js";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin.js";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction.js";
|
||||
|
@ -11,6 +11,7 @@ import {
|
|||
formatReasonWithMessageLinkForAttachments,
|
||||
} from "../../functions/formatReasonForAttachments.js";
|
||||
import { ModActionsPluginType } from "../../types.js";
|
||||
import { noop } from "../../../../utils.js";
|
||||
|
||||
export async function actualMassMuteCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -50,7 +51,7 @@ export async function actualMassMuteCmd(
|
|||
});
|
||||
|
||||
// Show loading indicator
|
||||
const loadingMsg = await sendContextResponse(context, { content: "Muting...", ephemeral: true });
|
||||
const loadingMsg = await sendContextResponse(context, "Muting...", true);
|
||||
|
||||
// Mute everyone and count fails
|
||||
const modId = author.id;
|
||||
|
@ -71,7 +72,7 @@ export async function actualMassMuteCmd(
|
|||
|
||||
if (!isContextInteraction(context)) {
|
||||
// Clear loading indicator
|
||||
loadingMsg.delete();
|
||||
deleteContextResponse(loadingMsg).catch(noop);
|
||||
}
|
||||
|
||||
const successfulMuteCount = userIds.length - failedMutes.length;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { getContextChannel, resolveMessageMember, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualMassUnbanCmd } from "./actualMassUnbanCmd.js";
|
||||
|
||||
|
@ -17,14 +17,15 @@ export const MassUnbanMsgCmd = modActionsMsgCmd({
|
|||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
// Ask for unban reason (cleaner this way instead of trying to cram it into the args)
|
||||
sendContextResponse(msg, "Unban reason? `cancel` to cancel");
|
||||
const unbanReasonReply = await waitForReply(pluginData.client, await getContextChannel(msg), msg.author.id);
|
||||
msg.reply("Unban reason? `cancel` to cancel");
|
||||
const unbanReasonReply = await waitForReply(pluginData.client, msg.channel, msg.author.id);
|
||||
if (!unbanReasonReply || !unbanReasonReply.content || unbanReasonReply.content.toLowerCase().trim() === "cancel") {
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
actualMassUnbanCmd(pluginData, msg, args.userIds, msg.member, unbanReasonReply.content, [
|
||||
const member = await resolveMessageMember(msg);
|
||||
actualMassUnbanCmd(pluginData, msg, args.userIds, member, unbanReasonReply.content, [
|
||||
...unbanReasonReply.attachments.values(),
|
||||
]);
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Attachment, ChatInputCommandInteraction, GuildMember, Message, Snowflak
|
|||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../../data/CaseTypes.js";
|
||||
import { LogType } from "../../../../data/LogType.js";
|
||||
import { isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { deleteContextResponse, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { MINUTES, noop } from "../../../../utils.js";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin.js";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin.js";
|
||||
|
@ -69,7 +69,7 @@ export async function actualMassUnbanCmd(
|
|||
|
||||
if (!isContextInteraction(context)) {
|
||||
// Clear loading indicator
|
||||
loadingMsg.delete().catch(noop);
|
||||
await deleteContextResponse(loadingMsg).catch(noop);
|
||||
}
|
||||
|
||||
const successfulUnbanCount = userIds.length - failedUnbans.length;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils.js";
|
||||
import { canActOn, hasPermission, resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { resolveMember, resolveUser } from "../../../../utils.js";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction.js";
|
||||
import { isBanned } from "../../functions/isBanned.js";
|
||||
|
@ -41,6 +41,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const authorMember = await resolveMessageMember(msg);
|
||||
const memberToMute = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||
|
||||
if (!memberToMute) {
|
||||
|
@ -57,7 +58,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
const reply = await waitForButtonConfirm(
|
||||
msg,
|
||||
{ content: "User not found on the server, forcemute instead?" },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: msg.member.id },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: authorMember.id },
|
||||
);
|
||||
|
||||
if (!reply) {
|
||||
|
@ -68,13 +69,13 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
}
|
||||
|
||||
// Make sure we're allowed to mute this member
|
||||
if (memberToMute && !canActOn(pluginData, msg.member, memberToMute)) {
|
||||
if (memberToMute && !canActOn(pluginData, authorMember, memberToMute)) {
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot mute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
let mod = authorMember;
|
||||
let ppId: string | undefined;
|
||||
|
||||
if (args.mod) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { hasPermission } from "../../../../pluginUtils.js";
|
||||
import { hasPermission, resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { resolveUser } from "../../../../utils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualUnbanCmd } from "./actualUnbanCmd.js";
|
||||
|
@ -29,8 +29,10 @@ export const UnbanMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const authorMember = await resolveMessageMember(msg);
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
let mod = authorMember;
|
||||
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");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils.js";
|
||||
import { canActOn, hasPermission, resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { resolveMember, resolveUser } from "../../../../utils.js";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction.js";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin.js";
|
||||
|
@ -39,6 +39,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const authorMember = await resolveMessageMember(msg);
|
||||
const memberToUnmute = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||
const mutesPlugin = pluginData.getPlugin(MutesPlugin);
|
||||
const hasMuteRole = memberToUnmute && mutesPlugin.hasMutedRole(memberToUnmute);
|
||||
|
@ -67,7 +68,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
const reply = await waitForButtonConfirm(
|
||||
msg,
|
||||
{ content: "User not on server, forceunmute instead?" },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: msg.member.id },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: authorMember.id },
|
||||
);
|
||||
|
||||
if (!reply) {
|
||||
|
@ -78,13 +79,13 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
}
|
||||
|
||||
// Make sure we're allowed to unmute this member
|
||||
if (memberToUnmute && !canActOn(pluginData, msg.member, memberToUnmute)) {
|
||||
if (memberToUnmute && !canActOn(pluginData, authorMember, memberToUnmute)) {
|
||||
pluginData.state.common.sendErrorMessage(msg, "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 mod = authorMember;
|
||||
let ppId: string | undefined;
|
||||
|
||||
if (args.mod) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils.js";
|
||||
import { canActOn, hasPermission, resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { errorMessage, resolveMember, resolveUser } from "../../../../utils.js";
|
||||
import { isBanned } from "../../functions/isBanned.js";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs.js";
|
||||
|
@ -27,6 +27,7 @@ export const WarnMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const authorMember = await resolveMessageMember(msg);
|
||||
const memberToWarn = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||
|
||||
if (!memberToWarn) {
|
||||
|
@ -41,13 +42,13 @@ export const WarnMsgCmd = modActionsMsgCmd({
|
|||
}
|
||||
|
||||
// Make sure we're allowed to warn this member
|
||||
if (!canActOn(pluginData, msg.member, memberToWarn)) {
|
||||
if (!canActOn(pluginData, authorMember, memberToWarn)) {
|
||||
await pluginData.state.common.sendErrorMessage(msg, "Cannot warn: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
let mod = authorMember;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
msg.channel.send(errorMessage("You don't have permission to use -mod"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue