mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-17 07:05:03 +00:00
update
This commit is contained in:
parent
4094cce931
commit
c5235564ec
1 changed files with 8 additions and 7 deletions
|
@ -9,10 +9,9 @@ import {
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
import humanizeDuration from "humanize-duration";
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { canActOn } from "src/pluginUtils";
|
|
||||||
import { ModActionsPlugin } from "src/plugins/ModActions/ModActionsPlugin";
|
import { ModActionsPlugin } from "src/plugins/ModActions/ModActionsPlugin";
|
||||||
import { logger } from "../../../logger";
|
import { logger } from "../../../logger";
|
||||||
import { convertDelayStringToMS, renderUserUsername, resolveMember } from "../../../utils";
|
import { convertDelayStringToMS, renderUserUsername, resolveUser } from "../../../utils";
|
||||||
import { CaseArgs } from "../../Cases/types";
|
import { CaseArgs } from "../../Cases/types";
|
||||||
import { MODAL_TIMEOUT } from "../commands/ModMenuUserCtxCmd";
|
import { MODAL_TIMEOUT } from "../commands/ModMenuUserCtxCmd";
|
||||||
import { ContextMenuPluginType, ModMenuActionType } from "../types";
|
import { ContextMenuPluginType, ModMenuActionType } from "../types";
|
||||||
|
@ -40,10 +39,10 @@ async function banAction(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetMember = await resolveMember(pluginData.client, pluginData.guild, target);
|
const user = await resolveUser(pluginData.client, target);
|
||||||
if (!canActOn(pluginData, executingMember, targetMember)) {
|
if (!user.id) {
|
||||||
await interactionToReply
|
await interactionToReply
|
||||||
.editReply({ content: "Cannot ban: insufficient permissions", embeds: [], components: [] })
|
.editReply({ content: "User not found", embeds: [], components: [] })
|
||||||
.catch((err) => logger.error(`Ban interaction reply failed: ${err}`));
|
.catch((err) => logger.error(`Ban interaction reply failed: ${err}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +52,7 @@ async function banAction(
|
||||||
};
|
};
|
||||||
|
|
||||||
const durationMs = duration ? convertDelayStringToMS(duration)! : undefined;
|
const durationMs = duration ? convertDelayStringToMS(duration)! : undefined;
|
||||||
const result = await modactions.banUserId(targetMember.id, reason, { caseArgs }, durationMs);
|
const result = await modactions.banUserId(user.id, reason, { caseArgs }, durationMs);
|
||||||
if (result.status === "failed") {
|
if (result.status === "failed") {
|
||||||
await interactionToReply
|
await interactionToReply
|
||||||
.editReply({ content: "Error: Failed to ban user", embeds: [], components: [] })
|
.editReply({ content: "Error: Failed to ban user", embeds: [], components: [] })
|
||||||
|
@ -61,7 +60,7 @@ async function banAction(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userName = renderUserUsername(targetMember.user);
|
const userName = renderUserUsername(user);
|
||||||
const messageResultText = result.notifyResult.text ? ` (${result.notifyResult.text})` : "";
|
const messageResultText = result.notifyResult.text ? ` (${result.notifyResult.text})` : "";
|
||||||
const banMessage = `Banned **${userName}** ${
|
const banMessage = `Banned **${userName}** ${
|
||||||
durationMs ? `for ${humanizeDuration(durationMs)}` : "indefinitely"
|
durationMs ? `for ${humanizeDuration(durationMs)}` : "indefinitely"
|
||||||
|
@ -105,6 +104,8 @@ export async function launchBanActionModal(
|
||||||
.catch((err) => logger.error(`Ban interaction defer failed: ${err}`));
|
.catch((err) => logger.error(`Ban interaction defer failed: ${err}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info(`TargeT: ${target}`);
|
||||||
|
|
||||||
const duration = submitted.fields.getTextInputValue("duration");
|
const duration = submitted.fields.getTextInputValue("duration");
|
||||||
const reason = submitted.fields.getTextInputValue("reason");
|
const reason = submitted.fields.getTextInputValue("reason");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue