3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-17 11:25:03 +00:00

Fixes, refactoring and PR feedback

This commit is contained in:
Lily Bergonzat 2024-04-15 15:51:45 +02:00
parent 0be54912c4
commit 893a77d562
202 changed files with 1037 additions and 1069 deletions

View file

@ -14,6 +14,7 @@ import {
import { LogsPlugin } from "../Logs/LogsPlugin";
import { runEvent } from "./functions/runEvent";
import { CustomEventsPluginType, zCustomEventsConfig } from "./types";
import { CommonPlugin } from "../Common/CommonPlugin";
const defaultOptions = {
config: {
@ -28,6 +29,10 @@ export const CustomEventsPlugin = guildPlugin<CustomEventsPluginType>()({
configParser: (input) => zCustomEventsConfig.parse(input),
defaultOptions,
beforeStart(pluginData) {
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
},
afterLoad(pluginData) {
const config = pluginData.config.get();
for (const [key, event] of Object.entries(config.events)) {

View file

@ -39,7 +39,7 @@ export async function runEvent(
} catch (e) {
if (e instanceof ActionError) {
if (event.trigger.type === "command") {
pluginData.getPlugin(CommonPlugin).sendErrorMessage((eventData.msg as Message).channel, e.message);
void pluginData.state.common.sendErrorMessage((eventData.msg as Message).channel, e.message);
} else {
// TODO: Where to log action errors from other kinds of triggers?
}

View file

@ -1,4 +1,4 @@
import { BasePluginType } from "knub";
import { BasePluginType, pluginUtils } from "knub";
import z from "zod";
import { zBoundedCharacters, zBoundedRecord } from "../../utils";
import { zAddRoleAction } from "./actions/addRoleAction";
@ -8,6 +8,7 @@ import { zMakeRoleUnmentionableAction } from "./actions/makeRoleUnmentionableAct
import { zMessageAction } from "./actions/messageAction";
import { zMoveToVoiceChannelAction } from "./actions/moveToVoiceChannelAction";
import { zSetChannelPermissionOverridesAction } from "./actions/setChannelPermissionOverrides";
import { CommonPlugin } from "../Common/CommonPlugin";
const zCommandTrigger = z.strictObject({
type: z.literal("command"),
@ -43,5 +44,6 @@ export interface CustomEventsPluginType extends BasePluginType {
config: z.infer<typeof zCustomEventsConfig>;
state: {
clearTriggers: () => void;
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
};
}