mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 05:45:02 +00:00
feat: Context menu mod menu command
This commit is contained in:
parent
5a4e50b19d
commit
771ed76f64
17 changed files with 818 additions and 204 deletions
97
backend/src/plugins/ContextMenus/actions/ban.ts
Normal file
97
backend/src/plugins/ContextMenus/actions/ban.ts
Normal file
|
@ -0,0 +1,97 @@
|
|||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonInteraction,
|
||||
ModalBuilder,
|
||||
ModalSubmitInteraction,
|
||||
TextInputBuilder,
|
||||
TextInputStyle,
|
||||
} from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { canActOn } from "src/pluginUtils";
|
||||
import { ModActionsPlugin } from "src/plugins/ModActions/ModActionsPlugin";
|
||||
import { convertDelayStringToMS, renderUserUsername } from "../../../utils";
|
||||
import { CaseArgs } from "../../Cases/types";
|
||||
import { MODAL_TIMEOUT } from "../commands/ModMenuCmd";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
|
||||
async function banAction(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
duration: string | undefined,
|
||||
reason: string | undefined,
|
||||
target: string,
|
||||
interaction: ButtonInteraction,
|
||||
) {
|
||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||
const userCfg = await pluginData.config.getMatchingConfig({
|
||||
channelId: interaction.channelId,
|
||||
member: executingMember,
|
||||
});
|
||||
|
||||
const modactions = pluginData.getPlugin(ModActionsPlugin);
|
||||
if (!userCfg.can_use || !(await modactions.hasBanPermission(executingMember, interaction.channelId))) {
|
||||
await interaction.editReply({ content: "Cannot ban: insufficient permissions", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const targetMember = await pluginData.guild.members.fetch(target);
|
||||
if (!canActOn(pluginData, executingMember, targetMember)) {
|
||||
await interaction.editReply({ content: "Cannot ban: insufficient permissions", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const caseArgs: Partial<CaseArgs> = {
|
||||
modId: executingMember.id,
|
||||
};
|
||||
|
||||
const durationMs = duration ? convertDelayStringToMS(duration)! : undefined;
|
||||
const result = await modactions.banUserId(target, reason, { caseArgs }, durationMs);
|
||||
if (result.status === "failed") {
|
||||
await interaction.editReply({ content: "ERROR: Failed to ban user", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const userName = renderUserUsername(targetMember.user);
|
||||
const messageResultText = result.notifyResult.text ? ` (${result.notifyResult.text})` : "";
|
||||
const banMessage = `Banned **${userName}** ${
|
||||
durationMs ? `for ${humanizeDuration(durationMs)}` : "indefinitely"
|
||||
} (Case #${result.case.case_number})${messageResultText}`;
|
||||
|
||||
await interaction.editReply({ content: banMessage, embeds: [], components: [] });
|
||||
}
|
||||
|
||||
export async function launchBanActionModal(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
interaction: ButtonInteraction,
|
||||
target: string,
|
||||
) {
|
||||
const modal = new ModalBuilder().setCustomId("ban").setTitle("Ban");
|
||||
|
||||
const durationIn = new TextInputBuilder()
|
||||
.setCustomId("duration")
|
||||
.setLabel("Duration (Optional)")
|
||||
.setRequired(false)
|
||||
.setStyle(TextInputStyle.Short);
|
||||
|
||||
const reasonIn = new TextInputBuilder()
|
||||
.setCustomId("reason")
|
||||
.setLabel("Reason (Optional)")
|
||||
.setRequired(false)
|
||||
.setStyle(TextInputStyle.Paragraph);
|
||||
|
||||
const durationRow = new ActionRowBuilder<TextInputBuilder>().addComponents(durationIn);
|
||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||
|
||||
modal.addComponents(durationRow, reasonRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
const submitted: ModalSubmitInteraction = await interaction.awaitModalSubmit({ time: MODAL_TIMEOUT });
|
||||
if (submitted) {
|
||||
await submitted.deferUpdate();
|
||||
|
||||
const duration = submitted.fields.getTextInputValue("duration");
|
||||
const reason = submitted.fields.getTextInputValue("reason");
|
||||
|
||||
await banAction(pluginData, duration, reason, target, interaction);
|
||||
}
|
||||
}
|
|
@ -1,16 +1,22 @@
|
|||
import { ContextMenuCommandInteraction, TextChannel } from "discord.js";
|
||||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonInteraction,
|
||||
ModalBuilder,
|
||||
ModalSubmitInteraction,
|
||||
TextInputBuilder,
|
||||
TextInputStyle,
|
||||
} from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
|
||||
import { UtilityPlugin } from "../../../plugins/Utility/UtilityPlugin";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { MODAL_TIMEOUT } from "../commands/ModMenuCmd";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
|
||||
export async function cleanAction(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
amount: number,
|
||||
interaction: ContextMenuCommandInteraction,
|
||||
target: string,
|
||||
interaction: ButtonInteraction,
|
||||
) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||
const userCfg = await pluginData.config.getMatchingConfig({
|
||||
channelId: interaction.channelId,
|
||||
|
@ -19,32 +25,42 @@ export async function cleanAction(
|
|||
const utility = pluginData.getPlugin(UtilityPlugin);
|
||||
|
||||
if (!userCfg.can_use || !(await utility.hasPermission(executingMember, interaction.channelId, "can_clean"))) {
|
||||
await interaction.followUp({ content: "Cannot clean: insufficient permissions" });
|
||||
await interaction.editReply({ content: "Cannot clean: insufficient permissions", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const targetMessage = interaction.channel
|
||||
? await interaction.channel.messages.fetch(interaction.targetId)
|
||||
: await (pluginData.guild.channels.resolve(interaction.channelId) as TextChannel).messages.fetch(
|
||||
interaction.targetId,
|
||||
);
|
||||
// TODO: Implement message cleaning
|
||||
await interaction.editReply({
|
||||
content: `TODO: Implementation incomplete`,
|
||||
embeds: [],
|
||||
components: [],
|
||||
});
|
||||
}
|
||||
|
||||
const targetUserOnly = false;
|
||||
const deletePins = false;
|
||||
const user = undefined;
|
||||
export async function launchCleanActionModal(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
interaction: ButtonInteraction,
|
||||
target: string,
|
||||
) {
|
||||
const modal = new ModalBuilder().setCustomId("clean").setTitle("Clean");
|
||||
|
||||
try {
|
||||
await interaction.followUp(`Cleaning... Amount: ${amount}, User Only: ${targetUserOnly}, Pins: ${deletePins}`);
|
||||
utility.clean({ count: amount, user, channel: targetMessage.channel.id, "delete-pins": deletePins }, targetMessage);
|
||||
} catch (e) {
|
||||
await interaction.followUp({ ephemeral: true, content: "Plugin error, please check your BOT_ALERTs" });
|
||||
const amountIn = new TextInputBuilder().setCustomId("amount").setLabel("Amount").setStyle(TextInputStyle.Short);
|
||||
|
||||
if (e instanceof RecoverablePluginError && e.code === ERRORS.NO_MUTE_ROLE_IN_CONFIG) {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Failed to clean in <#${interaction.channelId}> in ContextMenu action \`clean\`:_ ${e}`,
|
||||
});
|
||||
} else {
|
||||
throw e;
|
||||
const amountRow = new ActionRowBuilder<TextInputBuilder>().addComponents(amountIn);
|
||||
|
||||
modal.addComponents(amountRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
const submitted: ModalSubmitInteraction = await interaction.awaitModalSubmit({ time: MODAL_TIMEOUT });
|
||||
if (submitted) {
|
||||
await submitted.deferUpdate();
|
||||
|
||||
const amount = submitted.fields.getTextInputValue("amount");
|
||||
if (isNaN(Number(amount))) {
|
||||
interaction.editReply({ content: `ERROR: Amount ${amount} is invalid`, embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
await cleanAction(pluginData, Number(amount), target, interaction);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
import { ContextMenuCommandInteraction } from "discord.js";
|
||||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonInteraction,
|
||||
ModalBuilder,
|
||||
ModalSubmitInteraction,
|
||||
TextInputBuilder,
|
||||
TextInputStyle,
|
||||
} from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { canActOn } from "src/pluginUtils";
|
||||
|
@ -8,14 +15,16 @@ import { convertDelayStringToMS } from "../../../utils";
|
|||
import { CaseArgs } from "../../Cases/types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { MutesPlugin } from "../../Mutes/MutesPlugin";
|
||||
import { MODAL_TIMEOUT } from "../commands/ModMenuCmd";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
|
||||
export async function muteAction(
|
||||
async function muteAction(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
duration: string | undefined,
|
||||
interaction: ContextMenuCommandInteraction,
|
||||
reason: string | undefined,
|
||||
target: string,
|
||||
interaction: ButtonInteraction,
|
||||
) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||
const userCfg = await pluginData.config.getMatchingConfig({
|
||||
channelId: interaction.channelId,
|
||||
|
@ -24,43 +33,76 @@ export async function muteAction(
|
|||
|
||||
const modactions = pluginData.getPlugin(ModActionsPlugin);
|
||||
if (!userCfg.can_use || !(await modactions.hasMutePermission(executingMember, interaction.channelId))) {
|
||||
await interaction.followUp({ content: "Cannot mute: insufficient permissions" });
|
||||
await interaction.editReply({ content: "Cannot mute: insufficient permissions", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const durationMs = duration ? convertDelayStringToMS(duration)! : undefined;
|
||||
const mutes = pluginData.getPlugin(MutesPlugin);
|
||||
const userId = interaction.targetId;
|
||||
const targetMember = await pluginData.guild.members.fetch(interaction.targetId);
|
||||
|
||||
const targetMember = await pluginData.guild.members.fetch(target);
|
||||
if (!canActOn(pluginData, executingMember, targetMember)) {
|
||||
await interaction.followUp({ ephemeral: true, content: "Cannot mute: insufficient permissions" });
|
||||
await interaction.editReply({ content: "Cannot mute: insufficient permissions", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const caseArgs: Partial<CaseArgs> = {
|
||||
modId: executingMember.id,
|
||||
};
|
||||
const mutes = pluginData.getPlugin(MutesPlugin);
|
||||
const durationMs = duration ? convertDelayStringToMS(duration)! : undefined;
|
||||
|
||||
try {
|
||||
const result = await mutes.muteUser(userId, durationMs, "Context Menu Action", { caseArgs });
|
||||
const result = await mutes.muteUser(target, durationMs, reason, { caseArgs });
|
||||
|
||||
const messageResultText = result.notifyResult.text ? ` (${result.notifyResult.text})` : "";
|
||||
const muteMessage = `Muted **${result.case.user_name}** ${
|
||||
durationMs ? `for ${humanizeDuration(durationMs)}` : "indefinitely"
|
||||
} (Case #${result.case.case_number}) (user notified via ${
|
||||
result.notifyResult.method ?? "dm"
|
||||
})\nPlease update the new case with the \`update\` command`;
|
||||
} (Case #${result.case.case_number})${messageResultText}`;
|
||||
|
||||
await interaction.followUp({ ephemeral: true, content: muteMessage });
|
||||
await interaction.editReply({ content: muteMessage, embeds: [], components: [] });
|
||||
} catch (e) {
|
||||
await interaction.followUp({ ephemeral: true, content: "Plugin error, please check your BOT_ALERTs" });
|
||||
await interaction.editReply({ content: "Plugin error, please check your BOT_ALERTs", embeds: [], components: [] });
|
||||
|
||||
if (e instanceof RecoverablePluginError && e.code === ERRORS.NO_MUTE_ROLE_IN_CONFIG) {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Failed to mute <@!${userId}> in ContextMenu action \`mute\` because a mute role has not been specified in server config`,
|
||||
body: `Failed to mute <@!${target}> in ContextMenu action \`mute\` because a mute role has not been specified in server config`,
|
||||
});
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function launchMuteActionModal(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
interaction: ButtonInteraction,
|
||||
target: string,
|
||||
) {
|
||||
const modal = new ModalBuilder().setCustomId("mute").setTitle("Mute");
|
||||
|
||||
const durationIn = new TextInputBuilder()
|
||||
.setCustomId("duration")
|
||||
.setLabel("Duration (Optional)")
|
||||
.setRequired(false)
|
||||
.setStyle(TextInputStyle.Short);
|
||||
|
||||
const reasonIn = new TextInputBuilder()
|
||||
.setCustomId("reason")
|
||||
.setLabel("Reason (Optional)")
|
||||
.setRequired(false)
|
||||
.setStyle(TextInputStyle.Paragraph);
|
||||
|
||||
const durationRow = new ActionRowBuilder<TextInputBuilder>().addComponents(durationIn);
|
||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||
|
||||
modal.addComponents(durationRow, reasonRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
const submitted: ModalSubmitInteraction = await interaction.awaitModalSubmit({ time: MODAL_TIMEOUT });
|
||||
if (submitted) {
|
||||
await submitted.deferUpdate();
|
||||
|
||||
const duration = submitted.fields.getTextInputValue("duration");
|
||||
const reason = submitted.fields.getTextInputValue("reason");
|
||||
|
||||
await muteAction(pluginData, duration, reason, target, interaction);
|
||||
}
|
||||
}
|
||||
|
|
88
backend/src/plugins/ContextMenus/actions/note.ts
Normal file
88
backend/src/plugins/ContextMenus/actions/note.ts
Normal file
|
@ -0,0 +1,88 @@
|
|||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonInteraction,
|
||||
ModalBuilder,
|
||||
ModalSubmitInteraction,
|
||||
TextInputBuilder,
|
||||
TextInputStyle,
|
||||
} from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { canActOn } from "src/pluginUtils";
|
||||
import { ModActionsPlugin } from "src/plugins/ModActions/ModActionsPlugin";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
import { renderUserUsername } from "../../../utils";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { MODAL_TIMEOUT } from "../commands/ModMenuCmd";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
|
||||
async function noteAction(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
reason: string,
|
||||
target: string,
|
||||
interaction: ButtonInteraction,
|
||||
) {
|
||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||
const userCfg = await pluginData.config.getMatchingConfig({
|
||||
channelId: interaction.channelId,
|
||||
member: executingMember,
|
||||
});
|
||||
|
||||
const modactions = pluginData.getPlugin(ModActionsPlugin);
|
||||
if (!userCfg.can_use || !(await modactions.hasNotePermission(executingMember, interaction.channelId))) {
|
||||
await interaction.editReply({ content: "Cannot note: insufficient permissions", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const targetMember = await pluginData.guild.members.fetch(target);
|
||||
if (!canActOn(pluginData, executingMember, targetMember)) {
|
||||
await interaction.editReply({ content: "Cannot mute: insufficient permissions", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const createdCase = await casesPlugin.createCase({
|
||||
userId: target,
|
||||
modId: executingMember.id,
|
||||
type: CaseTypes.Note,
|
||||
reason,
|
||||
});
|
||||
|
||||
pluginData.getPlugin(LogsPlugin).logMemberNote({
|
||||
mod: interaction.user,
|
||||
user: targetMember.user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
});
|
||||
|
||||
const userName = renderUserUsername(targetMember.user);
|
||||
await interaction.editReply({
|
||||
content: `Note added on **${userName}** (Case #${createdCase.case_number})`,
|
||||
embeds: [],
|
||||
components: [],
|
||||
});
|
||||
}
|
||||
|
||||
export async function launchNoteActionModal(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
interaction: ButtonInteraction,
|
||||
target: string,
|
||||
) {
|
||||
const modal = new ModalBuilder().setCustomId("note").setTitle("Note");
|
||||
|
||||
const reasonIn = new TextInputBuilder().setCustomId("reason").setLabel("Note").setStyle(TextInputStyle.Paragraph);
|
||||
|
||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||
|
||||
modal.addComponents(reasonRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
const submitted: ModalSubmitInteraction = await interaction.awaitModalSubmit({ time: MODAL_TIMEOUT });
|
||||
if (submitted) {
|
||||
await submitted.deferUpdate();
|
||||
|
||||
const reason = submitted.fields.getTextInputValue("reason");
|
||||
|
||||
await noteAction(pluginData, reason, target, interaction);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
import { ContextMenuCommandInteraction } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { UtilityPlugin } from "../../../plugins/Utility/UtilityPlugin";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
|
||||
export async function userInfoAction(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
interaction: ContextMenuCommandInteraction,
|
||||
) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||
const userCfg = await pluginData.config.getMatchingConfig({
|
||||
channelId: interaction.channelId,
|
||||
member: executingMember,
|
||||
});
|
||||
const utility = pluginData.getPlugin(UtilityPlugin);
|
||||
|
||||
if (userCfg.can_use && (await utility.hasPermission(executingMember, interaction.channelId, "can_userinfo"))) {
|
||||
const embed = await utility.userInfo(interaction.targetId, interaction.user.id);
|
||||
if (!embed) {
|
||||
await interaction.followUp({ content: "Cannot info: internal error" });
|
||||
return;
|
||||
}
|
||||
await interaction.followUp({ embeds: [embed] });
|
||||
} else {
|
||||
await interaction.followUp({ content: "Cannot info: insufficient permissions" });
|
||||
}
|
||||
}
|
80
backend/src/plugins/ContextMenus/actions/warn.ts
Normal file
80
backend/src/plugins/ContextMenus/actions/warn.ts
Normal file
|
@ -0,0 +1,80 @@
|
|||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonInteraction,
|
||||
ModalBuilder,
|
||||
ModalSubmitInteraction,
|
||||
TextInputBuilder,
|
||||
TextInputStyle,
|
||||
} from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { canActOn } from "src/pluginUtils";
|
||||
import { ModActionsPlugin } from "src/plugins/ModActions/ModActionsPlugin";
|
||||
import { renderUserUsername } from "../../../utils";
|
||||
import { CaseArgs } from "../../Cases/types";
|
||||
import { MODAL_TIMEOUT } from "../commands/ModMenuCmd";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
|
||||
async function warnAction(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
reason: string,
|
||||
target: string,
|
||||
interaction: ButtonInteraction,
|
||||
) {
|
||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||
const userCfg = await pluginData.config.getMatchingConfig({
|
||||
channelId: interaction.channelId,
|
||||
member: executingMember,
|
||||
});
|
||||
|
||||
const modactions = pluginData.getPlugin(ModActionsPlugin);
|
||||
if (!userCfg.can_use || !(await modactions.hasWarnPermission(executingMember, interaction.channelId))) {
|
||||
await interaction.editReply({ content: "Cannot warn: insufficient permissions", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const targetMember = await pluginData.guild.members.fetch(target);
|
||||
if (!canActOn(pluginData, executingMember, targetMember)) {
|
||||
await interaction.editReply({ content: "Cannot mute: insufficient permissions", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const caseArgs: Partial<CaseArgs> = {
|
||||
modId: executingMember.id,
|
||||
};
|
||||
|
||||
const result = await modactions.warnMember(targetMember, reason, { caseArgs });
|
||||
if (result.status === "failed") {
|
||||
await interaction.editReply({ content: "Failed to warn user", embeds: [], components: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const userName = renderUserUsername(targetMember.user);
|
||||
const messageResultText = result.notifyResult.text ? ` (${result.notifyResult.text})` : "";
|
||||
const muteMessage = `Warned **${userName}** (Case #${result.case.case_number})${messageResultText}`;
|
||||
|
||||
await interaction.editReply({ content: muteMessage, embeds: [], components: [] });
|
||||
}
|
||||
|
||||
export async function launchWarnActionModal(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
interaction: ButtonInteraction,
|
||||
target: string,
|
||||
) {
|
||||
const modal = new ModalBuilder().setCustomId("warn").setTitle("Warn");
|
||||
|
||||
const reasonIn = new TextInputBuilder().setCustomId("reason").setLabel("Reason").setStyle(TextInputStyle.Paragraph);
|
||||
|
||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||
|
||||
modal.addComponents(reasonRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
const submitted: ModalSubmitInteraction = await interaction.awaitModalSubmit({ time: MODAL_TIMEOUT });
|
||||
if (submitted) {
|
||||
await submitted.deferUpdate();
|
||||
|
||||
const reason = submitted.fields.getTextInputValue("reason");
|
||||
|
||||
await warnAction(pluginData, reason, target, interaction);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue