-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathenableButtons.ts
More file actions
44 lines (39 loc) · 1.32 KB
/
enableButtons.ts
File metadata and controls
44 lines (39 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* SPDX-License-Identifier: LGPL-3.0-or-later
* Copyright © 2026 BotForge
*/
import { ButtonBuilder, ActionRowBuilder } from "discord.js"
import { ArgType, NativeFunction } from "../../structures"
export default new NativeFunction({
name: "$enableButtons",
version: "2.2.0",
description: "Enables all buttons on the current message",
aliases: ["$enableAllButtons"],
unwrap: true,
args: [
{
name: "index",
description: "The index of the row to enable",
rest: false,
required: true,
type: ArgType.Number,
},
],
brackets: false,
execute(ctx, [index]) {
const data = ctx.container.components
const components = Number.isFinite(index) ? new Array(data[index]) : data
ctx.container.actionRow?.components.forEach((x) => {
if (x instanceof ButtonBuilder) x.setDisabled(false)
})
for (let i = 0, len = components.length; i < len; i++) {
const row = components[i]
if (!(row instanceof ActionRowBuilder)) continue
const actionRow = new ActionRowBuilder()
row?.components.forEach((x) => {
if (x instanceof ButtonBuilder) actionRow.addComponents(x.setDisabled(false))
})
}
return this.success()
},
})