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 { trimPluginDescription } from "../../utils";
|
||||||
import { CasesPlugin } from "../Cases/CasesPlugin";
|
import { CasesPlugin } from "../Cases/CasesPlugin";
|
||||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||||
|
import { ModActionsPlugin } from "../ModActions/ModActionsPlugin";
|
||||||
import { MutesPlugin } from "../Mutes/MutesPlugin";
|
import { MutesPlugin } from "../Mutes/MutesPlugin";
|
||||||
import { UtilityPlugin } from "../Utility/UtilityPlugin";
|
import { UtilityPlugin } from "../Utility/UtilityPlugin";
|
||||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
|
@ -15,8 +16,6 @@ const defaultOptions: PluginOptions<ContextMenuPluginType> = {
|
||||||
can_use: false,
|
can_use: false,
|
||||||
|
|
||||||
can_open_mod_menu: false,
|
can_open_mod_menu: false,
|
||||||
|
|
||||||
log_channel: null,
|
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
|
@ -41,8 +40,9 @@ export const ContextMenuPlugin = zeppelinGuildPlugin<ContextMenuPluginType>()({
|
||||||
configSchema: ConfigSchema,
|
configSchema: ConfigSchema,
|
||||||
},
|
},
|
||||||
|
|
||||||
dependencies: () => [CasesPlugin, MutesPlugin, LogsPlugin, UtilityPlugin],
|
dependencies: () => [CasesPlugin, MutesPlugin, ModActionsPlugin, LogsPlugin, UtilityPlugin],
|
||||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||||
|
|
||||||
defaultOptions,
|
defaultOptions,
|
||||||
|
|
||||||
contextMenuCommands: [ModMenuCmd],
|
contextMenuCommands: [ModMenuCmd],
|
||||||
|
|
|
@ -47,7 +47,7 @@ async function banAction(
|
||||||
const durationMs = duration ? convertDelayStringToMS(duration)! : undefined;
|
const durationMs = duration ? convertDelayStringToMS(duration)! : undefined;
|
||||||
const result = await modactions.banUserId(target, reason, { caseArgs }, durationMs);
|
const result = await modactions.banUserId(target, reason, { caseArgs }, durationMs);
|
||||||
if (result.status === "failed") {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,22 +66,18 @@ export async function launchBanActionModal(
|
||||||
target: string,
|
target: string,
|
||||||
) {
|
) {
|
||||||
const modal = new ModalBuilder().setCustomId("ban").setTitle("Ban");
|
const modal = new ModalBuilder().setCustomId("ban").setTitle("Ban");
|
||||||
|
|
||||||
const durationIn = new TextInputBuilder()
|
const durationIn = new TextInputBuilder()
|
||||||
.setCustomId("duration")
|
.setCustomId("duration")
|
||||||
.setLabel("Duration (Optional)")
|
.setLabel("Duration (Optional)")
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.setStyle(TextInputStyle.Short);
|
.setStyle(TextInputStyle.Short);
|
||||||
|
|
||||||
const reasonIn = new TextInputBuilder()
|
const reasonIn = new TextInputBuilder()
|
||||||
.setCustomId("reason")
|
.setCustomId("reason")
|
||||||
.setLabel("Reason (Optional)")
|
.setLabel("Reason (Optional)")
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.setStyle(TextInputStyle.Paragraph);
|
.setStyle(TextInputStyle.Paragraph);
|
||||||
|
|
||||||
const durationRow = new ActionRowBuilder<TextInputBuilder>().addComponents(durationIn);
|
const durationRow = new ActionRowBuilder<TextInputBuilder>().addComponents(durationIn);
|
||||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||||
|
|
||||||
modal.addComponents(durationRow, reasonRow);
|
modal.addComponents(durationRow, reasonRow);
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
await interaction.showModal(modal);
|
||||||
|
|
|
@ -43,11 +43,8 @@ export async function launchCleanActionModal(
|
||||||
target: string,
|
target: string,
|
||||||
) {
|
) {
|
||||||
const modal = new ModalBuilder().setCustomId("clean").setTitle("Clean");
|
const modal = new ModalBuilder().setCustomId("clean").setTitle("Clean");
|
||||||
|
|
||||||
const amountIn = new TextInputBuilder().setCustomId("amount").setLabel("Amount").setStyle(TextInputStyle.Short);
|
const amountIn = new TextInputBuilder().setCustomId("amount").setLabel("Amount").setStyle(TextInputStyle.Short);
|
||||||
|
|
||||||
const amountRow = new ActionRowBuilder<TextInputBuilder>().addComponents(amountIn);
|
const amountRow = new ActionRowBuilder<TextInputBuilder>().addComponents(amountIn);
|
||||||
|
|
||||||
modal.addComponents(amountRow);
|
modal.addComponents(amountRow);
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
await interaction.showModal(modal);
|
||||||
|
@ -57,7 +54,7 @@ export async function launchCleanActionModal(
|
||||||
|
|
||||||
const amount = submitted.fields.getTextInputValue("amount");
|
const amount = submitted.fields.getTextInputValue("amount");
|
||||||
if (isNaN(Number(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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,22 +77,18 @@ export async function launchMuteActionModal(
|
||||||
target: string,
|
target: string,
|
||||||
) {
|
) {
|
||||||
const modal = new ModalBuilder().setCustomId("mute").setTitle("Mute");
|
const modal = new ModalBuilder().setCustomId("mute").setTitle("Mute");
|
||||||
|
|
||||||
const durationIn = new TextInputBuilder()
|
const durationIn = new TextInputBuilder()
|
||||||
.setCustomId("duration")
|
.setCustomId("duration")
|
||||||
.setLabel("Duration (Optional)")
|
.setLabel("Duration (Optional)")
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.setStyle(TextInputStyle.Short);
|
.setStyle(TextInputStyle.Short);
|
||||||
|
|
||||||
const reasonIn = new TextInputBuilder()
|
const reasonIn = new TextInputBuilder()
|
||||||
.setCustomId("reason")
|
.setCustomId("reason")
|
||||||
.setLabel("Reason (Optional)")
|
.setLabel("Reason (Optional)")
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.setStyle(TextInputStyle.Paragraph);
|
.setStyle(TextInputStyle.Paragraph);
|
||||||
|
|
||||||
const durationRow = new ActionRowBuilder<TextInputBuilder>().addComponents(durationIn);
|
const durationRow = new ActionRowBuilder<TextInputBuilder>().addComponents(durationIn);
|
||||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||||
|
|
||||||
modal.addComponents(durationRow, reasonRow);
|
modal.addComponents(durationRow, reasonRow);
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
await interaction.showModal(modal);
|
||||||
|
|
|
@ -36,7 +36,7 @@ async function noteAction(
|
||||||
|
|
||||||
const targetMember = await pluginData.guild.members.fetch(target);
|
const targetMember = await pluginData.guild.members.fetch(target);
|
||||||
if (!canActOn(pluginData, executingMember, targetMember)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +69,8 @@ export async function launchNoteActionModal(
|
||||||
target: string,
|
target: string,
|
||||||
) {
|
) {
|
||||||
const modal = new ModalBuilder().setCustomId("note").setTitle("Note");
|
const modal = new ModalBuilder().setCustomId("note").setTitle("Note");
|
||||||
|
|
||||||
const reasonIn = new TextInputBuilder().setCustomId("reason").setLabel("Note").setStyle(TextInputStyle.Paragraph);
|
const reasonIn = new TextInputBuilder().setCustomId("reason").setLabel("Note").setStyle(TextInputStyle.Paragraph);
|
||||||
|
|
||||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||||
|
|
||||||
modal.addComponents(reasonRow);
|
modal.addComponents(reasonRow);
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
await interaction.showModal(modal);
|
||||||
|
|
|
@ -34,7 +34,7 @@ async function warnAction(
|
||||||
|
|
||||||
const targetMember = await pluginData.guild.members.fetch(target);
|
const targetMember = await pluginData.guild.members.fetch(target);
|
||||||
if (!canActOn(pluginData, executingMember, targetMember)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ async function warnAction(
|
||||||
|
|
||||||
const result = await modactions.warnMember(targetMember, reason, { caseArgs });
|
const result = await modactions.warnMember(targetMember, reason, { caseArgs });
|
||||||
if (result.status === "failed") {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +61,8 @@ export async function launchWarnActionModal(
|
||||||
target: string,
|
target: string,
|
||||||
) {
|
) {
|
||||||
const modal = new ModalBuilder().setCustomId("warn").setTitle("Warn");
|
const modal = new ModalBuilder().setCustomId("warn").setTitle("Warn");
|
||||||
|
|
||||||
const reasonIn = new TextInputBuilder().setCustomId("reason").setLabel("Reason").setStyle(TextInputStyle.Paragraph);
|
const reasonIn = new TextInputBuilder().setCustomId("reason").setLabel("Reason").setStyle(TextInputStyle.Paragraph);
|
||||||
|
|
||||||
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
const reasonRow = new ActionRowBuilder<TextInputBuilder>().addComponents(reasonIn);
|
||||||
|
|
||||||
modal.addComponents(reasonRow);
|
modal.addComponents(reasonRow);
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
await interaction.showModal(modal);
|
||||||
|
|
|
@ -84,33 +84,24 @@ export const ModMenuCmd = guildPluginUserContextMenuCommand({
|
||||||
lines.length == 0
|
lines.length == 0
|
||||||
? `${userName}`
|
? `${userName}`
|
||||||
: `Most recent cases for ${userName} | ${firstCaseNum}-${lastCaseNum} of ${totalCases}`;
|
: `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 = {
|
const embed = {
|
||||||
author: {
|
author: {
|
||||||
name: title,
|
name: title,
|
||||||
icon_url: user instanceof User ? user.displayAvatarURL() : undefined,
|
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}` },
|
footer: { text: `Page ${page}/${totalPages}` },
|
||||||
} satisfies APIEmbed;
|
} satisfies APIEmbed;
|
||||||
|
|
||||||
|
|
|
@ -2,27 +2,18 @@ import { APIEmbed, Awaitable } from "discord.js";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { BasePluginType } from "knub";
|
import { BasePluginType } from "knub";
|
||||||
import { GuildCases } from "../../data/GuildCases";
|
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({
|
export const ConfigSchema = t.type({
|
||||||
can_use: t.boolean,
|
can_use: t.boolean,
|
||||||
|
|
||||||
can_open_mod_menu: t.boolean,
|
can_open_mod_menu: t.boolean,
|
||||||
|
|
||||||
log_channel: tNullable(t.string),
|
|
||||||
});
|
});
|
||||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||||
|
|
||||||
export interface ContextMenuPluginType extends BasePluginType {
|
export interface ContextMenuPluginType extends BasePluginType {
|
||||||
config: TConfigSchema;
|
config: TConfigSchema;
|
||||||
state: {
|
state: {
|
||||||
mutes: GuildMutes;
|
|
||||||
cases: GuildCases;
|
cases: GuildCases;
|
||||||
tempbans: GuildTempbans;
|
|
||||||
serverLogs: GuildLogs;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue