3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-14 13:55:03 +00:00

feat(ContextMenus): add new field to modals for case evidence

This commit is contained in:
Obliie 2023-07-16 19:48:53 +01:00
parent 26bf9363f9
commit 6689f91a6a
No known key found for this signature in database
GPG key ID: 9189A18F0D5B547E
4 changed files with 73 additions and 6 deletions

View file

@ -19,11 +19,13 @@ import { LogsPlugin } from "../../Logs/LogsPlugin";
import { MutesPlugin } from "../../Mutes/MutesPlugin";
import { MODAL_TIMEOUT } from "../commands/ModMenuUserCtxCmd";
import { ContextMenuPluginType, ModMenuActionType } from "../types";
import { updateAction } from "./update";
async function muteAction(
pluginData: GuildPluginData<ContextMenuPluginType>,
duration: string | undefined,
reason: string | undefined,
evidence: string | undefined,
target: string,
interaction: ButtonInteraction | ContextMenuCommandInteraction,
submitInteraction: ModalSubmitInteraction,
@ -73,6 +75,10 @@ async function muteAction(
durationMs ? `for ${humanizeDuration(durationMs)}` : "indefinitely"
} (Case #${result.case.case_number})${messageResultText}`;
if (evidence) {
await updateAction(pluginData, executingMember, result.case, evidence);
}
await interactionToReply
.editReply({ content: muteMessage, embeds: [], components: [] })
.catch((err) => logger.error(`Mute interaction reply failed: ${err}`));
@ -112,9 +118,15 @@ export async function launchMuteActionModal(
.setLabel("Reason (Optional)")
.setRequired(false)
.setStyle(TextInputStyle.Paragraph);
const evidenceIn = new TextInputBuilder()
.setCustomId("evidence")
.setLabel("Evidence (Optional)")
.setRequired(false)
.setStyle(TextInputStyle.Paragraph);
const durationRow = new ActionRowBuilder<TextInputBuilder>().addComponents(durationIn);
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
modal.addComponents(durationRow, reasonRow);
const evidenceRow = new ActionRowBuilder<TextInputBuilder>().addComponents(evidenceIn);
modal.addComponents(durationRow, reasonRow, evidenceRow);
await interaction.showModal(modal);
await interaction
@ -130,8 +142,9 @@ export async function launchMuteActionModal(
const duration = submitted.fields.getTextInputValue("duration");
const reason = submitted.fields.getTextInputValue("reason");
const evidence = submitted.fields.getTextInputValue("evidence");
await muteAction(pluginData, duration, reason, target, interaction, submitted);
await muteAction(pluginData, duration, reason, evidence, target, interaction, submitted);
})
.catch((err) => logger.error(`Mute modal interaction failed: ${err}`));
}