@stelliajs/framework 1.0.4 → 1.0.6
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 +61 -9
- package/dist/client/StelliaUtils.js +1 -1
- package/dist/utils/files.js +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -5,6 +5,39 @@
|
|
|
5
5
|
StelliaJS is built using Discord JS V14 and TypeScript. It allows you to quickly set up a new bot with a simple and complete architecture.
|
|
6
6
|
A CLI is currently being developed and will soon be available for even greater convenience.
|
|
7
7
|
|
|
8
|
+
## Architecture
|
|
9
|
+
Recommended architecture for StelliaJS project.
|
|
10
|
+
```
|
|
11
|
+
.
|
|
12
|
+
├── dist // Build folder
|
|
13
|
+
├── src/
|
|
14
|
+
│ ├── commands/
|
|
15
|
+
│ │ ├── contextMenus/
|
|
16
|
+
│ │ │ └── mute.ts
|
|
17
|
+
│ │ └── slash/
|
|
18
|
+
│ │ ├── moderation // You can create folders, everything is loaded recursively
|
|
19
|
+
│ │ │ ├── ban.ts
|
|
20
|
+
│ │ │ └── mute.ts
|
|
21
|
+
│ │ └── ping.ts
|
|
22
|
+
│ ├── events/
|
|
23
|
+
│ │ ├── ready.ts
|
|
24
|
+
│ │ └── interactionCreate.ts
|
|
25
|
+
│ ├── interactions/
|
|
26
|
+
│ │ ├── autoCompletes/
|
|
27
|
+
│ │ │ └── song.ts
|
|
28
|
+
│ │ ├── buttons/
|
|
29
|
+
│ │ │ └── colorChoice.ts
|
|
30
|
+
│ │ ├── modals/
|
|
31
|
+
│ │ │ └── form.ts
|
|
32
|
+
│ │ └── selectMenus/
|
|
33
|
+
│ │ └── settings.ts
|
|
34
|
+
│ ├── environment.d.ts
|
|
35
|
+
│ └── index.ts
|
|
36
|
+
├── .env
|
|
37
|
+
├── package.json
|
|
38
|
+
├── package-lock.json
|
|
39
|
+
└── tsconfig.json
|
|
40
|
+
```
|
|
8
41
|
## Examples
|
|
9
42
|
|
|
10
43
|
### Simple client
|
|
@@ -24,25 +57,25 @@ const client = new StelliaClient({
|
|
|
24
57
|
partials: [Partials.Message, Partials.GuildMember]
|
|
25
58
|
}, {
|
|
26
59
|
autoCompletes: {
|
|
27
|
-
directoryPath: "./
|
|
60
|
+
directoryPath: "./interactions/autoCompletes"
|
|
28
61
|
},
|
|
29
62
|
buttons: {
|
|
30
|
-
directoryPath: "./
|
|
63
|
+
directoryPath: "./interactions/buttons"
|
|
31
64
|
},
|
|
32
65
|
commands: {
|
|
33
|
-
directoryPath: "./
|
|
66
|
+
directoryPath: "./commands/slash"
|
|
34
67
|
},
|
|
35
68
|
contextMenus: {
|
|
36
|
-
directoryPath: "./
|
|
69
|
+
directoryPath: "./commands/contextMenus"
|
|
37
70
|
},
|
|
38
71
|
events: {
|
|
39
|
-
directoryPath: "./
|
|
72
|
+
directoryPath: "./events"
|
|
40
73
|
},
|
|
41
74
|
modals: {
|
|
42
|
-
directoryPath: "./
|
|
75
|
+
directoryPath: "./interactions/modals"
|
|
43
76
|
},
|
|
44
77
|
selectMenus: {
|
|
45
|
-
directoryPath: "./
|
|
78
|
+
directoryPath: "./interactions/selectMenus"
|
|
46
79
|
}
|
|
47
80
|
});
|
|
48
81
|
|
|
@@ -51,6 +84,7 @@ await client.connect(process.env.TOKEN);
|
|
|
51
84
|
|
|
52
85
|
### Simple event
|
|
53
86
|
|
|
87
|
+
#### Ready event
|
|
54
88
|
```js
|
|
55
89
|
import { type StelliaClient, type EventStructure } from "@stelliajs/framework";
|
|
56
90
|
import { Events } from "discord.js";
|
|
@@ -67,17 +101,35 @@ export default {
|
|
|
67
101
|
} as EventStructure;
|
|
68
102
|
```
|
|
69
103
|
|
|
104
|
+
#### InteractionCreate event
|
|
105
|
+
```js
|
|
106
|
+
import { type StelliaClient, type EventStructure } from "@stelliajs/framework";
|
|
107
|
+
import { Events, type Interaction } from "discord.js";
|
|
108
|
+
|
|
109
|
+
export default {
|
|
110
|
+
data: {
|
|
111
|
+
name: Events.InteractionCreate,
|
|
112
|
+
once: false
|
|
113
|
+
},
|
|
114
|
+
async execute(client: StelliaClient<true>, interaction: Interaction) {
|
|
115
|
+
if (interaction.inCachedGuild()) {
|
|
116
|
+
await client.handleInteraction(interaction); // Automatic interaction handling
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} as EventStructure;
|
|
120
|
+
```
|
|
121
|
+
|
|
70
122
|
### Simple command
|
|
71
123
|
|
|
72
124
|
```js
|
|
73
|
-
import { type CommandStructure, type StelliaClient } from "@stelliajs/framework";
|
|
125
|
+
import { type CommandStructure, ephemeralFollowUpResponse, type StelliaClient } from "@stelliajs/framework";
|
|
74
126
|
import { type ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
|
75
127
|
|
|
76
128
|
export default {
|
|
77
129
|
data: new SlashCommandBuilder()
|
|
78
130
|
.setName("ping"),
|
|
79
131
|
async execute(client: StelliaClient, interaction: ChatInputCommandInteraction<"cached">) { // All interactions are cached
|
|
80
|
-
await interaction
|
|
132
|
+
await ephemeralFollowUpResponse(interaction, "Pong!", true); // Response is ephemeral and deleted after 60 seconds
|
|
81
133
|
}
|
|
82
134
|
} as CommandStructure;
|
|
83
135
|
```
|
|
@@ -108,7 +108,7 @@ export class StelliaUtils {
|
|
|
108
108
|
handleSelectMenuInteraction = async (interaction) => {
|
|
109
109
|
try {
|
|
110
110
|
const interactionSelectMenu = interaction;
|
|
111
|
-
const selectMenu = this.client.managers.
|
|
111
|
+
const selectMenu = this.client.managers.selectMenus?.get(interactionSelectMenu.customId);
|
|
112
112
|
if (!selectMenu)
|
|
113
113
|
return;
|
|
114
114
|
await selectMenu.execute(this.client, interactionSelectMenu);
|
package/dist/utils/files.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readdirSync, statSync } from "fs";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
export const requiredFiles = async (directoryPath) => {
|
|
5
5
|
const collection = new Collection();
|
|
6
|
-
const filesPath = getAllFilesPath(directoryPath).filter((file) =>
|
|
6
|
+
const filesPath = getAllFilesPath(directoryPath).filter((file) => !file.endsWith(".d.ts") && (file.endsWith(".js") || file.endsWith(".ts")));
|
|
7
7
|
for (const filePath of filesPath) {
|
|
8
8
|
const data = await loadInteraction(filePath);
|
|
9
9
|
collection.set(data.data.name, data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stelliajs/framework",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
},
|
|
13
13
|
"author": "Tweenty_",
|
|
14
14
|
"license": "ISC",
|
|
15
|
+
"description": "A framework for simplify the creation of discord bots",
|
|
16
|
+
"keywords": ["discord", "bot", "discordjs", "typescript", "framework"],
|
|
15
17
|
"dependencies": {
|
|
16
18
|
"discord-api-types": "^0.37.92",
|
|
17
19
|
"discord.js": "^14.15.3"
|