-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧩 Add function actionDrawer in utils and plugin_base
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>>[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>>[]; | ||
} |