mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-13 21:35:02 +00:00
More fixes, change rest of stripObjectToScalars to configAccessibleObj
This commit is contained in:
parent
4ad99975de
commit
acb4913495
66 changed files with 623 additions and 192 deletions
backend/src/plugins/ModActions/commands
|
@ -1,10 +1,11 @@
|
|||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
import { canActOn, hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveMember, resolveUser, stripObjectToScalars } from "../../../utils";
|
||||
import { resolveMember, resolveUser } from "../../../utils";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { modActionsCmd } from "../types";
|
||||
|
||||
|
@ -83,7 +84,7 @@ export const AddCaseCmd = modActionsCmd({
|
|||
|
||||
// Log the action
|
||||
pluginData.state.serverLogs.log(LogType.CASE_CREATE, {
|
||||
mod: stripObjectToScalars(mod.user),
|
||||
mod: userToConfigAccessibleUser(mod.user),
|
||||
userId: user.id,
|
||||
caseNum: theCase.case_number,
|
||||
caseType: type.toUpperCase(),
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { User } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { getMemberLevel } from "knub/dist/helpers";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
import { canActOn, hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveMember, resolveUser, stripObjectToScalars } from "../../../utils";
|
||||
import { resolveMember, resolveUser } from "../../../utils";
|
||||
import { banLock } from "../../../utils/lockNameHelpers";
|
||||
import { waitForButtonConfirm } from "../../../utils/waitForInteraction";
|
||||
import { banUserId } from "../functions/banUserId";
|
||||
|
@ -109,8 +111,8 @@ export const BanCmd = modActionsCmd({
|
|||
});
|
||||
const logtype = time ? LogType.MEMBER_TIMED_BAN : LogType.MEMBER_BAN;
|
||||
pluginData.state.serverLogs.log(logtype, {
|
||||
mod: stripObjectToScalars(mod.user),
|
||||
user: stripObjectToScalars(user),
|
||||
mod: userToConfigAccessibleUser(mod.user),
|
||||
user: userToConfigAccessibleUser(user),
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
banTime: time ? humanizeDuration(time) : null,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { helpers } from "knub";
|
||||
import { memberToConfigAccessibleMember } from "src/utils/configAccessibleObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -81,7 +82,7 @@ export const DeleteCaseCmd = modActionsCmd({
|
|||
|
||||
const logs = pluginData.getPlugin(LogsPlugin);
|
||||
logs.log(LogType.CASE_DELETE, {
|
||||
mod: stripObjectToScalars(message.member, ["user", "roles"]),
|
||||
mod: memberToConfigAccessibleMember(message.member),
|
||||
case: stripObjectToScalars(theCase),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
import { canActOn, hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveMember, resolveUser, stripObjectToScalars } from "../../../utils";
|
||||
import { resolveMember, resolveUser } from "../../../utils";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { isBanned } from "../functions/isBanned";
|
||||
|
@ -91,7 +92,7 @@ export const ForcebanCmd = modActionsCmd({
|
|||
|
||||
// Log the action
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_FORCEBAN, {
|
||||
mod: stripObjectToScalars(mod.user),
|
||||
mod: userToConfigAccessibleUser(mod.user),
|
||||
userId: user.id,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { performance } from "perf_hooks";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -80,6 +81,7 @@ export const MassbanCmd = modActionsCmd({
|
|||
const startTime = performance.now();
|
||||
const failedBans: string[] = [];
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const deleteDays = (await pluginData.config.getForMessage(msg)).ban_delete_message_days;
|
||||
for (const [i, userId] of args.userIds.entries()) {
|
||||
if (pluginData.state.unloaded) {
|
||||
break;
|
||||
|
@ -92,7 +94,7 @@ export const MassbanCmd = modActionsCmd({
|
|||
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, userId, 120 * 1000);
|
||||
|
||||
await pluginData.guild.bans.create(userId as Snowflake, {
|
||||
days: 1,
|
||||
days: deleteDays,
|
||||
reason: banReason != null ? encodeURIComponent(banReason) : undefined,
|
||||
});
|
||||
|
||||
|
@ -128,7 +130,7 @@ export const MassbanCmd = modActionsCmd({
|
|||
} else {
|
||||
// Some or all bans were successful. Create a log entry for the mass ban and notify the user.
|
||||
pluginData.state.serverLogs.log(LogType.MASSBAN, {
|
||||
mod: stripObjectToScalars(msg.author),
|
||||
mod: userToConfigAccessibleUser(msg.author),
|
||||
count: successfulBanCount,
|
||||
reason: banReason,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -87,7 +88,7 @@ export const MassunbanCmd = modActionsCmd({
|
|||
} else {
|
||||
// Some or all unbans were successful. Create a log entry for the mass unban and notify the user.
|
||||
pluginData.state.serverLogs.log(LogType.MASSUNBAN, {
|
||||
mod: stripObjectToScalars(msg.author),
|
||||
mod: userToConfigAccessibleUser(msg.author),
|
||||
count: successfulUnbanCount,
|
||||
reason: unbanReason,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -87,7 +88,7 @@ export const MassmuteCmd = modActionsCmd({
|
|||
} else {
|
||||
// Success on all or some mutes
|
||||
pluginData.state.serverLogs.log(LogType.MASSMUTE, {
|
||||
mod: stripObjectToScalars(msg.author),
|
||||
mod: userToConfigAccessibleUser(msg.author),
|
||||
count: successfulMuteCount,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { User } from "discord.js";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, stripObjectToScalars } from "../../../utils";
|
||||
import { resolveUser } from "../../../utils";
|
||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { modActionsCmd } from "../types";
|
||||
|
@ -41,8 +43,8 @@ export const NoteCmd = modActionsCmd({
|
|||
});
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_NOTE, {
|
||||
mod: stripObjectToScalars(msg.author),
|
||||
user: stripObjectToScalars(user, ["user", "roles"]),
|
||||
mod: userToConfigAccessibleUser(msg.author),
|
||||
user: userToConfigAccessibleUser(user),
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
});
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
import { hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, stripObjectToScalars } from "../../../utils";
|
||||
import { resolveUser } from "../../../utils";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { IgnoredEventType, modActionsCmd } from "../types";
|
||||
|
@ -73,7 +74,7 @@ export const UnbanCmd = modActionsCmd({
|
|||
|
||||
// Log the action
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_UNBAN, {
|
||||
mod: stripObjectToScalars(mod.user),
|
||||
mod: userToConfigAccessibleUser(mod.user),
|
||||
userId: user.id,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue