mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25: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
|
@ -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,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { GuildAuditLogs, User } from "discord.js";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -65,8 +66,8 @@ export const CreateBanCaseOnManualBanEvt = modActionsEvt({
|
|||
}
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_BAN, {
|
||||
mod: mod ? stripObjectToScalars(mod, ["user"]) : null,
|
||||
user: stripObjectToScalars(user, ["user"]),
|
||||
mod: mod ? userToConfigAccessibleUser(mod) : null,
|
||||
user: userToConfigAccessibleUser(user),
|
||||
caseNumber: createdCase?.case_number ?? 0,
|
||||
reason,
|
||||
});
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { GuildAuditLogs, User } from "discord.js";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
import { resolveUser, stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||
import { resolveUser, UnknownUser } from "../../../utils";
|
||||
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
|
||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
|
||||
|
@ -58,8 +59,8 @@ export const CreateKickCaseOnManualKickEvt = modActionsEvt({
|
|||
}
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_KICK, {
|
||||
user: stripObjectToScalars(member.user),
|
||||
mod: mod ? stripObjectToScalars(mod) : null,
|
||||
user: userToConfigAccessibleUser(member.user!),
|
||||
mod: mod ? userToConfigAccessibleUser(mod) : null,
|
||||
caseNumber: createdCase?.case_number ?? 0,
|
||||
reason: kickAuditLogEntry.reason || "",
|
||||
});
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { GuildAuditLogs, User } from "discord.js";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { resolveUser, stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||
import { resolveUser, UnknownUser } from "../../../utils";
|
||||
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
|
||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
|
||||
|
@ -63,7 +64,7 @@ export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt({
|
|||
}
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_UNBAN, {
|
||||
mod: mod ? stripObjectToScalars(mod, ["user"]) : null,
|
||||
mod: mod ? userToConfigAccessibleUser(mod) : null,
|
||||
userId: user.id,
|
||||
caseNumber: createdCase?.case_number ?? 0,
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildMember, TextChannel } from "discord.js";
|
||||
import { GuildMember, TextChannel, ThreadChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { hasPermission } from "knub/dist/helpers";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -19,7 +19,7 @@ export async function actualKickMemberCmd(
|
|||
reason: string;
|
||||
mod: GuildMember;
|
||||
notify?: string;
|
||||
"notify-channel"?: TextChannel;
|
||||
"notify-channel"?: TextChannel | ThreadChannel;
|
||||
clean?: boolean;
|
||||
},
|
||||
) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildMember, Message, TextChannel, User } from "discord.js";
|
||||
import { GuildMember, Message, TextChannel, ThreadChannel, User } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -19,7 +19,13 @@ export async function actualMuteUserCmd(
|
|||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
user: User | UnknownUser,
|
||||
msg: Message,
|
||||
args: { time?: number; reason?: string; mod: GuildMember; notify?: string; "notify-channel"?: TextChannel },
|
||||
args: {
|
||||
time?: number;
|
||||
reason?: string;
|
||||
mod: GuildMember;
|
||||
notify?: string;
|
||||
"notify-channel"?: TextChannel | ThreadChannel;
|
||||
},
|
||||
) {
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod: GuildMember = msg.member!;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { DiscordAPIError, Snowflake, User } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -129,8 +130,8 @@ export async function banUserId(
|
|||
const mod = await resolveUser(pluginData.client, modId);
|
||||
const logtype = banTime ? LogType.MEMBER_TIMED_BAN : LogType.MEMBER_BAN;
|
||||
pluginData.state.serverLogs.log(logtype, {
|
||||
mod: stripObjectToScalars(mod),
|
||||
user: stripObjectToScalars(user),
|
||||
mod: userToConfigAccessibleUser(mod),
|
||||
user: userToConfigAccessibleUser(user),
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
banTime: banTime ? humanizeDuration(banTime) : null,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { renderTemplate } from "../../../templateFormatter";
|
||||
|
@ -40,7 +41,7 @@ export async function kickMember(
|
|||
guildName: pluginData.guild.name,
|
||||
reason,
|
||||
moderator: kickOptions.caseArgs?.modId
|
||||
? stripObjectToScalars(await resolveUser(pluginData.client, kickOptions.caseArgs.modId))
|
||||
? userToConfigAccessibleUser(await resolveUser(pluginData.client, kickOptions.caseArgs.modId))
|
||||
: {},
|
||||
});
|
||||
|
||||
|
@ -79,8 +80,8 @@ export async function kickMember(
|
|||
// Log the action
|
||||
const mod = await resolveUser(pluginData.client, modId);
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_KICK, {
|
||||
mod: stripObjectToScalars(mod),
|
||||
user: stripObjectToScalars(member.user),
|
||||
mod: userToConfigAccessibleUser(mod),
|
||||
user: userToConfigAccessibleUser(member.user),
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import { GuildPluginData } from "knub";
|
|||
import moment from "moment-timezone";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { logger } from "src/logger";
|
||||
import { userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { resolveUser, SECONDS, stripObjectToScalars } from "../../../utils";
|
||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
|
@ -57,7 +58,7 @@ export async function outdatedTempbansLoop(pluginData: GuildPluginData<ModAction
|
|||
// Log the unban
|
||||
const banTime = moment(tempban.created_at).diff(moment(tempban.expires_at));
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_TIMED_UNBAN, {
|
||||
mod: stripObjectToScalars(await resolveUser(pluginData.client, tempban.mod_id)),
|
||||
mod: userToConfigAccessibleUser(await resolveUser(pluginData.client, tempban.mod_id)),
|
||||
userId: tempban.user_id,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { TextChannel, ThreadChannel } from "discord.js";
|
||||
import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
|
||||
|
||||
export function readContactMethodsFromArgs(args: {
|
||||
notify?: string;
|
||||
"notify-channel"?: TextChannel;
|
||||
"notify-channel"?: TextChannel | ThreadChannel;
|
||||
}): null | UserNotificationMethod[] {
|
||||
if (args.notify) {
|
||||
if (args.notify === "dm") {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { GuildMember, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { memberToConfigAccessibleMember, userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { renderTemplate } from "../../../templateFormatter";
|
||||
|
@ -30,7 +31,7 @@ export async function warnMember(
|
|||
guildName: pluginData.guild.name,
|
||||
reason,
|
||||
moderator: warnOptions.caseArgs?.modId
|
||||
? stripObjectToScalars(await resolveUser(pluginData.client, warnOptions.caseArgs.modId))
|
||||
? userToConfigAccessibleUser(await resolveUser(pluginData.client, warnOptions.caseArgs.modId))
|
||||
: {},
|
||||
});
|
||||
const contactMethods = warnOptions?.contactMethods
|
||||
|
@ -77,8 +78,8 @@ export async function warnMember(
|
|||
|
||||
const mod = await pluginData.guild.members.fetch(modId as Snowflake);
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_WARN, {
|
||||
mod: stripObjectToScalars(mod),
|
||||
member: stripObjectToScalars(member, ["user", "roles"]),
|
||||
mod: memberToConfigAccessibleMember(mod),
|
||||
member: memberToConfigAccessibleMember(member),
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue