@guardbot/framework 1.0.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/README.md ADDED
@@ -0,0 +1,106 @@
1
+ ![Framework](https://raw.githubusercontent.com/guardbotgg/.github/master/assets/framework.png)
2
+
3
+ <br/>
4
+ <p align="center">
5
+ <img src="https://raw.githubusercontent.com/guardbotgg/assets/master/made-with-typescript.svg" alt="badge" />
6
+ <img src="https://raw.githubusercontent.com/guardbotgg/assets/master/made-with-love.svg" alt="badge" />
7
+ </p>
8
+ <br/>
9
+
10
+ # @guardbot/framework
11
+ > **A simple framework made for building discord bots with discord.js.**
12
+
13
+ ## **ðŸ“Ķ Installation**
14
+ ```sh
15
+ $ npm install @guardbot/framework # via npm
16
+ $ yarn add @guardbot/framework # yarn
17
+ $ pnpm add @guardbot/framework # pnpm
18
+ ```
19
+
20
+ ## **âœĻ Features**
21
+ - Easy to use.
22
+ - Beginner friendly.
23
+ - Supports Intellisense.
24
+
25
+ ## **ðŸŠī Quick Start**
26
+
27
+ ### 1. Initialize the Client
28
+ Create your main entry file (e.g., `index.ts`) and initialize the `FrameworkClient`.
29
+
30
+ ```typescript
31
+ import { FrameworkClient } from '@guardbot/framework';
32
+ import { GatewayIntentBits } from 'discord.js';
33
+ import path from 'path';
34
+
35
+ const client = new FrameworkClient({
36
+ clientOptions: {
37
+ intents: [
38
+ GatewayIntentBits.Guilds,
39
+ GatewayIntentBits.GuildMessages,
40
+ GatewayIntentBits.MessageContent
41
+ ]
42
+ },
43
+ rootDir: path.join(__dirname),
44
+ registerOnStart: true,
45
+ prefix: '!',
46
+ });
47
+
48
+ client.login('DISCORD_BOT_TOKEN');
49
+ ```
50
+
51
+ ### 2. Create a Slash Command
52
+ Create a file in your commands directory (e.g., `src/commands/general/ping.ts`).
53
+
54
+ ```typescript
55
+ import { SlashCommand } from '@guardbot/framework';
56
+
57
+ export default SlashCommand({
58
+ name: 'ping',
59
+ description: 'Replies with Pong!',
60
+ commandScope: 'default',
61
+ cooldown: 5000,
62
+
63
+ async execute(client, interaction) {
64
+ await interaction.reply({ content: `Pong! 🏓 (${client.ws.ping}ms)` });
65
+ },
66
+ });
67
+ ```
68
+
69
+ ### 3. Create a Message Command
70
+ Create a file for prefix-based commands (e.g., `src/commands/general/ping.ts`).
71
+
72
+ ```typescript
73
+ import { MessageCommand } from '@guardbot/framework';
74
+
75
+ export default MessageCommand({
76
+ name: 'ping',
77
+ description: 'Replies with Pong!',
78
+ aliases: ['latency'],
79
+ cooldown: 5000,
80
+
81
+ async execute(client, message, args) {
82
+ await message.reply({ content: `Pong! 🏓 (${client.ws.ping}ms)` });
83
+ },
84
+ });
85
+ ```
86
+
87
+ ### 4. Create an Event Listener
88
+ Create an event file (e.g., `src/listeners/client/ready.ts`).
89
+
90
+ ```typescript
91
+ import { Listener } from '@guardbot/framework';
92
+
93
+ export default Listener({
94
+ name: 'clientReady',
95
+ once: true,
96
+
97
+ async execute(client) {
98
+ console.log(`Logged in as ${client.user.tag}!`);
99
+ console.log(`Loaded ${client.commands.size} commands.`);
100
+ return true;
101
+ }
102
+ })
103
+ ```
104
+
105
+ ## **🎐 Support Server**
106
+ <a href="https://discord.gg/invite/GaczkwfgV9"><img src="https://invidget.switchblade.xyz/GaczkwfgV9" alt="Discord"></a>
@@ -0,0 +1,284 @@
1
+ import * as discord_js from 'discord.js';
2
+ import { Client, PermissionResolvable, InteractionContextType, ApplicationIntegrationType, LocalizationMap, ApplicationCommandOptionData, ChatInputCommandInteraction, AutocompleteInteraction, Message, ContextMenuCommandInteraction, CommandInteraction, PermissionsString, Interaction, Collection, ClientEvents, ModalSubmitInteraction, ClientOptions, MessageCollectorOptions, InteractionCollectorOptions } from 'discord.js';
3
+ export { SlashCommandAttachmentOption as AttachmentOption, SlashCommandBooleanOption as BooleanOption, SlashCommandChannelOption as ChannelOption, SlashCommandIntegerOption as IntegerOption, SlashCommandMentionableOption as MentionableOption, SlashCommandNumberOption as NumberOption, SlashCommandRoleOption as RoleOption, SlashCommandOptionsOnlyBuilder as SlashCommandOptionsBuilder, SlashCommandStringOption as StringOption, SlashCommandSubcommandBuilder as SubcommandBuilder, SlashCommandSubcommandGroupBuilder as SubcommandGroupBuilder } from 'discord.js';
4
+ import EventEmitter from 'events';
5
+
6
+ declare class FrameworkClient<Ready extends boolean = boolean> extends Client<Ready> {
7
+ rootDir: string;
8
+ prefix: string;
9
+ developers: string[];
10
+ constructor(frameworkOptions: FrameworkClientOptions);
11
+ start(token: string): Promise<void>;
12
+ }
13
+
14
+ interface BaseCommandOptions {
15
+ /** The Name of the Command */
16
+ name: string;
17
+ /** The Description of the Command */
18
+ description: string;
19
+ /** The Type of the Command */
20
+ commandType: 'Slash' | 'Message' | 'ContextMessage' | 'ContextUser';
21
+ /** The Cooldown of the Command (in MS) */
22
+ cooldown?: number;
23
+ /** Permissions required by the User to use this Command */
24
+ memberPermissions?: PermissionResolvable;
25
+ /** Permissions required by the Application Client to execute this Command */
26
+ clientPermissions?: PermissionResolvable;
27
+ /** Whether this command is Disbaled */
28
+ disabled?: boolean;
29
+ }
30
+ interface BaseAppCommandOptions extends BaseCommandOptions {
31
+ /**
32
+ * Where this Application Command can be registered
33
+ * - `default` - In both Guild & Global Commands
34
+ * - `guild` - In only Guild Commands
35
+ * - `global` - In only Global Commands
36
+ */
37
+ commandScope: 'default' | 'guild' | 'global';
38
+ /**
39
+ * Where this Application Command can be used
40
+ * - `Guild` | `(0)` - In Guilds
41
+ * - `BotDM` | `(1)` - In Application DMs
42
+ * - `PrivateChannel` | `(2)` - In Other's DMs & Group DMs
43
+ */
44
+ commandContexts?: (InteractionContextType | keyof typeof InteractionContextType)[];
45
+ /**
46
+ * Where this Application Command can be integrated
47
+ * - `GuildInstall` | `(0)` - App is installable to servers
48
+ * - `UserInstall` | `(1)` - App is installable to users
49
+ */
50
+ integrationTypes?: (ApplicationIntegrationType | keyof typeof ApplicationIntegrationType)[];
51
+ /** The Name Localizations of the Command */
52
+ nameLocalizations?: LocalizationMap;
53
+ /** The Description Localizations of the Command */
54
+ descriptionLocalizations?: LocalizationMap;
55
+ }
56
+ interface MessageCommandOptions$1 extends BaseCommandOptions {
57
+ commandType: 'Message';
58
+ /** The Aliases of the Command */
59
+ aliases?: string[];
60
+ /** The Usage of the Command */
61
+ usage?: string;
62
+ /** Whether the command is Developer Only */
63
+ devOnly?: boolean;
64
+ /**
65
+ * Where this Application Command can be used
66
+ * - `BotDM` - In Application DMs
67
+ * - `Guild` - In Guilds
68
+ */
69
+ contexts?: ('BotDM' | 'Guild')[];
70
+ execute: (client: FrameworkClient<true>, message: Message, args: string[]) => Promise<unknown>;
71
+ }
72
+ interface SlashCommandOptions$1 extends BaseAppCommandOptions {
73
+ commandType: 'Slash';
74
+ /** The Application Command Options of this Command */
75
+ options?: ApplicationCommandOptionData[];
76
+ execute: (client: FrameworkClient<true>, interaction: ChatInputCommandInteraction) => Promise<unknown>;
77
+ autocomplete?: (client: FrameworkClient<true>, interaction: AutocompleteInteraction) => Promise<unknown>;
78
+ }
79
+ interface ContextCommandOptions extends BaseAppCommandOptions {
80
+ commandType: 'ContextMessage' | 'ContextUser';
81
+ execute: (client: FrameworkClient<true>, interaction: ContextMenuCommandInteraction) => Promise<unknown>;
82
+ }
83
+ interface BaseCommand {
84
+ id: string;
85
+ filepath: string;
86
+ disabled: boolean;
87
+ }
88
+ type FrameworkSlashCommand = SlashCommandOptions$1 & BaseCommand;
89
+ type FrameworkContextCommand = ContextCommandOptions & BaseCommand;
90
+ type FrameworkMessageCommand = MessageCommandOptions$1 & BaseCommand & {
91
+ devOnly: boolean;
92
+ contexts: ('BotDM' | 'Guild')[];
93
+ };
94
+ type FrameworkCommand = (FrameworkSlashCommand | FrameworkMessageCommand | FrameworkContextCommand);
95
+ interface CommandModuleHandler {
96
+ onCooldown?: (context: Message | CommandInteraction, command: FrameworkCommand, expirationTime: Date) => any;
97
+ onMemberPermissions?: (context: Message, command: FrameworkCommand, missingPermissions: PermissionsString[]) => any;
98
+ onClientPermissions?: (context: Message | CommandInteraction, command: FrameworkCommand, missingPermissions: PermissionsString[]) => any;
99
+ MessageCommandInterceptor?: (message: Message) => Promise<boolean>;
100
+ InteractionCommandInterceptor?: (interaction: Interaction) => Promise<boolean>;
101
+ }
102
+ type CommandHandlerName = keyof Omit<CommandModuleHandler, 'MessageCommandInterceptor' | 'InteractionCommandInterceptor'>;
103
+
104
+ /**
105
+ * @class AutocompleteModule
106
+ * @fires AutocompleteModule#execute
107
+ * @fires AutocompleteModule#success
108
+ * @fires AutocompleteModule#error
109
+ * @fires AutocompleteModule#unknown
110
+ */
111
+ declare class AutocompleteModule extends EventEmitter {
112
+ private client;
113
+ constructor(client: FrameworkClient);
114
+ load(filepath: string, reload?: boolean): Promise<boolean>;
115
+ loadAll(): Promise<void>;
116
+ reload(id: string): void;
117
+ private unload;
118
+ private _handleInteraction;
119
+ }
120
+
121
+ declare class ListenerModule {
122
+ private client;
123
+ constructor(client: FrameworkClient);
124
+ load(filepath: string, reload?: boolean): Promise<boolean>;
125
+ loadAll(): Promise<void>;
126
+ reload(id: string): void;
127
+ private unload;
128
+ }
129
+
130
+ /**
131
+ * @class CommandsModule
132
+ * @fires CommandsModule#execute
133
+ * @fires CommandsModule#success
134
+ * @fires CommandsModule#error
135
+ * @fires CommandsModule#unknown
136
+ */
137
+ declare class CommandsModule extends EventEmitter {
138
+ private client;
139
+ private handler;
140
+ constructor(client: FrameworkClient);
141
+ setHandler<K extends CommandHandlerName>(key: K, callback: NonNullable<CommandModuleHandler[K]>): NonNullable<CommandModuleHandler[K]>;
142
+ setMessageInterceptor(callback: (message: Message) => Promise<boolean>): (message: Message) => Promise<boolean>;
143
+ setInteractionInterceptor(callback: (interaction: Interaction) => Promise<boolean>): (interaction: Interaction) => Promise<boolean>;
144
+ load(filepath: string, reload?: boolean): Promise<boolean>;
145
+ loadAll(): Promise<void>;
146
+ reload(id: string): void;
147
+ private unload;
148
+ registerOnStart(guildIds: string[], commands?: Collection<string, FrameworkCommand>): Promise<void>;
149
+ publishGlobal(commands?: Collection<string, FrameworkCommand>): Promise<false | Collection<string, discord_js.ApplicationCommand<{
150
+ guild: discord_js.GuildResolvable;
151
+ }>>>;
152
+ publishGuild(guildId: string, commands?: Collection<string, FrameworkCommand>): Promise<void>;
153
+ private _handleMessage;
154
+ private _handleInteraction;
155
+ private _getCommandId;
156
+ private _getCommandData;
157
+ }
158
+
159
+ interface ListenerOptions<T extends keyof ClientEvents = keyof ClientEvents> {
160
+ /** Name of the Listener. */
161
+ name: T;
162
+ /** Wheather to execute the function only Once. */
163
+ once?: boolean;
164
+ /** Whether the Listener is disabled. */
165
+ disabled?: boolean;
166
+ /** Handles the execution of the Listener */
167
+ execute: (...args: ClientEvents[T]) => Promise<boolean>;
168
+ }
169
+ interface FrameworkListener<T extends keyof ClientEvents = keyof ClientEvents> {
170
+ id: string;
171
+ filepath: string;
172
+ name: T;
173
+ once: boolean;
174
+ disabled: boolean;
175
+ execute: (...args: ClientEvents[T]) => Promise<boolean>;
176
+ _execute?: (...args: ClientEvents[T]) => Promise<boolean>;
177
+ }
178
+
179
+ interface FrameworkClientOptions {
180
+ clientOptions: ClientOptions;
181
+ rootDir?: string;
182
+ developers?: string[];
183
+ prefix?: string;
184
+ registerOnStart?: boolean;
185
+ guildsToRegister?: string[];
186
+ }
187
+ interface AutocompleterOptions {
188
+ /** Name of the Autocompleter. */
189
+ name: string;
190
+ /** Whether the Autocompleter is disabled. */
191
+ disabled?: boolean;
192
+ /** Handle the execution of the Autocompleter. */
193
+ execute: (client: FrameworkClient<true>, interaction: AutocompleteInteraction, command: FrameworkSlashCommand, value: string) => Promise<unknown>;
194
+ }
195
+ interface FrameworkAutocompleter {
196
+ id: string;
197
+ filepath: string;
198
+ name: string;
199
+ disabled: boolean;
200
+ execute: (client: FrameworkClient<true>, interaction: AutocompleteInteraction, command: FrameworkSlashCommand, value: string) => Promise<unknown>;
201
+ }
202
+ type ModalCollectorOptions = InteractionCollectorOptions<ModalSubmitInteraction>;
203
+ interface AwaitMemberResponseOptions extends MessageCollectorOptions {
204
+ deleteMessage?: boolean;
205
+ }
206
+
207
+ declare module 'discord.js' {
208
+ interface ClientEvents {
209
+ buttonInteraction: [interaction: ButtonInteraction];
210
+ selectMenuInteraction: [interaction: AnySelectMenuInteraction];
211
+ modalSubmitInteraction: [interaction: ModalSubmitInteraction];
212
+ }
213
+ interface Client {
214
+ prefix: string;
215
+ developers: string[];
216
+ autocomplete: Collection<string, FrameworkAutocompleter>;
217
+ aliases: Collection<string, string>;
218
+ commands: Collection<string, FrameworkCommand>;
219
+ cooldowns: Collection<string, Collection<string, number>>;
220
+ events: Collection<string, FrameworkListener<keyof ClientEvents>>;
221
+ autocompleteModule: AutocompleteModule;
222
+ commandsModule: CommandsModule;
223
+ listenerModule: ListenerModule;
224
+ }
225
+ interface Message {
226
+ prefix: string;
227
+ isDeveloper(): boolean;
228
+ awaitMemberResponse(options?: AwaitMemberResponseOptions): Promise<Message>;
229
+ createModalSubmitCollector(options?: ModalCollectorOptions): InteractionCollector<ModalSubmitInteraction>;
230
+ awaitModalSubmitComponent(options?: ModalCollectorOptions): Promise<ModalSubmitInteraction>;
231
+ }
232
+ }
233
+
234
+ declare function Autocompleter(options: AutocompleterOptions): {
235
+ id: string;
236
+ name: string;
237
+ disabled: boolean;
238
+ execute: (client: FrameworkClient<true>, interaction: discord_js.AutocompleteInteraction, command: FrameworkSlashCommand, value: string) => Promise<unknown>;
239
+ };
240
+
241
+ declare function ContextCommand(options: ContextCommandOptions): {
242
+ id: string;
243
+ name: string;
244
+ description: string;
245
+ commandType: "Slash" | "Message" | "ContextUser" | "ContextMessage";
246
+ memberPermissions: discord_js.PermissionResolvable | undefined;
247
+ clientPermissions: discord_js.PermissionResolvable | undefined;
248
+ cooldown: number | undefined;
249
+ disabled: boolean;
250
+ };
251
+
252
+ type MessageCommandOptions = Omit<MessageCommandOptions$1, 'commandType'>;
253
+ declare function MessageCommand(options: MessageCommandOptions): {
254
+ id: string;
255
+ name: string;
256
+ description: string;
257
+ commandType: "Slash" | "Message" | "ContextUser" | "ContextMessage";
258
+ memberPermissions: discord_js.PermissionResolvable | undefined;
259
+ clientPermissions: discord_js.PermissionResolvable | undefined;
260
+ cooldown: number | undefined;
261
+ disabled: boolean;
262
+ };
263
+
264
+ type SlashCommandOptions = Omit<SlashCommandOptions$1, 'commandType'>;
265
+ declare function SlashCommand(options: SlashCommandOptions): {
266
+ id: string;
267
+ name: string;
268
+ description: string;
269
+ commandType: "Slash" | "Message" | "ContextUser" | "ContextMessage";
270
+ memberPermissions: discord_js.PermissionResolvable | undefined;
271
+ clientPermissions: discord_js.PermissionResolvable | undefined;
272
+ cooldown: number | undefined;
273
+ disabled: boolean;
274
+ };
275
+
276
+ declare function Listener<T extends keyof ClientEvents>(options: ListenerOptions<T>): {
277
+ id: string;
278
+ name: T;
279
+ once: boolean;
280
+ disabled: boolean;
281
+ execute: (...args: ClientEvents[T]) => Promise<boolean>;
282
+ };
283
+
284
+ export { Autocompleter, type CommandHandlerName, type CommandModuleHandler, ContextCommand, type FrameworkAutocompleter, FrameworkClient, type FrameworkCommand, type FrameworkContextCommand, type FrameworkListener, type FrameworkMessageCommand, type FrameworkSlashCommand, Listener, MessageCommand, SlashCommand };
@@ -0,0 +1,284 @@
1
+ import * as discord_js from 'discord.js';
2
+ import { Client, PermissionResolvable, InteractionContextType, ApplicationIntegrationType, LocalizationMap, ApplicationCommandOptionData, ChatInputCommandInteraction, AutocompleteInteraction, Message, ContextMenuCommandInteraction, CommandInteraction, PermissionsString, Interaction, Collection, ClientEvents, ModalSubmitInteraction, ClientOptions, MessageCollectorOptions, InteractionCollectorOptions } from 'discord.js';
3
+ export { SlashCommandAttachmentOption as AttachmentOption, SlashCommandBooleanOption as BooleanOption, SlashCommandChannelOption as ChannelOption, SlashCommandIntegerOption as IntegerOption, SlashCommandMentionableOption as MentionableOption, SlashCommandNumberOption as NumberOption, SlashCommandRoleOption as RoleOption, SlashCommandOptionsOnlyBuilder as SlashCommandOptionsBuilder, SlashCommandStringOption as StringOption, SlashCommandSubcommandBuilder as SubcommandBuilder, SlashCommandSubcommandGroupBuilder as SubcommandGroupBuilder } from 'discord.js';
4
+ import EventEmitter from 'events';
5
+
6
+ declare class FrameworkClient<Ready extends boolean = boolean> extends Client<Ready> {
7
+ rootDir: string;
8
+ prefix: string;
9
+ developers: string[];
10
+ constructor(frameworkOptions: FrameworkClientOptions);
11
+ start(token: string): Promise<void>;
12
+ }
13
+
14
+ interface BaseCommandOptions {
15
+ /** The Name of the Command */
16
+ name: string;
17
+ /** The Description of the Command */
18
+ description: string;
19
+ /** The Type of the Command */
20
+ commandType: 'Slash' | 'Message' | 'ContextMessage' | 'ContextUser';
21
+ /** The Cooldown of the Command (in MS) */
22
+ cooldown?: number;
23
+ /** Permissions required by the User to use this Command */
24
+ memberPermissions?: PermissionResolvable;
25
+ /** Permissions required by the Application Client to execute this Command */
26
+ clientPermissions?: PermissionResolvable;
27
+ /** Whether this command is Disbaled */
28
+ disabled?: boolean;
29
+ }
30
+ interface BaseAppCommandOptions extends BaseCommandOptions {
31
+ /**
32
+ * Where this Application Command can be registered
33
+ * - `default` - In both Guild & Global Commands
34
+ * - `guild` - In only Guild Commands
35
+ * - `global` - In only Global Commands
36
+ */
37
+ commandScope: 'default' | 'guild' | 'global';
38
+ /**
39
+ * Where this Application Command can be used
40
+ * - `Guild` | `(0)` - In Guilds
41
+ * - `BotDM` | `(1)` - In Application DMs
42
+ * - `PrivateChannel` | `(2)` - In Other's DMs & Group DMs
43
+ */
44
+ commandContexts?: (InteractionContextType | keyof typeof InteractionContextType)[];
45
+ /**
46
+ * Where this Application Command can be integrated
47
+ * - `GuildInstall` | `(0)` - App is installable to servers
48
+ * - `UserInstall` | `(1)` - App is installable to users
49
+ */
50
+ integrationTypes?: (ApplicationIntegrationType | keyof typeof ApplicationIntegrationType)[];
51
+ /** The Name Localizations of the Command */
52
+ nameLocalizations?: LocalizationMap;
53
+ /** The Description Localizations of the Command */
54
+ descriptionLocalizations?: LocalizationMap;
55
+ }
56
+ interface MessageCommandOptions$1 extends BaseCommandOptions {
57
+ commandType: 'Message';
58
+ /** The Aliases of the Command */
59
+ aliases?: string[];
60
+ /** The Usage of the Command */
61
+ usage?: string;
62
+ /** Whether the command is Developer Only */
63
+ devOnly?: boolean;
64
+ /**
65
+ * Where this Application Command can be used
66
+ * - `BotDM` - In Application DMs
67
+ * - `Guild` - In Guilds
68
+ */
69
+ contexts?: ('BotDM' | 'Guild')[];
70
+ execute: (client: FrameworkClient<true>, message: Message, args: string[]) => Promise<unknown>;
71
+ }
72
+ interface SlashCommandOptions$1 extends BaseAppCommandOptions {
73
+ commandType: 'Slash';
74
+ /** The Application Command Options of this Command */
75
+ options?: ApplicationCommandOptionData[];
76
+ execute: (client: FrameworkClient<true>, interaction: ChatInputCommandInteraction) => Promise<unknown>;
77
+ autocomplete?: (client: FrameworkClient<true>, interaction: AutocompleteInteraction) => Promise<unknown>;
78
+ }
79
+ interface ContextCommandOptions extends BaseAppCommandOptions {
80
+ commandType: 'ContextMessage' | 'ContextUser';
81
+ execute: (client: FrameworkClient<true>, interaction: ContextMenuCommandInteraction) => Promise<unknown>;
82
+ }
83
+ interface BaseCommand {
84
+ id: string;
85
+ filepath: string;
86
+ disabled: boolean;
87
+ }
88
+ type FrameworkSlashCommand = SlashCommandOptions$1 & BaseCommand;
89
+ type FrameworkContextCommand = ContextCommandOptions & BaseCommand;
90
+ type FrameworkMessageCommand = MessageCommandOptions$1 & BaseCommand & {
91
+ devOnly: boolean;
92
+ contexts: ('BotDM' | 'Guild')[];
93
+ };
94
+ type FrameworkCommand = (FrameworkSlashCommand | FrameworkMessageCommand | FrameworkContextCommand);
95
+ interface CommandModuleHandler {
96
+ onCooldown?: (context: Message | CommandInteraction, command: FrameworkCommand, expirationTime: Date) => any;
97
+ onMemberPermissions?: (context: Message, command: FrameworkCommand, missingPermissions: PermissionsString[]) => any;
98
+ onClientPermissions?: (context: Message | CommandInteraction, command: FrameworkCommand, missingPermissions: PermissionsString[]) => any;
99
+ MessageCommandInterceptor?: (message: Message) => Promise<boolean>;
100
+ InteractionCommandInterceptor?: (interaction: Interaction) => Promise<boolean>;
101
+ }
102
+ type CommandHandlerName = keyof Omit<CommandModuleHandler, 'MessageCommandInterceptor' | 'InteractionCommandInterceptor'>;
103
+
104
+ /**
105
+ * @class AutocompleteModule
106
+ * @fires AutocompleteModule#execute
107
+ * @fires AutocompleteModule#success
108
+ * @fires AutocompleteModule#error
109
+ * @fires AutocompleteModule#unknown
110
+ */
111
+ declare class AutocompleteModule extends EventEmitter {
112
+ private client;
113
+ constructor(client: FrameworkClient);
114
+ load(filepath: string, reload?: boolean): Promise<boolean>;
115
+ loadAll(): Promise<void>;
116
+ reload(id: string): void;
117
+ private unload;
118
+ private _handleInteraction;
119
+ }
120
+
121
+ declare class ListenerModule {
122
+ private client;
123
+ constructor(client: FrameworkClient);
124
+ load(filepath: string, reload?: boolean): Promise<boolean>;
125
+ loadAll(): Promise<void>;
126
+ reload(id: string): void;
127
+ private unload;
128
+ }
129
+
130
+ /**
131
+ * @class CommandsModule
132
+ * @fires CommandsModule#execute
133
+ * @fires CommandsModule#success
134
+ * @fires CommandsModule#error
135
+ * @fires CommandsModule#unknown
136
+ */
137
+ declare class CommandsModule extends EventEmitter {
138
+ private client;
139
+ private handler;
140
+ constructor(client: FrameworkClient);
141
+ setHandler<K extends CommandHandlerName>(key: K, callback: NonNullable<CommandModuleHandler[K]>): NonNullable<CommandModuleHandler[K]>;
142
+ setMessageInterceptor(callback: (message: Message) => Promise<boolean>): (message: Message) => Promise<boolean>;
143
+ setInteractionInterceptor(callback: (interaction: Interaction) => Promise<boolean>): (interaction: Interaction) => Promise<boolean>;
144
+ load(filepath: string, reload?: boolean): Promise<boolean>;
145
+ loadAll(): Promise<void>;
146
+ reload(id: string): void;
147
+ private unload;
148
+ registerOnStart(guildIds: string[], commands?: Collection<string, FrameworkCommand>): Promise<void>;
149
+ publishGlobal(commands?: Collection<string, FrameworkCommand>): Promise<false | Collection<string, discord_js.ApplicationCommand<{
150
+ guild: discord_js.GuildResolvable;
151
+ }>>>;
152
+ publishGuild(guildId: string, commands?: Collection<string, FrameworkCommand>): Promise<void>;
153
+ private _handleMessage;
154
+ private _handleInteraction;
155
+ private _getCommandId;
156
+ private _getCommandData;
157
+ }
158
+
159
+ interface ListenerOptions<T extends keyof ClientEvents = keyof ClientEvents> {
160
+ /** Name of the Listener. */
161
+ name: T;
162
+ /** Wheather to execute the function only Once. */
163
+ once?: boolean;
164
+ /** Whether the Listener is disabled. */
165
+ disabled?: boolean;
166
+ /** Handles the execution of the Listener */
167
+ execute: (...args: ClientEvents[T]) => Promise<boolean>;
168
+ }
169
+ interface FrameworkListener<T extends keyof ClientEvents = keyof ClientEvents> {
170
+ id: string;
171
+ filepath: string;
172
+ name: T;
173
+ once: boolean;
174
+ disabled: boolean;
175
+ execute: (...args: ClientEvents[T]) => Promise<boolean>;
176
+ _execute?: (...args: ClientEvents[T]) => Promise<boolean>;
177
+ }
178
+
179
+ interface FrameworkClientOptions {
180
+ clientOptions: ClientOptions;
181
+ rootDir?: string;
182
+ developers?: string[];
183
+ prefix?: string;
184
+ registerOnStart?: boolean;
185
+ guildsToRegister?: string[];
186
+ }
187
+ interface AutocompleterOptions {
188
+ /** Name of the Autocompleter. */
189
+ name: string;
190
+ /** Whether the Autocompleter is disabled. */
191
+ disabled?: boolean;
192
+ /** Handle the execution of the Autocompleter. */
193
+ execute: (client: FrameworkClient<true>, interaction: AutocompleteInteraction, command: FrameworkSlashCommand, value: string) => Promise<unknown>;
194
+ }
195
+ interface FrameworkAutocompleter {
196
+ id: string;
197
+ filepath: string;
198
+ name: string;
199
+ disabled: boolean;
200
+ execute: (client: FrameworkClient<true>, interaction: AutocompleteInteraction, command: FrameworkSlashCommand, value: string) => Promise<unknown>;
201
+ }
202
+ type ModalCollectorOptions = InteractionCollectorOptions<ModalSubmitInteraction>;
203
+ interface AwaitMemberResponseOptions extends MessageCollectorOptions {
204
+ deleteMessage?: boolean;
205
+ }
206
+
207
+ declare module 'discord.js' {
208
+ interface ClientEvents {
209
+ buttonInteraction: [interaction: ButtonInteraction];
210
+ selectMenuInteraction: [interaction: AnySelectMenuInteraction];
211
+ modalSubmitInteraction: [interaction: ModalSubmitInteraction];
212
+ }
213
+ interface Client {
214
+ prefix: string;
215
+ developers: string[];
216
+ autocomplete: Collection<string, FrameworkAutocompleter>;
217
+ aliases: Collection<string, string>;
218
+ commands: Collection<string, FrameworkCommand>;
219
+ cooldowns: Collection<string, Collection<string, number>>;
220
+ events: Collection<string, FrameworkListener<keyof ClientEvents>>;
221
+ autocompleteModule: AutocompleteModule;
222
+ commandsModule: CommandsModule;
223
+ listenerModule: ListenerModule;
224
+ }
225
+ interface Message {
226
+ prefix: string;
227
+ isDeveloper(): boolean;
228
+ awaitMemberResponse(options?: AwaitMemberResponseOptions): Promise<Message>;
229
+ createModalSubmitCollector(options?: ModalCollectorOptions): InteractionCollector<ModalSubmitInteraction>;
230
+ awaitModalSubmitComponent(options?: ModalCollectorOptions): Promise<ModalSubmitInteraction>;
231
+ }
232
+ }
233
+
234
+ declare function Autocompleter(options: AutocompleterOptions): {
235
+ id: string;
236
+ name: string;
237
+ disabled: boolean;
238
+ execute: (client: FrameworkClient<true>, interaction: discord_js.AutocompleteInteraction, command: FrameworkSlashCommand, value: string) => Promise<unknown>;
239
+ };
240
+
241
+ declare function ContextCommand(options: ContextCommandOptions): {
242
+ id: string;
243
+ name: string;
244
+ description: string;
245
+ commandType: "Slash" | "Message" | "ContextUser" | "ContextMessage";
246
+ memberPermissions: discord_js.PermissionResolvable | undefined;
247
+ clientPermissions: discord_js.PermissionResolvable | undefined;
248
+ cooldown: number | undefined;
249
+ disabled: boolean;
250
+ };
251
+
252
+ type MessageCommandOptions = Omit<MessageCommandOptions$1, 'commandType'>;
253
+ declare function MessageCommand(options: MessageCommandOptions): {
254
+ id: string;
255
+ name: string;
256
+ description: string;
257
+ commandType: "Slash" | "Message" | "ContextUser" | "ContextMessage";
258
+ memberPermissions: discord_js.PermissionResolvable | undefined;
259
+ clientPermissions: discord_js.PermissionResolvable | undefined;
260
+ cooldown: number | undefined;
261
+ disabled: boolean;
262
+ };
263
+
264
+ type SlashCommandOptions = Omit<SlashCommandOptions$1, 'commandType'>;
265
+ declare function SlashCommand(options: SlashCommandOptions): {
266
+ id: string;
267
+ name: string;
268
+ description: string;
269
+ commandType: "Slash" | "Message" | "ContextUser" | "ContextMessage";
270
+ memberPermissions: discord_js.PermissionResolvable | undefined;
271
+ clientPermissions: discord_js.PermissionResolvable | undefined;
272
+ cooldown: number | undefined;
273
+ disabled: boolean;
274
+ };
275
+
276
+ declare function Listener<T extends keyof ClientEvents>(options: ListenerOptions<T>): {
277
+ id: string;
278
+ name: T;
279
+ once: boolean;
280
+ disabled: boolean;
281
+ execute: (...args: ClientEvents[T]) => Promise<boolean>;
282
+ };
283
+
284
+ export { Autocompleter, type CommandHandlerName, type CommandModuleHandler, ContextCommand, type FrameworkAutocompleter, FrameworkClient, type FrameworkCommand, type FrameworkContextCommand, type FrameworkListener, type FrameworkMessageCommand, type FrameworkSlashCommand, Listener, MessageCommand, SlashCommand };