discord.fixed.js 1.2.3 → 1.2.5
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 +86 -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/VoiceChannelStatus.js +10 -0
- package/src/Builders/index.d.ts +81 -0
- package/src/Client/Bot.cjs +32 -0
- package/src/Client/Bot.js +14 -43
- 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.js +6 -1
- 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,145 @@
|
|
|
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
|
+
- `VoiceChannelStatus` — simple way to set Voice Channel Status
|
|
18
|
+
- `EmbedBuilder` — simplified embed construction
|
|
19
|
+
- `ComponentBuilder` — build complex component layouts
|
|
20
|
+
- `Button`, `Row`, `Select` — quick action row and button handling
|
|
21
|
+
- Message prototype extensions:
|
|
22
|
+
- `.reply()`, `.edit()`, `.deleteSafe()`, `.ping()`
|
|
23
|
+
- Aliases and constants (`I`, `Flags`, `Perms`, `Channels`, etc.)
|
|
24
|
+
- Fully compatible with **CJS, ESM, and TypeScript**
|
|
25
|
+
- Includes `.d.ts` typings for TS projects
|
|
23
26
|
|
|
24
27
|
---
|
|
25
28
|
|
|
26
29
|
## 📦 Installation
|
|
27
30
|
|
|
31
|
+
```bash
|
|
28
32
|
npm install discord.fixed.js
|
|
33
|
+
```
|
|
29
34
|
|
|
30
35
|
---
|
|
31
36
|
|
|
32
37
|
## 🚀 Quick Start
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
### CommonJS
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
const { Bot, EmbedBuilder, Button } = require("discord.fixed.js");
|
|
35
43
|
|
|
36
44
|
const client = new Bot({
|
|
37
45
|
intents: "all",
|
|
38
|
-
|
|
39
|
-
commandsPath: "./commands",
|
|
40
|
-
eventsPath: "./events"
|
|
46
|
+
owners: ["YOUR_USER_ID"]
|
|
41
47
|
});
|
|
42
48
|
|
|
43
49
|
client.start("YOUR_BOT_TOKEN");
|
|
50
|
+
```
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
### Modern JS / ESM
|
|
46
53
|
|
|
47
|
-
|
|
54
|
+
```js
|
|
55
|
+
import { Bot, EmbedBuilder, Button } from "discord.fixed.js";
|
|
48
56
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
│ └─ hello.js
|
|
54
|
-
│
|
|
55
|
-
├─ events/
|
|
56
|
-
│ └─ ready.js
|
|
57
|
-
│
|
|
58
|
-
└─ index.js
|
|
57
|
+
const client = new Bot({
|
|
58
|
+
intents: "all",
|
|
59
|
+
owners: ["YOUR_USER_ID"]
|
|
60
|
+
});
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
client.start("YOUR_BOT_TOKEN");
|
|
63
|
+
```
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
### TypeScript
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
```ts
|
|
68
|
+
import { Bot, EmbedBuilder, Button } from "discord.fixed.js";
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
message.reply("Pong!");
|
|
71
|
-
}
|
|
72
|
-
};
|
|
70
|
+
const client = new Bot({
|
|
71
|
+
intents: "all",
|
|
72
|
+
owners: ["YOUR_USER_ID"]
|
|
73
|
+
});
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
client.start("YOUR_BOT_TOKEN");
|
|
76
|
+
```
|
|
76
77
|
|
|
77
78
|
---
|
|
78
79
|
|
|
79
|
-
##
|
|
80
|
+
## 🔧 Builders & Utilities
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
### Embeds
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
once: true,
|
|
86
|
-
execute(client) {
|
|
87
|
-
console.log(`${client.user.tag} is online`);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
84
|
+
```js
|
|
85
|
+
import { EmbedBuilder } from "discord.fixed.js";
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
const embed = new EmbedBuilder()
|
|
88
|
+
.title("Hello")
|
|
89
|
+
.description("This is an embed")
|
|
90
|
+
.color("Blue");
|
|
91
|
+
```
|
|
93
92
|
|
|
94
|
-
|
|
93
|
+
### VoiceChannelStatus
|
|
95
94
|
|
|
96
|
-
|
|
95
|
+
```js
|
|
96
|
+
const { VoiceChannelStatus } = require("discord.fixed.js");
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
• Prefix command execution is handled internally
|
|
101
|
-
• Users never write messageCreate listeners
|
|
102
|
-
• The framework owns execution & safety
|
|
98
|
+
VoiceChannelStatus().set("text", "emoji", "12341234")
|
|
99
|
+
```
|
|
103
100
|
|
|
104
|
-
|
|
101
|
+
### Components
|
|
105
102
|
|
|
106
|
-
|
|
103
|
+
```js
|
|
104
|
+
import { Button, Row, Select } from "discord.fixed.js";
|
|
105
|
+
|
|
106
|
+
const button = new Button().label("Click Me").style("Primary").id("btn_1");
|
|
107
|
+
const row = new Row().add(button);
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
const select = new Select().id("menu_1").placeholder("Choose").option("Option 1", "1");
|
|
110
|
+
```
|
|
109
111
|
|
|
110
|
-
|
|
112
|
+
### Message Extensions
|
|
111
113
|
|
|
112
|
-
|
|
114
|
+
```js
|
|
115
|
+
// Works on discord.js Message object
|
|
116
|
+
message.reply("Hello!");
|
|
117
|
+
message.ping();
|
|
118
|
+
message.deleteSafe();
|
|
119
|
+
message.edit("New content");
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## ⚙️ How discord.fixed.js Works
|
|
113
125
|
|
|
114
|
-
|
|
126
|
+
- Provides a **lightweight Bot class** for Discord.js
|
|
127
|
+
- Builders make component, embed, and button creation easier
|
|
128
|
+
- Adds safe, convenient **message prototype helpers**
|
|
129
|
+
- Fully compatible with **CJS, ESM, and TypeScript**, including `.d.ts` support
|
|
115
130
|
|
|
116
|
-
|
|
131
|
+
You focus on logic — the library handles convenience utilities.
|
|
117
132
|
|
|
118
133
|
---
|
|
119
134
|
|
|
120
135
|
## 🧠 Philosophy
|
|
121
136
|
|
|
122
137
|
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
138
|
|
|
128
|
-
|
|
139
|
+
- Remove repetitive boilerplate
|
|
140
|
+
- Provide clean, safe builders for Discord.js
|
|
141
|
+
- Stay small but powerful
|
|
142
|
+
- Be beginner-friendly and scalable
|
|
129
143
|
|
|
130
144
|
---
|
|
131
145
|
|
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.5",
|
|
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;
|