3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-08 00:05:01 +00:00

Merge branch '240811_application_commands_merge_2' into next

This commit is contained in:
Dragory 2024-08-11 22:28:41 +03:00
commit 43b8017985
No known key found for this signature in database
279 changed files with 6192 additions and 3044 deletions

View file

@ -1,5 +1,6 @@
import { guildPlugin } from "knub";
import { GuildRoleButtons } from "../../data/GuildRoleButtons.js";
import { CommonPlugin } from "../Common/CommonPlugin.js";
import { LogsPlugin } from "../Logs/LogsPlugin.js";
import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin.js";
import { resetButtonsCmd } from "./commands/resetButtons.js";
@ -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

@ -1,6 +1,5 @@
import { guildPluginMessageCommand } from "knub";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { applyAllRoleButtons } from "../functions/applyAllRoleButtons.js";
import { RoleButtonsPluginType } from "../types.js";
@ -16,12 +15,12 @@ export const resetButtonsCmd = guildPluginMessageCommand<RoleButtonsPluginType>(
async run({ pluginData, args, message }) {
const config = pluginData.config.get();
if (!config.buttons[args.name]) {
sendErrorMessage(pluginData, message.channel, `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);
sendSuccessMessage(pluginData, message.channel, "Done!");
void pluginData.state.common.sendSuccessMessage(message, "Done!");
},
});

View file

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