mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 05:45:02 +00:00
fix: plugin dependencies and cleanup
This commit is contained in:
parent
771ed76f64
commit
24b11800f5
8 changed files with 20 additions and 55 deletions
|
@ -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<ContextMenuPluginType> = {
|
|||
can_use: false,
|
||||
|
||||
can_open_mod_menu: false,
|
||||
|
||||
log_channel: null,
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
@ -41,8 +40,9 @@ export const ContextMenuPlugin = zeppelinGuildPlugin<ContextMenuPluginType>()({
|
|||
configSchema: ConfigSchema,
|
||||
},
|
||||
|
||||
dependencies: () => [CasesPlugin, MutesPlugin, LogsPlugin, UtilityPlugin],
|
||||
dependencies: () => [CasesPlugin, MutesPlugin, ModActionsPlugin, LogsPlugin, UtilityPlugin],
|
||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||
|
||||
defaultOptions,
|
||||
|
||||
contextMenuCommands: [ModMenuCmd],
|
||||
|
|
|
@ -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<TextInputBuilder>().addComponents(durationIn);
|
||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||
|
||||
modal.addComponents(durationRow, reasonRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
|
|
|
@ -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<TextInputBuilder>().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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<TextInputBuilder>().addComponents(durationIn);
|
||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||
|
||||
modal.addComponents(durationRow, reasonRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
|
|
|
@ -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<TextInputBuilder>().addComponents(reasonIn);
|
||||
|
||||
modal.addComponents(reasonRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
|
|
|
@ -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<TextInputBuilder>().addComponents(reasonIn);
|
||||
|
||||
modal.addComponents(reasonRow);
|
||||
|
||||
await interaction.showModal(modal);
|
||||
|
|
|
@ -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 <num>\` 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 <num>\` to see more information about an individual case`,
|
||||
),
|
||||
},
|
||||
],
|
||||
footer: { text: `Page ${page}/${totalPages}` },
|
||||
} satisfies APIEmbed;
|
||||
|
||||
|
|
|
@ -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<typeof ConfigSchema>;
|
||||
|
||||
export interface ContextMenuPluginType extends BasePluginType {
|
||||
config: TConfigSchema;
|
||||
state: {
|
||||
mutes: GuildMutes;
|
||||
cases: GuildCases;
|
||||
tempbans: GuildTempbans;
|
||||
serverLogs: GuildLogs;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue