discord.fixed.js 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -72
- package/package.json +21 -7
- package/src/Builders/ButtonActionBuilder.cjs +51 -0
- package/src/Builders/ButtonActionBuilder.mjs +51 -0
- package/src/Builders/ButtonActionBuilder.ts +51 -0
- package/src/Builders/ComponentBuilder.cjs +67 -0
- package/src/Builders/ComponentBuilder.mjs +67 -0
- package/src/Builders/ComponentBuilder.ts +68 -0
- package/src/Builders/EmbedBuilder.cjs +26 -0
- package/src/Builders/EmbedBuilder.js +36 -1
- package/src/Builders/EmbedBuilder.mjs +26 -0
- package/src/Builders/EmbedBuilder.ts +30 -0
- package/src/Builders/index.d.ts +81 -0
- package/src/Client/Bot.cjs +17 -0
- package/src/Client/Bot.d.ts +14 -0
- package/src/Client/Bot.js +11 -42
- package/src/Client/Bot.mjs +17 -0
- package/src/Client/Bot.ts +26 -0
- package/src/Patches/Aliases.cjs +47 -0
- package/src/Patches/Aliases.d.ts +43 -0
- package/src/Patches/Aliases.js +11 -2
- package/src/Patches/Aliases.mjs +45 -0
- package/src/Patches/Aliases.ts +43 -0
- package/src/Patches/index.cjs +3 -0
- package/src/Patches/index.d.ts +1 -0
- package/src/Patches/index.mjs +5 -0
- package/src/Patches/index.ts +3 -0
- package/src/Patches/message.cjs +38 -0
- package/src/Patches/message.mjs +38 -0
- package/src/Patches/message.ts +38 -0
- package/src/export.cjs +7 -0
- package/src/export.d.ts +6 -0
- package/src/export.mjs +13 -0
- package/src/export.ts +54 -0
- package/src/Loaders/commandLoader.js +0 -41
- package/src/Loaders/eventLoader.js +0 -35
package/README.md
CHANGED
|
@@ -1,131 +1,136 @@
|
|
|
1
1
|
# ⚙️ discord.fixed.js
|
|
2
2
|
|
|
3
|
-
A **minimal, fast, and opinionated framework** built on top of **discord.js** that removes boilerplate and
|
|
3
|
+
A **minimal, fast, and opinionated framework** built on top of **discord.js** that removes boilerplate and provides helper utilities for building Discord bots.
|
|
4
4
|
|
|
5
|
-
discord.fixed.js is designed to be:
|
|
6
|
-
- Easy to use
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
5
|
+
discord.fixed.js is designed to be:
|
|
6
|
+
- Easy to use
|
|
7
|
+
- Fast to develop with
|
|
8
|
+
- Safe as a library (no forced structure)
|
|
9
|
+
- Compatible with **CJS, ESM (Modern JS), and TypeScript**
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
## ✨ Features
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
- Simplified `Bot` class for Discord.js
|
|
16
|
+
- Builders for modern Discord interactions:
|
|
17
|
+
- `EmbedBuilder` — simplified embed construction
|
|
18
|
+
- `ComponentBuilder` — build complex component layouts
|
|
19
|
+
- `Button`, `Row`, `Select` — quick action row and button handling
|
|
20
|
+
- Message prototype extensions:
|
|
21
|
+
- `.reply()`, `.edit()`, `.deleteSafe()`, `.ping()`
|
|
22
|
+
- Aliases and constants (`I`, `Flags`, `Perms`, `Channels`, etc.)
|
|
23
|
+
- Fully compatible with **CJS, ESM, and TypeScript**
|
|
24
|
+
- Includes `.d.ts` typings for TS projects
|
|
23
25
|
|
|
24
26
|
---
|
|
25
27
|
|
|
26
28
|
## 📦 Installation
|
|
27
29
|
|
|
30
|
+
```bash
|
|
28
31
|
npm install discord.fixed.js
|
|
32
|
+
```
|
|
29
33
|
|
|
30
34
|
---
|
|
31
35
|
|
|
32
36
|
## 🚀 Quick Start
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
### CommonJS
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
const { Bot, EmbedBuilder, Button } = require("discord.fixed.js");
|
|
35
42
|
|
|
36
43
|
const client = new Bot({
|
|
37
44
|
intents: "all",
|
|
38
|
-
|
|
39
|
-
commandsPath: "./commands",
|
|
40
|
-
eventsPath: "./events"
|
|
45
|
+
owners: ["YOUR_USER_ID"]
|
|
41
46
|
});
|
|
42
47
|
|
|
43
48
|
client.start("YOUR_BOT_TOKEN");
|
|
49
|
+
```
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
### Modern JS / ESM
|
|
46
52
|
|
|
47
|
-
|
|
53
|
+
```js
|
|
54
|
+
import { Bot, EmbedBuilder, Button } from "discord.fixed.js";
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
│ └─ hello.js
|
|
54
|
-
│
|
|
55
|
-
├─ events/
|
|
56
|
-
│ └─ ready.js
|
|
57
|
-
│
|
|
58
|
-
└─ index.js
|
|
56
|
+
const client = new Bot({
|
|
57
|
+
intents: "all",
|
|
58
|
+
owners: ["YOUR_USER_ID"]
|
|
59
|
+
});
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
client.start("YOUR_BOT_TOKEN");
|
|
62
|
+
```
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
### TypeScript
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
```ts
|
|
67
|
+
import { Bot, EmbedBuilder, Button } from "discord.fixed.js";
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
message.reply("Pong!");
|
|
71
|
-
}
|
|
72
|
-
};
|
|
69
|
+
const client = new Bot({
|
|
70
|
+
intents: "all",
|
|
71
|
+
owners: ["YOUR_USER_ID"]
|
|
72
|
+
});
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
client.start("YOUR_BOT_TOKEN");
|
|
75
|
+
```
|
|
76
76
|
|
|
77
77
|
---
|
|
78
78
|
|
|
79
|
-
##
|
|
79
|
+
## 🔧 Builders & Utilities
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
### Embeds
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
once: true,
|
|
86
|
-
execute(client) {
|
|
87
|
-
console.log(`${client.user.tag} is online`);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
83
|
+
```js
|
|
84
|
+
import { EmbedBuilder } from "discord.fixed.js";
|
|
90
85
|
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
const embed = new EmbedBuilder()
|
|
87
|
+
.title("Hello")
|
|
88
|
+
.description("This is an embed")
|
|
89
|
+
.color("Blue");
|
|
90
|
+
```
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
### Components
|
|
95
93
|
|
|
96
|
-
|
|
94
|
+
```js
|
|
95
|
+
import { Button, Row, Select } from "discord.fixed.js";
|
|
97
96
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
• Prefix command execution is handled internally
|
|
101
|
-
• Users never write messageCreate listeners
|
|
102
|
-
• The framework owns execution & safety
|
|
97
|
+
const button = new Button().label("Click Me").style("Primary").id("btn_1");
|
|
98
|
+
const row = new Row().add(button);
|
|
103
99
|
|
|
104
|
-
|
|
100
|
+
const select = new Select().id("menu_1").placeholder("Choose").option("Option 1", "1");
|
|
101
|
+
```
|
|
105
102
|
|
|
106
|
-
|
|
103
|
+
### Message Extensions
|
|
107
104
|
|
|
108
|
-
|
|
105
|
+
```js
|
|
106
|
+
// Works on discord.js Message object
|
|
107
|
+
message.reply("Hello!");
|
|
108
|
+
message.ping();
|
|
109
|
+
message.deleteSafe();
|
|
110
|
+
message.edit("New content");
|
|
111
|
+
```
|
|
109
112
|
|
|
110
|
-
|
|
113
|
+
---
|
|
111
114
|
|
|
112
|
-
|
|
115
|
+
## ⚙️ How discord.fixed.js Works
|
|
113
116
|
|
|
114
|
-
|
|
117
|
+
- Provides a **lightweight Bot class** for Discord.js
|
|
118
|
+
- Builders make component, embed, and button creation easier
|
|
119
|
+
- Adds safe, convenient **message prototype helpers**
|
|
120
|
+
- Fully compatible with **CJS, ESM, and TypeScript**, including `.d.ts` support
|
|
115
121
|
|
|
116
|
-
|
|
122
|
+
You focus on logic — the library handles convenience utilities.
|
|
117
123
|
|
|
118
124
|
---
|
|
119
125
|
|
|
120
126
|
## 🧠 Philosophy
|
|
121
127
|
|
|
122
128
|
discord.fixed.js exists to:
|
|
123
|
-
• Remove Discord.js boilerplate
|
|
124
|
-
• Enforce clean architecture
|
|
125
|
-
• Stay small but powerful
|
|
126
|
-
• Be beginner-friendly and scalable
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
- Remove repetitive boilerplate
|
|
131
|
+
- Provide clean, safe builders for Discord.js
|
|
132
|
+
- Stay small but powerful
|
|
133
|
+
- Be beginner-friendly and scalable
|
|
129
134
|
|
|
130
135
|
---
|
|
131
136
|
|
package/package.json
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discord.fixed.js",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "src/export.
|
|
3
|
+
"version": "1.2.4",
|
|
4
|
+
"description": "A wrapper for Discord developers",
|
|
5
|
+
"main": "src/export.cjs",
|
|
6
|
+
"module": "src/export.mjs",
|
|
7
|
+
"types": "src/export.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./src/export.mjs",
|
|
11
|
+
"require": "./src/export.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
6
15
|
"scripts": {
|
|
16
|
+
"build:types": "tsc --declaration --emitDeclarationOnly --allowJs --outDir dist/types",
|
|
17
|
+
"build": "npm run build:types",
|
|
7
18
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
19
|
},
|
|
9
20
|
"keywords": [
|
|
10
21
|
"discord.js",
|
|
11
22
|
"discord",
|
|
12
|
-
"discord.fixed.js"
|
|
23
|
+
"discord.fixed.js",
|
|
24
|
+
"discord library"
|
|
13
25
|
],
|
|
14
26
|
"author": "synorix.dev",
|
|
15
27
|
"license": "MIT",
|
|
16
|
-
"
|
|
28
|
+
"devDependencies": {
|
|
17
29
|
"@types/node": "^22.13.11",
|
|
18
|
-
"
|
|
19
|
-
|
|
30
|
+
"typescript": "^5.2.2"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"discord.js": "^14.25.1"
|
|
20
34
|
}
|
|
21
35
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const {
|
|
2
|
+
ButtonBuilder: DjsButtonBuilder,
|
|
3
|
+
ActionRowBuilder: DjsActionRowBuilder,
|
|
4
|
+
ButtonStyle,
|
|
5
|
+
StringSelectMenuBuilder
|
|
6
|
+
} = require("discord.js");
|
|
7
|
+
|
|
8
|
+
const STYLE_MAP = {
|
|
9
|
+
blue: ButtonStyle.Primary,
|
|
10
|
+
primary: ButtonStyle.Primary,
|
|
11
|
+
green: ButtonStyle.Success,
|
|
12
|
+
success: ButtonStyle.Success,
|
|
13
|
+
red: ButtonStyle.Danger,
|
|
14
|
+
danger: ButtonStyle.Danger,
|
|
15
|
+
gray: ButtonStyle.Secondary,
|
|
16
|
+
grey: ButtonStyle.Secondary,
|
|
17
|
+
secondary: ButtonStyle.Secondary,
|
|
18
|
+
link: ButtonStyle.Link
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
class Button extends DjsButtonBuilder {
|
|
22
|
+
constructor(data) { super(data); }
|
|
23
|
+
label(value) { this.setLabel(String(value)); return this; }
|
|
24
|
+
id(value) { this.setCustomId(String(value)); return this; }
|
|
25
|
+
style(value) {
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
const key = value.toLowerCase();
|
|
28
|
+
this.setStyle(STYLE_MAP[key] ?? ButtonStyle[value]);
|
|
29
|
+
} else {
|
|
30
|
+
this.setStyle(value);
|
|
31
|
+
}
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
url(value) { this.setURL(String(value)); return this; }
|
|
35
|
+
emoji(value) { this.setEmoji(value); return this; }
|
|
36
|
+
disabled(value = true) { this.setDisabled(value); return this; }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class Row extends DjsActionRowBuilder {
|
|
40
|
+
constructor(data) { super(data); }
|
|
41
|
+
add(component) { this.addComponents(component); return this; }
|
|
42
|
+
components(arr = []) { this.addComponents(arr); return this; }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
class Select extends StringSelectMenuBuilder {
|
|
46
|
+
id(i) { return this.setCustomId(i); }
|
|
47
|
+
placeholder(t) { return this.setPlaceholder(t); }
|
|
48
|
+
option(l, v, d, e) { return this.addOptions({ label: l, value: v, description: d, emoji: e }); }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = { Button, Row, Select };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonBuilder as DjsButtonBuilder,
|
|
3
|
+
ActionRowBuilder as DjsActionRowBuilder,
|
|
4
|
+
ButtonStyle,
|
|
5
|
+
StringSelectMenuBuilder
|
|
6
|
+
} from "discord.js";
|
|
7
|
+
|
|
8
|
+
const STYLE_MAP = {
|
|
9
|
+
blue: ButtonStyle.Primary,
|
|
10
|
+
primary: ButtonStyle.Primary,
|
|
11
|
+
green: ButtonStyle.Success,
|
|
12
|
+
success: ButtonStyle.Success,
|
|
13
|
+
red: ButtonStyle.Danger,
|
|
14
|
+
danger: ButtonStyle.Danger,
|
|
15
|
+
gray: ButtonStyle.Secondary,
|
|
16
|
+
grey: ButtonStyle.Secondary,
|
|
17
|
+
secondary: ButtonStyle.Secondary,
|
|
18
|
+
link: ButtonStyle.Link
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
class Button extends DjsButtonBuilder {
|
|
22
|
+
constructor(data) { super(data); }
|
|
23
|
+
label(value) { this.setLabel(String(value)); return this; }
|
|
24
|
+
id(value) { this.setCustomId(String(value)); return this; }
|
|
25
|
+
style(value) {
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
const key = value.toLowerCase();
|
|
28
|
+
this.setStyle(STYLE_MAP[key] ?? ButtonStyle[value]);
|
|
29
|
+
} else {
|
|
30
|
+
this.setStyle(value);
|
|
31
|
+
}
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
url(value) { this.setURL(String(value)); return this; }
|
|
35
|
+
emoji(value) { this.setEmoji(value); return this; }
|
|
36
|
+
disabled(value = true) { this.setDisabled(value); return this; }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class Row extends DjsActionRowBuilder {
|
|
40
|
+
constructor(data) { super(data); }
|
|
41
|
+
add(component) { this.addComponents(component); return this; }
|
|
42
|
+
components(arr = []) { this.addComponents(arr); return this; }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
class Select extends StringSelectMenuBuilder {
|
|
46
|
+
id(i) { return this.setCustomId(i); }
|
|
47
|
+
placeholder(t) { return this.setPlaceholder(t); }
|
|
48
|
+
option(l, v, d, e) { return this.addOptions({ label: l, value: v, description: d, emoji: e }); }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { Button, Row, Select };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonBuilder as DjsButtonBuilder,
|
|
3
|
+
ActionRowBuilder as DjsActionRowBuilder,
|
|
4
|
+
ButtonStyle,
|
|
5
|
+
StringSelectMenuBuilder
|
|
6
|
+
} from "discord.js";
|
|
7
|
+
|
|
8
|
+
const STYLE_MAP: Record<string, ButtonStyle> = {
|
|
9
|
+
blue: ButtonStyle.Primary,
|
|
10
|
+
primary: ButtonStyle.Primary,
|
|
11
|
+
green: ButtonStyle.Success,
|
|
12
|
+
success: ButtonStyle.Success,
|
|
13
|
+
red: ButtonStyle.Danger,
|
|
14
|
+
danger: ButtonStyle.Danger,
|
|
15
|
+
gray: ButtonStyle.Secondary,
|
|
16
|
+
grey: ButtonStyle.Secondary,
|
|
17
|
+
secondary: ButtonStyle.Secondary,
|
|
18
|
+
link: ButtonStyle.Link
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export class Button extends DjsButtonBuilder {
|
|
22
|
+
constructor(data?: Partial<DjsButtonBuilder>) {
|
|
23
|
+
super(data);
|
|
24
|
+
}
|
|
25
|
+
label(value: string) { this.setLabel(value); return this; }
|
|
26
|
+
id(value: string) { this.setCustomId(value); return this; }
|
|
27
|
+
style(value: string | ButtonStyle) {
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
const key = value.toLowerCase();
|
|
30
|
+
this.setStyle(STYLE_MAP[key] ?? ButtonStyle[value as keyof typeof ButtonStyle]);
|
|
31
|
+
} else {
|
|
32
|
+
this.setStyle(value);
|
|
33
|
+
}
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
url(value: string) { this.setURL(value); return this; }
|
|
37
|
+
emoji(value: string | object) { this.setEmoji(value as any); return this; }
|
|
38
|
+
disabled(value = true) { this.setDisabled(value); return this; }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class Row extends DjsActionRowBuilder {
|
|
42
|
+
constructor(data?: Partial<DjsActionRowBuilder>) { super(data); }
|
|
43
|
+
add(component: any) { this.addComponents(component); return this; }
|
|
44
|
+
components(arr: any[] = []) { this.addComponents(arr); return this; }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class Select extends StringSelectMenuBuilder {
|
|
48
|
+
id(i: string) { return this.setCustomId(i); }
|
|
49
|
+
placeholder(t: string) { return this.setPlaceholder(t); }
|
|
50
|
+
option(l: string, v: string, d?: string, e?: any) { return this.addOptions({ label: l, value: v, description: d, emoji: e }); }
|
|
51
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const {
|
|
2
|
+
ContainerBuilder,
|
|
3
|
+
TextDisplayBuilder,
|
|
4
|
+
SeparatorBuilder,
|
|
5
|
+
SeparatorSpacingSize,
|
|
6
|
+
ActionRowBuilder,
|
|
7
|
+
ButtonBuilder,
|
|
8
|
+
StringSelectMenuBuilder,
|
|
9
|
+
MediaGalleryBuilder,
|
|
10
|
+
MediaGalleryItemBuilder
|
|
11
|
+
} = require("discord.js");
|
|
12
|
+
|
|
13
|
+
class ComponentBuilder extends ContainerBuilder {
|
|
14
|
+
constructor() { super(); }
|
|
15
|
+
|
|
16
|
+
addText(input) {
|
|
17
|
+
if (typeof input === "string") {
|
|
18
|
+
this.addTextDisplayComponents(new TextDisplayBuilder().setContent(input));
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
if (input instanceof TextDisplayBuilder) {
|
|
22
|
+
this.addTextDisplayComponents(input);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
addSeparator(spacing = "Small") {
|
|
29
|
+
const map = { Small: SeparatorSpacingSize.Small, Large: SeparatorSpacingSize.Large };
|
|
30
|
+
this.addSeparatorComponents(new SeparatorBuilder().setSpacing(map[spacing] || SeparatorSpacingSize.Small));
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
addButtons(...buttons) {
|
|
35
|
+
this.addActionRowComponents(new ActionRowBuilder().addComponents(buttons));
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
addSelect(select) {
|
|
40
|
+
this.addActionRowComponents(new ActionRowBuilder().addComponents(select));
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
addMedia(items = []) {
|
|
45
|
+
const gallery = new MediaGalleryBuilder();
|
|
46
|
+
for (const item of items) {
|
|
47
|
+
if (typeof item === "string") gallery.addItems(new MediaGalleryItemBuilder().setURL(item));
|
|
48
|
+
else if (item instanceof MediaGalleryItemBuilder) gallery.addItems(item);
|
|
49
|
+
}
|
|
50
|
+
this.addMediaGalleryComponents(gallery);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const text = content => new TextDisplayBuilder().setContent(content);
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
ComponentBuilder,
|
|
59
|
+
text,
|
|
60
|
+
TextDisplayBuilder,
|
|
61
|
+
SeparatorBuilder,
|
|
62
|
+
ActionRowBuilder,
|
|
63
|
+
ButtonBuilder,
|
|
64
|
+
StringSelectMenuBuilder,
|
|
65
|
+
MediaGalleryBuilder,
|
|
66
|
+
MediaGalleryItemBuilder
|
|
67
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContainerBuilder,
|
|
3
|
+
TextDisplayBuilder,
|
|
4
|
+
SeparatorBuilder,
|
|
5
|
+
SeparatorSpacingSize,
|
|
6
|
+
ActionRowBuilder,
|
|
7
|
+
ButtonBuilder,
|
|
8
|
+
StringSelectMenuBuilder,
|
|
9
|
+
MediaGalleryBuilder,
|
|
10
|
+
MediaGalleryItemBuilder
|
|
11
|
+
} from "discord.js";
|
|
12
|
+
|
|
13
|
+
class ComponentBuilder extends ContainerBuilder {
|
|
14
|
+
constructor() { super(); }
|
|
15
|
+
|
|
16
|
+
addText(input) {
|
|
17
|
+
if (typeof input === "string") {
|
|
18
|
+
this.addTextDisplayComponents(new TextDisplayBuilder().setContent(input));
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
if (input instanceof TextDisplayBuilder) {
|
|
22
|
+
this.addTextDisplayComponents(input);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
addSeparator(spacing = "Small") {
|
|
29
|
+
const map = { Small: SeparatorSpacingSize.Small, Large: SeparatorSpacingSize.Large };
|
|
30
|
+
this.addSeparatorComponents(new SeparatorBuilder().setSpacing(map[spacing] || SeparatorSpacingSize.Small));
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
addButtons(...buttons) {
|
|
35
|
+
this.addActionRowComponents(new ActionRowBuilder().addComponents(buttons));
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
addSelect(select) {
|
|
40
|
+
this.addActionRowComponents(new ActionRowBuilder().addComponents(select));
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
addMedia(items = []) {
|
|
45
|
+
const gallery = new MediaGalleryBuilder();
|
|
46
|
+
for (const item of items) {
|
|
47
|
+
if (typeof item === "string") gallery.addItems(new MediaGalleryItemBuilder().setURL(item));
|
|
48
|
+
else if (item instanceof MediaGalleryItemBuilder) gallery.addItems(item);
|
|
49
|
+
}
|
|
50
|
+
this.addMediaGalleryComponents(gallery);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const text = content => new TextDisplayBuilder().setContent(content);
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
ComponentBuilder,
|
|
59
|
+
text,
|
|
60
|
+
TextDisplayBuilder,
|
|
61
|
+
SeparatorBuilder,
|
|
62
|
+
ActionRowBuilder,
|
|
63
|
+
ButtonBuilder,
|
|
64
|
+
StringSelectMenuBuilder,
|
|
65
|
+
MediaGalleryBuilder,
|
|
66
|
+
MediaGalleryItemBuilder
|
|
67
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContainerBuilder,
|
|
3
|
+
TextDisplayBuilder,
|
|
4
|
+
SeparatorBuilder,
|
|
5
|
+
SeparatorSpacingSize,
|
|
6
|
+
ActionRowBuilder,
|
|
7
|
+
ButtonBuilder,
|
|
8
|
+
StringSelectMenuBuilder,
|
|
9
|
+
MediaGalleryBuilder,
|
|
10
|
+
MediaGalleryItemBuilder
|
|
11
|
+
} from "discord.js";
|
|
12
|
+
|
|
13
|
+
export class ComponentBuilder extends ContainerBuilder {
|
|
14
|
+
constructor() { super(); }
|
|
15
|
+
|
|
16
|
+
addText(input: string | TextDisplayBuilder) {
|
|
17
|
+
if (typeof input === "string") {
|
|
18
|
+
this.addTextDisplayComponents(new TextDisplayBuilder().setContent(input));
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
if (input instanceof TextDisplayBuilder) {
|
|
22
|
+
this.addTextDisplayComponents(input);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
addSeparator(spacing: "Small" | "Large" = "Small") {
|
|
29
|
+
const map: Record<string, SeparatorSpacingSize> = {
|
|
30
|
+
Small: SeparatorSpacingSize.Small,
|
|
31
|
+
Large: SeparatorSpacingSize.Large
|
|
32
|
+
};
|
|
33
|
+
this.addSeparatorComponents(new SeparatorBuilder().setSpacing(map[spacing] || SeparatorSpacingSize.Small));
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
addButtons(...buttons: any[]) {
|
|
38
|
+
this.addActionRowComponents(new ActionRowBuilder().addComponents(buttons));
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
addSelect(select: any) {
|
|
43
|
+
this.addActionRowComponents(new ActionRowBuilder().addComponents(select));
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
addMedia(items: (string | MediaGalleryItemBuilder)[] = []) {
|
|
48
|
+
const gallery = new MediaGalleryBuilder();
|
|
49
|
+
for (const item of items) {
|
|
50
|
+
if (typeof item === "string") gallery.addItems(new MediaGalleryItemBuilder().setURL(item));
|
|
51
|
+
else if (item instanceof MediaGalleryItemBuilder) gallery.addItems(item);
|
|
52
|
+
}
|
|
53
|
+
this.addMediaGalleryComponents(gallery);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const text = (content: string) => new TextDisplayBuilder().setContent(content);
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
TextDisplayBuilder,
|
|
62
|
+
SeparatorBuilder,
|
|
63
|
+
ActionRowBuilder,
|
|
64
|
+
ButtonBuilder,
|
|
65
|
+
StringSelectMenuBuilder,
|
|
66
|
+
MediaGalleryBuilder,
|
|
67
|
+
MediaGalleryItemBuilder
|
|
68
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { EmbedBuilder: DjsEmbedBuilder } = require("discord.js");
|
|
2
|
+
|
|
3
|
+
class EmbedBuilder extends DjsEmbedBuilder {
|
|
4
|
+
constructor(data) { super(data); }
|
|
5
|
+
title(value) { this.setTitle(String(value)); return this; }
|
|
6
|
+
addTitle(value) { this.setTitle(String(value)); return this; }
|
|
7
|
+
description(value) { this.setDescription(String(value)); return this; }
|
|
8
|
+
addDescription(value) { this.setDescription(String(value)); return this; }
|
|
9
|
+
color(value) { this.setColor(value); return this; }
|
|
10
|
+
addColor(value) { this.setColor(value); return this; }
|
|
11
|
+
author(name, iconURL, url) { this.setAuthor({ name, iconURL, url }); return this; }
|
|
12
|
+
addAuthor(name, iconURL, url) { this.setAuthor({ name, iconURL, url }); return this; }
|
|
13
|
+
footer(text, iconURL) { this.setFooter({ text, iconURL }); return this; }
|
|
14
|
+
addFooter(text, iconURL) { this.setFooter({ text, iconURL }); return this; }
|
|
15
|
+
thumbnail(url) { this.setThumbnail(url); return this; }
|
|
16
|
+
addThumbnail(url) { this.setThumbnail(url); return this; }
|
|
17
|
+
image(url) { this.setImage(url); return this; }
|
|
18
|
+
addImage(url) { this.setImage(url); return this; }
|
|
19
|
+
field(name, value, inline = false) { this.addFields({ name: String(name), value: String(value), inline }); return this; }
|
|
20
|
+
addField(name, value, inline = false) { this.addFields({ name: String(name), value: String(value), inline }); return this; }
|
|
21
|
+
fields(arr = []) { this.addFields(arr.map(f => ({ name: String(f.name), value: String(f.value), inline: !!f.inline }))); return this; }
|
|
22
|
+
timestamp(value = Date.now()) { this.setTimestamp(value); return this; }
|
|
23
|
+
addTime(value = Date.now()) { this.setTimestamp(value); return this; }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = EmbedBuilder;
|