diff --git a/backend/src/plugins/ContextMenus/ContextMenuPlugin.ts b/backend/src/plugins/ContextMenus/ContextMenuPlugin.ts index dc08389e..b48cc0ea 100644 --- a/backend/src/plugins/ContextMenus/ContextMenuPlugin.ts +++ b/backend/src/plugins/ContextMenus/ContextMenuPlugin.ts @@ -4,6 +4,7 @@ import { makeIoTsConfigParser } from "../../pluginUtils"; import { trimPluginDescription } from "../../utils"; import { CasesPlugin } from "../Cases/CasesPlugin"; import { LogsPlugin } from "../Logs/LogsPlugin"; +import { ModActionsPlugin } from "../ModActions/ModActionsPlugin"; import { MutesPlugin } from "../Mutes/MutesPlugin"; import { UtilityPlugin } from "../Utility/UtilityPlugin"; import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint"; @@ -15,8 +16,6 @@ const defaultOptions: PluginOptions = { can_use: false, can_open_mod_menu: false, - - log_channel: null, }, overrides: [ { @@ -41,8 +40,9 @@ export const ContextMenuPlugin = zeppelinGuildPlugin()({ configSchema: ConfigSchema, }, - dependencies: () => [CasesPlugin, MutesPlugin, LogsPlugin, UtilityPlugin], + dependencies: () => [CasesPlugin, MutesPlugin, ModActionsPlugin, LogsPlugin, UtilityPlugin], configParser: makeIoTsConfigParser(ConfigSchema), + defaultOptions, contextMenuCommands: [ModMenuCmd], diff --git a/backend/src/plugins/ContextMenus/actions/ban.ts b/backend/src/plugins/ContextMenus/actions/ban.ts index 38ec91a1..bfe7bc13 100644 --- a/backend/src/plugins/ContextMenus/actions/ban.ts +++ b/backend/src/plugins/ContextMenus/actions/ban.ts @@ -47,7 +47,7 @@ async function banAction( 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: [] }); + await interaction.editReply({ content: "Error: Failed to ban user", embeds: [], components: [] }); return; } @@ -66,22 +66,18 @@ export async function launchBanActionModal( 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().addComponents(durationIn); const reasonRow = new ActionRowBuilder().addComponents(reasonIn); - modal.addComponents(durationRow, reasonRow); await interaction.showModal(modal); diff --git a/backend/src/plugins/ContextMenus/actions/clean.ts b/backend/src/plugins/ContextMenus/actions/clean.ts index 6274f230..3d005bfb 100644 --- a/backend/src/plugins/ContextMenus/actions/clean.ts +++ b/backend/src/plugins/ContextMenus/actions/clean.ts @@ -43,11 +43,8 @@ export async function launchCleanActionModal( target: string, ) { const modal = new ModalBuilder().setCustomId("clean").setTitle("Clean"); - const amountIn = new TextInputBuilder().setCustomId("amount").setLabel("Amount").setStyle(TextInputStyle.Short); - const amountRow = new ActionRowBuilder().addComponents(amountIn); - modal.addComponents(amountRow); await interaction.showModal(modal); @@ -57,7 +54,7 @@ export async function launchCleanActionModal( const amount = submitted.fields.getTextInputValue("amount"); if (isNaN(Number(amount))) { - interaction.editReply({ content: `ERROR: Amount ${amount} is invalid`, embeds: [], components: [] }); + interaction.editReply({ content: `Error: Amount '${amount}' is invalid`, embeds: [], components: [] }); return; } diff --git a/backend/src/plugins/ContextMenus/actions/mute.ts b/backend/src/plugins/ContextMenus/actions/mute.ts index a86a5ddd..90a04575 100644 --- a/backend/src/plugins/ContextMenus/actions/mute.ts +++ b/backend/src/plugins/ContextMenus/actions/mute.ts @@ -77,22 +77,18 @@ export async function launchMuteActionModal( 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().addComponents(durationIn); const reasonRow = new ActionRowBuilder().addComponents(reasonIn); - modal.addComponents(durationRow, reasonRow); await interaction.showModal(modal); diff --git a/backend/src/plugins/ContextMenus/actions/note.ts b/backend/src/plugins/ContextMenus/actions/note.ts index 13d855d5..84b0e2bb 100644 --- a/backend/src/plugins/ContextMenus/actions/note.ts +++ b/backend/src/plugins/ContextMenus/actions/note.ts @@ -36,7 +36,7 @@ async function noteAction( const targetMember = await pluginData.guild.members.fetch(target); if (!canActOn(pluginData, executingMember, targetMember)) { - await interaction.editReply({ content: "Cannot mute: insufficient permissions", embeds: [], components: [] }); + await interaction.editReply({ content: "Cannot note: insufficient permissions", embeds: [], components: [] }); return; } @@ -69,11 +69,8 @@ export async function launchNoteActionModal( 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().addComponents(reasonIn); - modal.addComponents(reasonRow); await interaction.showModal(modal); diff --git a/backend/src/plugins/ContextMenus/actions/warn.ts b/backend/src/plugins/ContextMenus/actions/warn.ts index bbfa66c5..c6a0c8ca 100644 --- a/backend/src/plugins/ContextMenus/actions/warn.ts +++ b/backend/src/plugins/ContextMenus/actions/warn.ts @@ -34,7 +34,7 @@ async function warnAction( const targetMember = await pluginData.guild.members.fetch(target); if (!canActOn(pluginData, executingMember, targetMember)) { - await interaction.editReply({ content: "Cannot mute: insufficient permissions", embeds: [], components: [] }); + await interaction.editReply({ content: "Cannot warn: insufficient permissions", embeds: [], components: [] }); return; } @@ -44,7 +44,7 @@ async function warnAction( const result = await modactions.warnMember(targetMember, reason, { caseArgs }); if (result.status === "failed") { - await interaction.editReply({ content: "Failed to warn user", embeds: [], components: [] }); + await interaction.editReply({ content: "Error: Failed to warn user", embeds: [], components: [] }); return; } @@ -61,11 +61,8 @@ export async function launchWarnActionModal( 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().addComponents(reasonIn); - modal.addComponents(reasonRow); await interaction.showModal(modal); diff --git a/backend/src/plugins/ContextMenus/commands/ModMenuCmd.ts b/backend/src/plugins/ContextMenus/commands/ModMenuCmd.ts index faf9bd2f..1150893c 100644 --- a/backend/src/plugins/ContextMenus/commands/ModMenuCmd.ts +++ b/backend/src/plugins/ContextMenus/commands/ModMenuCmd.ts @@ -84,33 +84,24 @@ export const ModMenuCmd = guildPluginUserContextMenuCommand({ lines.length == 0 ? `${userName}` : `Most recent cases for ${userName} | ${firstCaseNum}-${lastCaseNum} of ${totalCases}`; - const embedFields = - lines.length == 0 - ? [ - { - name: `**No cases found**`, - value: "", - }, - ] - : [ - ...getChunkedEmbedFields( - emptyEmbedValue, - lines.length == 0 ? `No cases found for **${userName}**` : lines.join("\n"), - ), - { - name: emptyEmbedValue, - value: trimLines(` - Use \`${prefix}case \` to see more information about an individual case - `), - }, - ]; const embed = { author: { name: title, icon_url: user instanceof User ? user.displayAvatarURL() : undefined, }, - fields: embedFields, + fields: [ + ...getChunkedEmbedFields( + emptyEmbedValue, + lines.length == 0 ? `No cases found for **${userName}**` : lines.join("\n"), + ), + { + name: emptyEmbedValue, + value: trimLines( + lines.length == 0 ? "" : `Use \`${prefix}case \` to see more information about an individual case`, + ), + }, + ], footer: { text: `Page ${page}/${totalPages}` }, } satisfies APIEmbed; diff --git a/backend/src/plugins/ContextMenus/types.ts b/backend/src/plugins/ContextMenus/types.ts index b4340b1b..d099d843 100644 --- a/backend/src/plugins/ContextMenus/types.ts +++ b/backend/src/plugins/ContextMenus/types.ts @@ -2,27 +2,18 @@ import { APIEmbed, Awaitable } from "discord.js"; import * as t from "io-ts"; import { BasePluginType } from "knub"; import { GuildCases } from "../../data/GuildCases"; -import { GuildLogs } from "../../data/GuildLogs"; -import { GuildMutes } from "../../data/GuildMutes"; -import { GuildTempbans } from "../../data/GuildTempbans"; -import { tNullable } from "../../utils"; export const ConfigSchema = t.type({ can_use: t.boolean, can_open_mod_menu: t.boolean, - - log_channel: tNullable(t.string), }); export type TConfigSchema = t.TypeOf; export interface ContextMenuPluginType extends BasePluginType { config: TConfigSchema; state: { - mutes: GuildMutes; cases: GuildCases; - tempbans: GuildTempbans; - serverLogs: GuildLogs; }; }