Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
isContextInteraction,
sendContextResponse,
} from "../../../../pluginUtils.js";
import { DAYS, MINUTES, SECONDS, noop } from "../../../../utils.js";
import { DAYS, MINUTES, SECONDS, noop, resolveMember } from "../../../../utils.js";

Check warning on line 14 in backend/src/plugins/ModActions/commands/massban/actualMassBanCmd.ts

View workflow job for this annotation

GitHub Actions / build

'resolveMember' is defined but never used
import { CasesPlugin } from "../../../Cases/CasesPlugin.js";
import { LogsPlugin } from "../../../Logs/LogsPlugin.js";
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction.js";
Expand Down Expand Up @@ -44,8 +44,15 @@
const banReasonWithAttachments = formatReasonWithAttachments(reason, attachments);

// Verify we can act on each of the users specified
let fetchedMembers: Map<string, GuildMember> | null = null;
try {
fetchedMembers = await pluginData.guild.members.fetch({ user: userIds as Snowflake[] });
} catch {
// If bulk fetch fails, fall back to cache-only checks
}

for (const userId of userIds) {
const member = pluginData.guild.members.cache.get(userId as Snowflake); // TODO: Get members on demand?
const member = fetchedMembers?.get(userId) ?? pluginData.guild.members.cache.get(userId as Snowflake);
if (member && !canActOn(pluginData, author, member)) {
pluginData.state.common.sendErrorMessage(context, "Cannot massban one or more users: insufficient permissions");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { LogType } from "../../../../data/LogType.js";
import { logger } from "../../../../logger.js";
import { canActOn, deleteContextResponse, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
import { noop } from "../../../../utils.js";
import { noop, resolveMember } from "../../../../utils.js";

Check warning on line 6 in backend/src/plugins/ModActions/commands/massmute/actualMassMuteCmd.ts

View workflow job for this annotation

GitHub Actions / build

'resolveMember' is defined but never used
import { LogsPlugin } from "../../../Logs/LogsPlugin.js";
import { MutesPlugin } from "../../../Mutes/MutesPlugin.js";
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction.js";
Expand Down Expand Up @@ -35,8 +35,15 @@
const muteReasonWithAttachments = formatReasonWithAttachments(reason, attachments);

// Verify we can act upon all users
let fetchedMembers: Map<string, GuildMember> | null = null;
try {
fetchedMembers = await pluginData.guild.members.fetch({ user: userIds as Snowflake[] });
} catch {
// If bulk fetch fails, fall back to cache-only checks
}

for (const userId of userIds) {
const member = pluginData.guild.members.cache.get(userId as Snowflake);
const member = fetchedMembers?.get(userId) ?? pluginData.guild.members.cache.get(userId as Snowflake);
if (member && !canActOn(pluginData, author, member)) {
pluginData.state.common.sendErrorMessage(context, "Cannot massmute one or more users: insufficient permissions");
return;
Expand Down
Loading