Skip to content

Commit

Permalink
🧩 Add function actionDrawer in utils and plugin_base
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Jun 14, 2024
1 parent d88451e commit 782a8d5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions plugins/plugin_base/src/functions/actionDrawer.ts
Original file line number Diff line number Diff line change
@@ -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<T extends AnyComponentBuilder>(rows: T[], lines = 5) {
const actions = [];
let current: ActionRowBuilder<T> = 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<typeof ActionRowBuilder<T>>[];
}
17 changes: 17 additions & 0 deletions plugins/utils/src/functions/actionDrawer.ts
Original file line number Diff line number Diff line change
@@ -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<T extends AnyComponentBuilder>(rows: T[], lines = 5) {
const actions = [];
let current: ActionRowBuilder<T> = 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<typeof ActionRowBuilder<T>>[];
}

0 comments on commit 782a8d5

Please sign in to comment.