mirror of
https://github.com/HirziDevs/PteroStats.git
synced 2026-03-31 06:24:10 -04:00
feat: add multiple row support for link buttons
This commit is contained in:
11
config.yml
11
config.yml
@@ -52,10 +52,15 @@ embed:
|
||||
button:
|
||||
enable: true # Enable or disable buttons in messages.
|
||||
row1:
|
||||
- label: "Panel"
|
||||
- label: "Panel" # Label for the first button.
|
||||
url: "https://panel.example.com" # URL for the first button.
|
||||
# - label: "Dashboard" # Uncomment to add a second button.
|
||||
# url: "https://dash.example.com" # URL for the second button.
|
||||
# - label: "Dashboard" # Remove "#" at the start of the line to use this button
|
||||
# url: "https://dash.example.com" # Remove "#" at the start of the line to use this button
|
||||
# row2: # Remove "#" at the start of the line to use this row
|
||||
# - label: "Backup Panel"
|
||||
# url: "https://panel2.example.com"
|
||||
# - label: "Backup Dashboard"
|
||||
# url: "https://dash2.example.com"
|
||||
|
||||
# Status Message Configuration
|
||||
# For details on using custom emojis, visit: https://github.com/HirziDevs/PteroStats#using-custom-emoji
|
||||
|
||||
25
index.js
25
index.js
@@ -191,17 +191,20 @@ async function createMessage({ cache, panel, nodes, servers, users }) {
|
||||
|
||||
const components = []
|
||||
|
||||
if (config.button.enable && config.button.row1?.length > 0) {
|
||||
components.push(
|
||||
new ActionRowBuilder().addComponents(
|
||||
config.button.row1.map(button =>
|
||||
new ButtonBuilder()
|
||||
.setLabel(button.label)
|
||||
.setURL(button.url)
|
||||
.setStyle(ButtonStyle.Link)
|
||||
)
|
||||
)
|
||||
)
|
||||
if (config.button.enable) {
|
||||
for (const row of ["row1", "row2", "row3", "row4", "row5"]) {
|
||||
if (config.button[row] && config.button[row].length > 0 && config.button[row].label && config.button[row].url)
|
||||
components.push(
|
||||
new ActionRowBuilder().addComponents(
|
||||
config.button[row].slice(0, 5).map(button =>
|
||||
new ButtonBuilder()
|
||||
.setLabel(button.label)
|
||||
.setURL(button.url)
|
||||
.setStyle(ButtonStyle.Link)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user