diff --git a/plugins/plugin_base/src/functions/actionDrawer.ts b/plugins/plugin_base/src/functions/actionDrawer.ts new file mode 100644 index 00000000..0d1b7cb0 --- /dev/null +++ b/plugins/plugin_base/src/functions/actionDrawer.ts @@ -0,0 +1,17 @@ +import { ActionRowBuilder, AnyComponentBuilder } from "discord.js"; + +/** + * ActionsRow drawer, for multiple buttons, lines is for the number of buttons in each line + */ +export function ActionDrawer(rows: T[], lines = 5) { + const actions = []; + let current: ActionRowBuilder = new ActionRowBuilder(); + for (let i = 0; i < rows.length; i++) { + if (i % lines === 0) { + current = new ActionRowBuilder(); + actions.push(current); + } + current.addComponents(rows[i]); + } + return actions as InstanceType>[]; +} \ No newline at end of file diff --git a/plugins/utils/src/functions/actionDrawer.ts b/plugins/utils/src/functions/actionDrawer.ts new file mode 100644 index 00000000..0d1b7cb0 --- /dev/null +++ b/plugins/utils/src/functions/actionDrawer.ts @@ -0,0 +1,17 @@ +import { ActionRowBuilder, AnyComponentBuilder } from "discord.js"; + +/** + * ActionsRow drawer, for multiple buttons, lines is for the number of buttons in each line + */ +export function ActionDrawer(rows: T[], lines = 5) { + const actions = []; + let current: ActionRowBuilder = new ActionRowBuilder(); + for (let i = 0; i < rows.length; i++) { + if (i % lines === 0) { + current = new ActionRowBuilder(); + actions.push(current); + } + current.addComponents(rows[i]); + } + return actions as InstanceType>[]; +} \ No newline at end of file