@stelliajs/framework 1.4.5 → 1.5.0
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/.prettierrc +8 -0
- package/README.md +44 -38
- package/dist/client/StelliaClient.js +11 -7
- package/dist/client/StelliaUtils.d.ts +1 -1
- package/dist/client/StelliaUtils.js +31 -7
- package/dist/managers/AutoCompleteManager.d.ts +1 -1
- package/dist/managers/BaseManager.d.ts +1 -1
- package/dist/managers/ButtonManager.d.ts +1 -1
- package/dist/managers/CommandManager.d.ts +1 -1
- package/dist/managers/ContextMenuManager.d.ts +1 -1
- package/dist/managers/EventManager.d.ts +1 -1
- package/dist/managers/EventManager.js +2 -1
- package/dist/managers/ModalManager.d.ts +1 -1
- package/dist/managers/SelectMenuManager.d.ts +1 -1
- package/dist/structures/Interaction.d.ts +20 -6
- package/dist/typescript/types.d.ts +1 -1
- package/dist/utils/files.js +4 -3
- package/dist/utils/translation.js +3 -3
- package/eslint.config.mjs +68 -0
- package/package.json +40 -27
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -6,7 +6,9 @@ StelliaJS is built using Discord JS V14 and TypeScript. It allows you to quickly
|
|
|
6
6
|
A CLI is available to help you set up a project with StelliaJS : [link to the CLI](https://github.com/StelliaJS/cli)
|
|
7
7
|
|
|
8
8
|
## Architecture
|
|
9
|
+
|
|
9
10
|
Recommended architecture for StelliaJS project.
|
|
11
|
+
|
|
10
12
|
```
|
|
11
13
|
.
|
|
12
14
|
├── dist // Build folder
|
|
@@ -49,45 +51,48 @@ Recommended architecture for StelliaJS project.
|
|
|
49
51
|
### Simple client with environment
|
|
50
52
|
|
|
51
53
|
```js
|
|
52
|
-
import { StelliaClient } from "@stelliajs/framework";
|
|
53
54
|
import { GatewayIntentBits, Partials } from "discord.js";
|
|
55
|
+
import { StelliaClient } from "@stelliajs/framework";
|
|
54
56
|
|
|
55
|
-
const client = new StelliaClient(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
57
|
+
const client = new StelliaClient(
|
|
58
|
+
{
|
|
59
|
+
intents: [
|
|
60
|
+
GatewayIntentBits.Guilds,
|
|
61
|
+
GatewayIntentBits.GuildMessages,
|
|
62
|
+
GatewayIntentBits.MessageContent,
|
|
63
|
+
GatewayIntentBits.GuildMembers
|
|
64
|
+
],
|
|
65
|
+
partials: [Partials.Message, Partials.GuildMember]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
managers: {
|
|
69
|
+
autoCompletes: {
|
|
70
|
+
directoryPath: "./interactions/autoCompletes"
|
|
71
|
+
},
|
|
72
|
+
buttons: {
|
|
73
|
+
directoryPath: "./interactions/buttons"
|
|
74
|
+
},
|
|
75
|
+
commands: {
|
|
76
|
+
directoryPath: "./commands/slash"
|
|
77
|
+
},
|
|
78
|
+
contextMenus: {
|
|
79
|
+
directoryPath: "./commands/contextMenus"
|
|
80
|
+
},
|
|
81
|
+
events: {
|
|
82
|
+
directoryPath: "./events"
|
|
83
|
+
},
|
|
84
|
+
modals: {
|
|
85
|
+
directoryPath: "./interactions/modals"
|
|
86
|
+
},
|
|
87
|
+
selectMenus: {
|
|
88
|
+
directoryPath: "./interactions/selectMenus"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
environment: {
|
|
92
|
+
areGuildsConfigurationEnabled: true
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
);
|
|
91
96
|
|
|
92
97
|
await client.connect(process.env.TOKEN);
|
|
93
98
|
```
|
|
@@ -95,6 +100,7 @@ await client.connect(process.env.TOKEN);
|
|
|
95
100
|
### Simple event
|
|
96
101
|
|
|
97
102
|
#### Ready event with environment
|
|
103
|
+
|
|
98
104
|
```js
|
|
99
105
|
import { type StelliaClient, type EventStructure } from "@stelliajs/framework";
|
|
100
106
|
import { Events } from "discord.js";
|
|
@@ -113,6 +119,7 @@ export default {
|
|
|
113
119
|
```
|
|
114
120
|
|
|
115
121
|
#### InteractionCreate event with environment
|
|
122
|
+
|
|
116
123
|
```js
|
|
117
124
|
import { type StelliaClient, type EventStructure } from "@stelliajs/framework";
|
|
118
125
|
import { Events, type Interaction } from "discord.js";
|
|
@@ -147,7 +154,6 @@ export default {
|
|
|
147
154
|
} as CommandStructure;
|
|
148
155
|
```
|
|
149
156
|
|
|
150
|
-
|
|
151
157
|
## Help
|
|
152
158
|
|
|
153
159
|
If you need help with the framework you can open an issue.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Client } from "discord.js";
|
|
2
|
-
import { AutoCompleteManager, ButtonManager, CommandManager, ContextMenuManager, EventManager, ModalManager, SelectMenuManager } from "../managers/index.js";
|
|
3
|
-
import { StelliaUtils } from "./index.js";
|
|
4
|
-
import path from "path";
|
|
5
1
|
import * as fs from "node:fs";
|
|
2
|
+
import path from "path";
|
|
6
3
|
import { pathToFileURL } from "url";
|
|
4
|
+
import { Client } from "discord.js";
|
|
5
|
+
import { StelliaUtils } from "./index.js";
|
|
6
|
+
import { AutoCompleteManager, ButtonManager, CommandManager, ContextMenuManager, EventManager, ModalManager, SelectMenuManager } from "../managers/index.js";
|
|
7
7
|
import { logger } from "../utils/logger.js";
|
|
8
8
|
export class StelliaClient extends Client {
|
|
9
9
|
utils;
|
|
@@ -58,7 +58,7 @@ export class StelliaClient extends Client {
|
|
|
58
58
|
await this.utils.initializeCommands();
|
|
59
59
|
};
|
|
60
60
|
getGuildsConfiguration = async () => {
|
|
61
|
-
const chosenEnvironment = process.argv.find(arg => arg.startsWith("--config"))?.split("=")[1];
|
|
61
|
+
const chosenEnvironment = process.argv.find((arg) => arg.startsWith("--config"))?.split("=")[1];
|
|
62
62
|
if (!chosenEnvironment) {
|
|
63
63
|
throw new Error("Environment not provided");
|
|
64
64
|
}
|
|
@@ -75,7 +75,9 @@ export class StelliaClient extends Client {
|
|
|
75
75
|
return reject(new Error("Invalid environment"));
|
|
76
76
|
}
|
|
77
77
|
const environmentData = environments[chosenEnvironment];
|
|
78
|
-
const environmentPath = environmentData.production
|
|
78
|
+
const environmentPath = environmentData.production
|
|
79
|
+
? StelliaClient.convertFilePathToProduction(environmentData.file)
|
|
80
|
+
: environmentData.file;
|
|
79
81
|
const environmentAbsolutePath = pathToFileURL(path.join(srcPath, "..", environmentPath)).href;
|
|
80
82
|
const environmentFile = await import(environmentAbsolutePath);
|
|
81
83
|
resolve(environmentFile.environment);
|
|
@@ -94,7 +96,9 @@ export class StelliaClient extends Client {
|
|
|
94
96
|
};
|
|
95
97
|
areManagersLoaded = () => {
|
|
96
98
|
const managers = Object.values(this.managers);
|
|
97
|
-
return managers.length === 0
|
|
99
|
+
return managers.length === 0
|
|
100
|
+
? true
|
|
101
|
+
: managers.every((manager) => manager.isManagerLoaded());
|
|
98
102
|
};
|
|
99
103
|
static convertFilePathToProduction = (filePath) => {
|
|
100
104
|
return filePath.replace("src", "dist").replace(".ts", ".js");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type StelliaClient } from "./index.js";
|
|
2
1
|
import { type Interaction } from "discord.js";
|
|
2
|
+
import { type StelliaClient } from "./index.js";
|
|
3
3
|
import { type GuildConfiguration } from "../typescript/index.js";
|
|
4
4
|
export declare class StelliaUtils {
|
|
5
5
|
readonly client: StelliaClient;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationCommandType, REST, Routes } from "discord.js";
|
|
1
|
+
import { ApplicationCommandType, MessageFlags, REST, Routes } from "discord.js";
|
|
2
2
|
import { DISCORD_API_VERSION } from "../constants/index.js";
|
|
3
3
|
import { InteractionType } from "../typescript/index.js";
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
@@ -17,7 +17,8 @@ export class StelliaUtils {
|
|
|
17
17
|
[InteractionType.SelectMenu, this.handleSelectMenuInteraction]
|
|
18
18
|
]);
|
|
19
19
|
if (this.client.environment.areGuildsConfigurationEnabled) {
|
|
20
|
-
this.client
|
|
20
|
+
this.client
|
|
21
|
+
.getGuildsConfiguration()
|
|
21
22
|
.then((guildsConfiguration) => {
|
|
22
23
|
this.guildsConfiguration = guildsConfiguration;
|
|
23
24
|
logger.success("Guilds configuration loaded successfully for interactions");
|
|
@@ -32,7 +33,9 @@ export class StelliaUtils {
|
|
|
32
33
|
if (this.client.isReady()) {
|
|
33
34
|
const rest = new REST({ version: DISCORD_API_VERSION }).setToken(this.client.token);
|
|
34
35
|
try {
|
|
35
|
-
await rest.put(Routes.applicationCommands(this.client.user.id), {
|
|
36
|
+
await rest.put(Routes.applicationCommands(this.client.user.id), {
|
|
37
|
+
body: applicationCommands
|
|
38
|
+
});
|
|
36
39
|
logger.success("Application commands registered successfully");
|
|
37
40
|
}
|
|
38
41
|
catch (error) {
|
|
@@ -92,9 +95,13 @@ export class StelliaUtils {
|
|
|
92
95
|
const buttonManager = this.client.managers.buttons;
|
|
93
96
|
if (!buttonManager)
|
|
94
97
|
return;
|
|
95
|
-
const button = buttonManager.getByCustomId(buttonInteraction.customId) ||
|
|
98
|
+
const button = buttonManager.getByCustomId(buttonInteraction.customId) ||
|
|
99
|
+
buttonManager.getByRegex(buttonInteraction.customId);
|
|
96
100
|
if (!button)
|
|
97
101
|
return;
|
|
102
|
+
if (button.data.reply.autoDefer && !buttonInteraction.deferred) {
|
|
103
|
+
await buttonInteraction.deferReply({ flags: button.data.reply.ephemeral ? MessageFlags.Ephemeral : undefined });
|
|
104
|
+
}
|
|
98
105
|
if (this.client.environment.areGuildsConfigurationEnabled) {
|
|
99
106
|
const buttonWithGuildConfiguration = button;
|
|
100
107
|
const guildConfiguration = this.getGuildConfiguration(buttonInteraction.guildId);
|
|
@@ -115,9 +122,12 @@ export class StelliaUtils {
|
|
|
115
122
|
const commandManager = this.client.managers.commands;
|
|
116
123
|
if (!commandManager)
|
|
117
124
|
return;
|
|
118
|
-
|
|
125
|
+
const command = commandManager.getByCustomId(commandInteraction.commandName);
|
|
119
126
|
if (!command)
|
|
120
127
|
return;
|
|
128
|
+
if (command.data.reply.autoDefer && !commandInteraction.deferred) {
|
|
129
|
+
await commandInteraction.deferReply({ flags: command.data.reply.ephemeral ? MessageFlags.Ephemeral : undefined });
|
|
130
|
+
}
|
|
121
131
|
if (this.client.environment.areGuildsConfigurationEnabled) {
|
|
122
132
|
const commandWithGuildConfiguration = command;
|
|
123
133
|
const guildConfiguration = this.getGuildConfiguration(commandInteraction.guildId);
|
|
@@ -154,9 +164,13 @@ export class StelliaUtils {
|
|
|
154
164
|
const modalManager = this.client.managers.modals;
|
|
155
165
|
if (!modalManager)
|
|
156
166
|
return;
|
|
157
|
-
const modal = modalManager.getByCustomId(modalInteraction.customId) ||
|
|
167
|
+
const modal = modalManager.getByCustomId(modalInteraction.customId) ||
|
|
168
|
+
modalManager.getByRegex(modalInteraction.customId);
|
|
158
169
|
if (!modal)
|
|
159
170
|
return;
|
|
171
|
+
if (modal.data.reply.autoDefer && !modalInteraction.deferred) {
|
|
172
|
+
await modalInteraction.deferReply({ flags: modal.data.reply.ephemeral ? MessageFlags.Ephemeral : undefined });
|
|
173
|
+
}
|
|
160
174
|
if (this.client.environment.areGuildsConfigurationEnabled) {
|
|
161
175
|
const modalWithGuildConfiguration = modal;
|
|
162
176
|
const guildConfiguration = this.getGuildConfiguration(modalInteraction.guildId);
|
|
@@ -177,9 +191,13 @@ export class StelliaUtils {
|
|
|
177
191
|
const selectMenuManager = this.client.managers.selectMenus;
|
|
178
192
|
if (!selectMenuManager)
|
|
179
193
|
return;
|
|
180
|
-
const selectMenu = selectMenuManager.getByCustomId(selectMenuInteraction.customId) ||
|
|
194
|
+
const selectMenu = selectMenuManager.getByCustomId(selectMenuInteraction.customId) ||
|
|
195
|
+
selectMenuManager.getByRegex(selectMenuInteraction.customId);
|
|
181
196
|
if (!selectMenu)
|
|
182
197
|
return;
|
|
198
|
+
if (selectMenu.data.reply.autoDefer && !selectMenuInteraction.deferred) {
|
|
199
|
+
await selectMenuInteraction.deferReply({ flags: selectMenu.data.reply.ephemeral ? MessageFlags.Ephemeral : undefined });
|
|
200
|
+
}
|
|
183
201
|
if (this.client.environment.areGuildsConfigurationEnabled) {
|
|
184
202
|
const selectMenuWithGuildConfiguration = selectMenu;
|
|
185
203
|
const guildConfiguration = this.getGuildConfiguration(selectMenuInteraction.guildId);
|
|
@@ -202,6 +220,9 @@ export class StelliaUtils {
|
|
|
202
220
|
const messageContextMenu = contextMenuManager.getByCustomId(interaction.commandName);
|
|
203
221
|
if (!messageContextMenu)
|
|
204
222
|
return;
|
|
223
|
+
if (messageContextMenu.data.reply.autoDefer && !interaction.deferred) {
|
|
224
|
+
await interaction.deferReply({ flags: messageContextMenu.data.reply.ephemeral ? MessageFlags.Ephemeral : undefined });
|
|
225
|
+
}
|
|
205
226
|
if (this.client.environment.areGuildsConfigurationEnabled) {
|
|
206
227
|
const messageContextMenuWithGuildConfiguration = messageContextMenu;
|
|
207
228
|
const guildConfiguration = this.getGuildConfiguration(interaction.guildId);
|
|
@@ -224,6 +245,9 @@ export class StelliaUtils {
|
|
|
224
245
|
const userContextMenu = contextMenuManager.getByCustomId(interaction.commandName);
|
|
225
246
|
if (!userContextMenu)
|
|
226
247
|
return;
|
|
248
|
+
if (userContextMenu.data.reply.autoDefer && !interaction.deferred) {
|
|
249
|
+
await interaction.deferReply({ flags: userContextMenu.data.reply.ephemeral ? MessageFlags.Ephemeral : undefined });
|
|
250
|
+
}
|
|
227
251
|
if (this.client.environment.areGuildsConfigurationEnabled) {
|
|
228
252
|
const userContextMenuWithGuildConfiguration = userContextMenu;
|
|
229
253
|
const guildConfiguration = this.getGuildConfiguration(interaction.guildId);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection } from "discord.js";
|
|
2
2
|
import { type StelliaClient } from "../client/index.js";
|
|
3
3
|
import { BaseManager } from "./index.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type InteractionCustomId, type StructureCustomId } from "../typescript/index.js";
|
|
5
5
|
export declare class AutoCompleteManager extends BaseManager {
|
|
6
6
|
private interactions;
|
|
7
7
|
constructor(client: StelliaClient, directory: string);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection } from "discord.js";
|
|
2
2
|
import { type StelliaClient } from "../client/index.js";
|
|
3
|
-
import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
|
|
4
3
|
import { type AnyInteractionStructure } from "../structures/index.js";
|
|
4
|
+
import { type InteractionCustomId, type StructureCustomId } from "../typescript/index.js";
|
|
5
5
|
export interface ManagerOptions {
|
|
6
6
|
directoryPath: string;
|
|
7
7
|
}
|
|
@@ -2,7 +2,7 @@ import { Collection } from "discord.js";
|
|
|
2
2
|
import { type StelliaClient } from "../client/index.js";
|
|
3
3
|
import { BaseManager } from "./index.js";
|
|
4
4
|
import { type ButtonStructure } from "../structures/index.js";
|
|
5
|
-
import { type
|
|
5
|
+
import { type InteractionCustomId, type StructureCustomId } from "../typescript/index.js";
|
|
6
6
|
export declare class ButtonManager extends BaseManager {
|
|
7
7
|
interactions: Collection<StructureCustomId, ButtonStructure>;
|
|
8
8
|
constructor(client: StelliaClient, directory: string);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection } from "discord.js";
|
|
2
2
|
import { type StelliaClient } from "../client/index.js";
|
|
3
3
|
import { BaseManager } from "./index.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type InteractionCustomId, type StructureCustomId } from "../typescript/index.js";
|
|
5
5
|
export declare class CommandManager extends BaseManager {
|
|
6
6
|
private interactions;
|
|
7
7
|
constructor(client: StelliaClient, directory: string);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection } from "discord.js";
|
|
2
2
|
import { type StelliaClient } from "../client/index.js";
|
|
3
3
|
import { BaseManager } from "./index.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type InteractionCustomId, type StructureCustomId } from "../typescript/index.js";
|
|
5
5
|
export declare class ContextMenuManager extends BaseManager {
|
|
6
6
|
private interactions;
|
|
7
7
|
constructor(client: StelliaClient, directory: string);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection } from "discord.js";
|
|
2
2
|
import { type StelliaClient } from "../client/index.js";
|
|
3
3
|
import { BaseManager } from "./index.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type InteractionCustomId, type StructureCustomId } from "../typescript/index.js";
|
|
5
5
|
export declare class EventManager extends BaseManager {
|
|
6
6
|
private interactions;
|
|
7
7
|
private guildsConfiguration;
|
|
@@ -8,7 +8,8 @@ export class EventManager extends BaseManager {
|
|
|
8
8
|
constructor(client, directoryPath) {
|
|
9
9
|
super(client, directoryPath);
|
|
10
10
|
if (this.client.environment.areGuildsConfigurationEnabled) {
|
|
11
|
-
this.client
|
|
11
|
+
this.client
|
|
12
|
+
.getGuildsConfiguration()
|
|
12
13
|
.then((guildsConfiguration) => {
|
|
13
14
|
this.guildsConfiguration = guildsConfiguration;
|
|
14
15
|
logger.success("Guilds configuration loaded successfully for event");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection } from "discord.js";
|
|
2
2
|
import { type StelliaClient } from "../client/index.js";
|
|
3
3
|
import { BaseManager } from "./index.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type InteractionCustomId, type StructureCustomId } from "../typescript/index.js";
|
|
5
5
|
export declare class ModalManager extends BaseManager {
|
|
6
6
|
private interactions;
|
|
7
7
|
constructor(client: StelliaClient, directory: string);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection } from "discord.js";
|
|
2
2
|
import { type StelliaClient } from "../client/index.js";
|
|
3
3
|
import { BaseManager } from "./index.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type InteractionCustomId, type StructureCustomId } from "../typescript/index.js";
|
|
5
5
|
export declare class SelectMenuManager extends BaseManager {
|
|
6
6
|
private interactions;
|
|
7
7
|
constructor(client: StelliaClient, directory: string);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { type AnySelectMenuInteraction, type AutocompleteInteraction, type Awaitable, type ButtonInteraction, type ChatInputCommandInteraction, type ContextMenuCommandType, type MessageContextMenuCommandInteraction, type ModalSubmitInteraction, type SlashCommandOptionsOnlyBuilder, type UserContextMenuCommandInteraction } from "discord.js";
|
|
1
|
+
import { type AnySelectMenuInteraction, type AutocompleteInteraction, type Awaitable, type ButtonInteraction, type ChatInputCommandInteraction, type ContextMenuCommandType, type MessageContextMenuCommandInteraction, type ModalSubmitInteraction, type SlashCommandOptionsOnlyBuilder, type SlashCommandSubcommandsOnlyBuilder, type UserContextMenuCommandInteraction } from "discord.js";
|
|
2
2
|
import { type StelliaClient } from "../client/index.js";
|
|
3
|
-
import { type GuildConfigurationType } from "../typescript/index.js";
|
|
4
3
|
import { type EventStructure } from "./Event.js";
|
|
5
|
-
|
|
4
|
+
import { type GuildConfigurationType } from "../typescript/index.js";
|
|
5
|
+
export interface AutoCompleteStructureWithGuildConfiguration extends Omit<MessageInteractionStructure, "data"> {
|
|
6
|
+
data: Omit<MessageDataStructure, "reply">;
|
|
6
7
|
execute(client: StelliaClient, guildConfiguration: GuildConfigurationType, interaction: AutocompleteInteraction<"cached">): Awaitable<unknown>;
|
|
7
8
|
}
|
|
8
|
-
export interface AutoCompleteStructureWithoutGuildConfiguration extends MessageInteractionStructure {
|
|
9
|
+
export interface AutoCompleteStructureWithoutGuildConfiguration extends Omit<MessageInteractionStructure, "data"> {
|
|
10
|
+
data: Omit<MessageDataStructure, "reply">;
|
|
9
11
|
execute(client: StelliaClient, interaction: AutocompleteInteraction<"cached">): Awaitable<unknown>;
|
|
10
12
|
}
|
|
11
13
|
export type AutoCompleteStructure = AutoCompleteStructureWithGuildConfiguration | AutoCompleteStructureWithoutGuildConfiguration;
|
|
@@ -46,7 +48,11 @@ export interface SelectMenuStructureWithoutGuildConfiguration extends MessageInt
|
|
|
46
48
|
export type SelectMenuStructure = SelectMenuStructureWithGuildConfiguration | SelectMenuStructureWithoutGuildConfiguration;
|
|
47
49
|
export type AnyInteractionStructure = AutoCompleteStructure | ButtonStructure | CommandStructure | ContextMenuStructure | EventStructure | ModalStructure | SelectMenuStructure;
|
|
48
50
|
interface CommandInteractionStructure {
|
|
49
|
-
data:
|
|
51
|
+
data: CommandDataStructure;
|
|
52
|
+
}
|
|
53
|
+
interface CommandDataStructure {
|
|
54
|
+
command: SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandsOnlyBuilder;
|
|
55
|
+
reply: ReplyStructure<true> | ReplyStructure<false>;
|
|
50
56
|
}
|
|
51
57
|
interface ContextMenuInteractionStructure {
|
|
52
58
|
data: ContextMenuDataStructure;
|
|
@@ -54,6 +60,7 @@ interface ContextMenuInteractionStructure {
|
|
|
54
60
|
interface ContextMenuDataStructure {
|
|
55
61
|
name: string;
|
|
56
62
|
type: ContextMenuCommandType;
|
|
63
|
+
reply: ReplyStructure<true> | ReplyStructure<false>;
|
|
57
64
|
}
|
|
58
65
|
interface MessageInteractionStructure {
|
|
59
66
|
data: MessageDataStructure;
|
|
@@ -61,5 +68,12 @@ interface MessageInteractionStructure {
|
|
|
61
68
|
interface MessageDataStructure {
|
|
62
69
|
name: string | RegExp;
|
|
63
70
|
once: boolean;
|
|
64
|
-
|
|
71
|
+
reply: ReplyStructure<true> | ReplyStructure<false>;
|
|
72
|
+
}
|
|
73
|
+
type ReplyStructure<T extends boolean = false> = T extends true ? {
|
|
74
|
+
autoDefer: true;
|
|
75
|
+
ephemeral: boolean;
|
|
76
|
+
} : {
|
|
77
|
+
autoDefer: false;
|
|
78
|
+
};
|
|
65
79
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AutoCompleteManager, type ButtonManager, type CommandManager, type ContextMenuManager, type EventManager, type ModalManager, type SelectMenuManager } from "../managers/index.js";
|
|
2
1
|
import { type Locale, type Snowflake } from "discord.js";
|
|
2
|
+
import { type AutoCompleteManager, type ButtonManager, type CommandManager, type ContextMenuManager, type EventManager, type ModalManager, type SelectMenuManager } from "../managers/index.js";
|
|
3
3
|
export type StructureCustomId = string | RegExp;
|
|
4
4
|
export type InteractionCustomId = string;
|
|
5
5
|
export declare enum InteractionType {
|
package/dist/utils/files.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Collection } from "discord.js";
|
|
2
1
|
import { readdirSync, statSync } from "fs";
|
|
3
2
|
import path from "path";
|
|
3
|
+
import { Collection } from "discord.js";
|
|
4
4
|
export const requiredFiles = async (directoryPath) => {
|
|
5
5
|
const collection = new Collection();
|
|
6
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
|
-
const
|
|
9
|
-
|
|
8
|
+
const interactionData = await loadInteraction(filePath);
|
|
9
|
+
const interactionName = "command" in interactionData.data ? interactionData.data.command.name : interactionData.data.name;
|
|
10
|
+
collection.set(interactionName, interactionData);
|
|
10
11
|
}
|
|
11
12
|
return collection;
|
|
12
13
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { changeLanguage, t } from "i18next";
|
|
2
2
|
export const translateToLocale = async (locale, key, args) => {
|
|
3
|
-
await
|
|
4
|
-
return
|
|
3
|
+
await changeLanguage(locale);
|
|
4
|
+
return t(key, { interpolation: { escapeValue: false }, returnObjects: true, ...args });
|
|
5
5
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import ts from "typescript-eslint";
|
|
3
|
+
import importPlugin from "eslint-plugin-import";
|
|
4
|
+
import prettierConfig from "eslint-config-prettier";
|
|
5
|
+
|
|
6
|
+
export default ts.config(
|
|
7
|
+
js.configs.recommended,
|
|
8
|
+
ts.configs.recommended,
|
|
9
|
+
importPlugin.flatConfigs.recommended,
|
|
10
|
+
importPlugin.flatConfigs.typescript,
|
|
11
|
+
prettierConfig,
|
|
12
|
+
{
|
|
13
|
+
languageOptions: {
|
|
14
|
+
parserOptions: {
|
|
15
|
+
project: "./tsconfig.json",
|
|
16
|
+
sourceType: "module",
|
|
17
|
+
ecmaVersion: "latest"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
"import/namespace": "off",
|
|
22
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
23
|
+
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
|
|
24
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
25
|
+
"import/order": [
|
|
26
|
+
"error",
|
|
27
|
+
{
|
|
28
|
+
groups: [
|
|
29
|
+
"builtin",
|
|
30
|
+
"external",
|
|
31
|
+
"internal",
|
|
32
|
+
["parent", "sibling", "index"],
|
|
33
|
+
"object",
|
|
34
|
+
"type"
|
|
35
|
+
],
|
|
36
|
+
pathGroups: [
|
|
37
|
+
{
|
|
38
|
+
pattern: "@/**",
|
|
39
|
+
group: "internal"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
pathGroupsExcludedImportTypes: ["builtin"],
|
|
43
|
+
alphabetize: {
|
|
44
|
+
order: "asc",
|
|
45
|
+
caseInsensitive: true
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"import/newline-after-import": ["error", { count: 1 }],
|
|
50
|
+
"import/no-unresolved": "error",
|
|
51
|
+
"import/no-duplicates": "error",
|
|
52
|
+
"no-console": "off",
|
|
53
|
+
"no-var": "error",
|
|
54
|
+
"prefer-const": "error"
|
|
55
|
+
},
|
|
56
|
+
settings: {
|
|
57
|
+
"import/resolver": {
|
|
58
|
+
typescript: {
|
|
59
|
+
alwaysTryTypes: true,
|
|
60
|
+
project: "./tsconfig.json"
|
|
61
|
+
},
|
|
62
|
+
node: {
|
|
63
|
+
extensions: [".js", ".ts"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
);
|
package/package.json
CHANGED
|
@@ -1,29 +1,42 @@
|
|
|
1
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
|
-
|
|
2
|
+
"name": "@stelliajs/framework",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"lint": "eslint src --ext .ts",
|
|
8
|
+
"format": "prettier --write .",
|
|
9
|
+
"build": "tsc && tsc-alias"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/stelliajs/framework.git"
|
|
14
|
+
},
|
|
15
|
+
"author": "Tweenty_",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"description": "A framework for simplify the creation of discord bots",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"discord",
|
|
20
|
+
"bot",
|
|
21
|
+
"discordjs",
|
|
22
|
+
"typescript",
|
|
23
|
+
"framework"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"discord.js": "^14.21.0",
|
|
27
|
+
"i18next": "^25.3.2",
|
|
28
|
+
"log-symbols": "^7.0.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@eslint/js": "^9.33.0",
|
|
32
|
+
"discord-api-types": "^0.38.18",
|
|
33
|
+
"eslint-config-prettier": "^10.1.8",
|
|
34
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
35
|
+
"eslint-plugin-import": "^2.32.0",
|
|
36
|
+
"prettier": "^3.6.2",
|
|
37
|
+
"tsc-alias": "^1.8.16",
|
|
38
|
+
"typescript-eslint": "^8.39.0"
|
|
39
|
+
},
|
|
40
|
+
"type": "module",
|
|
41
|
+
"packageManager": "pnpm@10.14.0"
|
|
29
42
|
}
|