mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 19:17:19 +00:00
Added Discord attachment link reaction, fixed emoji configuration and moved util functions
This commit is contained in:
parent
a4c4b17a14
commit
592d037148
173 changed files with 1540 additions and 1170 deletions
|
@ -1,46 +1,45 @@
|
|||
import { ChatInputCommandInteraction, GuildMember, Snowflake, TextBasedChannel } from "discord.js";
|
||||
import { ChatInputCommandInteraction, GuildMember, Message, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { waitForReply } from "knub/helpers";
|
||||
import { CaseTypes } from "../../../../data/CaseTypes";
|
||||
import { LogType } from "../../../../data/LogType";
|
||||
import {
|
||||
isContextInteraction,
|
||||
sendContextResponse,
|
||||
sendErrorMessage,
|
||||
sendSuccessMessage,
|
||||
} from "../../../../pluginUtils";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { formatReasonWithAttachments } from "../formatReasonWithAttachments";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../ignoreEvent";
|
||||
import { isBanned } from "../isBanned";
|
||||
|
||||
export async function actualMassUnbanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
context: TextBasedChannel | ChatInputCommandInteraction,
|
||||
context: Message | ChatInputCommandInteraction,
|
||||
userIds: string[],
|
||||
author: GuildMember,
|
||||
) {
|
||||
// Limit to 100 users at once (arbitrary?)
|
||||
if (userIds.length > 100) {
|
||||
sendErrorMessage(pluginData, context, `Can only mass-unban max 100 users at once`);
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `Can only mass-unban max 100 users at once`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ask for unban reason (cleaner this way instead of trying to cram it into the args)
|
||||
sendContextResponse(context, "Unban reason? `cancel` to cancel");
|
||||
const unbanReasonReply = await waitForReply(
|
||||
pluginData.client,
|
||||
isContextInteraction(context) ? context.channel! : context,
|
||||
author.id,
|
||||
);
|
||||
const unbanReasonReply = await waitForReply(pluginData.client, await getContextChannel(context), author.id);
|
||||
if (!unbanReasonReply || !unbanReasonReply.content || unbanReasonReply.content.toLowerCase().trim() === "cancel") {
|
||||
sendErrorMessage(pluginData, context, "Cancelled");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
const unbanReason = formatReasonWithAttachments(unbanReasonReply.content, [...unbanReasonReply.attachments.values()]);
|
||||
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, unbanReasonReply.content)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unbanReason = await formatReasonWithMessageLinkForAttachments(pluginData, unbanReasonReply.content, context, [
|
||||
...unbanReasonReply.attachments.values(),
|
||||
]);
|
||||
|
||||
// Ignore automatic unban cases and logs for these users
|
||||
// We'll create our own cases below and post a single "mass unbanned" log instead
|
||||
|
@ -83,7 +82,9 @@ export async function actualMassUnbanCmd(
|
|||
const successfulUnbanCount = userIds.length - failedUnbans.length;
|
||||
if (successfulUnbanCount === 0) {
|
||||
// All unbans failed - don't create a log entry and notify the user
|
||||
sendErrorMessage(pluginData, context, "All unbans failed. Make sure the IDs are valid and banned.");
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(context, "All unbans failed. Make sure the IDs are valid and banned.");
|
||||
} else {
|
||||
// Some or all unbans were successful. Create a log entry for the mass unban and notify the user.
|
||||
pluginData.getPlugin(LogsPlugin).logMassUnban({
|
||||
|
@ -110,13 +111,16 @@ export async function actualMassUnbanCmd(
|
|||
});
|
||||
}
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
context,
|
||||
`Unbanned ${successfulUnbanCount} users, ${failedUnbans.length} failed:\n${failedMsg}`,
|
||||
);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
context,
|
||||
`Unbanned ${successfulUnbanCount} users, ${failedUnbans.length} failed:\n${failedMsg}`,
|
||||
);
|
||||
} else {
|
||||
sendSuccessMessage(pluginData, context, `Unbanned ${successfulUnbanCount} users successfully`);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(context, `Unbanned ${successfulUnbanCount} users successfully`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue