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

feat: add '!role_buttons reset' command

This commit is contained in:
Dragory 2022-04-23 19:43:11 +03:00
parent 4a9ece8e3b
commit b6ab2c7d4a
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
3 changed files with 46 additions and 0 deletions

View file

@ -10,6 +10,7 @@ import { onButtonInteraction } from "./events/buttonInteraction";
import { pluginInfo } from "./info";
import { createButtonComponents } from "./functions/createButtonComponents";
import { TooManyComponentsError } from "./functions/TooManyComponentsError";
import { resetButtonsCmd } from "./commands/resetButtons";
export const RoleButtonsPlugin = zeppelinGuildPlugin<RoleButtonsPluginType>()({
name: "role_buttons",
@ -17,6 +18,21 @@ export const RoleButtonsPlugin = zeppelinGuildPlugin<RoleButtonsPluginType>()({
info: pluginInfo,
showInDocs: true,
defaultOptions: {
config: {
buttons: {},
can_reset: false,
},
overrides: [
{
level: ">=100",
config: {
can_reset: true,
},
},
],
},
configPreprocessor(options) {
// Auto-fill "name" property for buttons based on the object key
const buttonsArray = Array.isArray(options.config?.buttons) ? options.config.buttons : [];
@ -58,6 +74,8 @@ export const RoleButtonsPlugin = zeppelinGuildPlugin<RoleButtonsPluginType>()({
events: [onButtonInteraction],
commands: [resetButtonsCmd],
beforeLoad(pluginData) {
pluginData.state.roleButtons = GuildRoleButtons.getGuildInstance(pluginData.guild.id);
},