3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-08 00:05:01 +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

@ -6,6 +6,7 @@ import { resetButtonsCmd } from "./commands/resetButtons";
import { onButtonInteraction } from "./events/buttonInteraction";
import { applyAllRoleButtons } from "./functions/applyAllRoleButtons";
import { RoleButtonsPluginType, zRoleButtonsConfig } from "./types";
import { CommonPlugin } from "../Common/CommonPlugin";
export const RoleButtonsPlugin = guildPlugin<RoleButtonsPluginType>()({
name: "role_buttons",
@ -37,6 +38,10 @@ export const RoleButtonsPlugin = guildPlugin<RoleButtonsPluginType>()({
pluginData.state.roleButtons = GuildRoleButtons.getGuildInstance(pluginData.guild.id);
},
beforeStart(pluginData) {
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
},
async afterLoad(pluginData) {
await applyAllRoleButtons(pluginData);
},

View file

@ -16,14 +16,12 @@ export const resetButtonsCmd = guildPluginMessageCommand<RoleButtonsPluginType>(
async run({ pluginData, args, message }) {
const config = pluginData.config.get();
if (!config.buttons[args.name]) {
pluginData
.getPlugin(CommonPlugin)
.sendErrorMessage(message, `Can't find role buttons with the name "${args.name}"`);
void pluginData.state.common.sendErrorMessage(message, `Can't find role buttons with the name "${args.name}"`);
return;
}
await pluginData.state.roleButtons.deleteRoleButtonItem(args.name);
await applyAllRoleButtons(pluginData);
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(message, "Done!");
void pluginData.state.common.sendSuccessMessage(message, "Done!");
},
});

View file

@ -1,10 +1,11 @@
import { ButtonStyle } from "discord.js";
import { BasePluginType } from "knub";
import { BasePluginType, pluginUtils } from "knub";
import z from "zod";
import { GuildRoleButtons } from "../../data/GuildRoleButtons";
import { zBoundedCharacters, zBoundedRecord, zMessageContent, zSnowflake } from "../../utils";
import { TooManyComponentsError } from "./functions/TooManyComponentsError";
import { createButtonComponents } from "./functions/createButtonComponents";
import { CommonPlugin } from "../Common/CommonPlugin";
const zRoleButtonOption = z.strictObject({
role_id: zSnowflake,
@ -109,5 +110,6 @@ export interface RoleButtonsPluginType extends BasePluginType {
config: z.infer<typeof zRoleButtonsConfig>;
state: {
roleButtons: GuildRoleButtons;
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
};
}