meocord 1.2.1 → 1.2.2
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/CHANGELOG.md +35 -0
- package/README.md +152 -140
- package/dist/cjs/_shared/meocord.app-CHjdCAA_.cjs +496 -0
- package/dist/cjs/_shared/theme-BdtbtMZX.cjs +176 -0
- package/dist/cjs/common/index.cjs +16 -0
- package/dist/cjs/core/index.cjs +35 -0
- package/dist/cjs/decorator/index.cjs +360 -0
- package/dist/cjs/enum/index.cjs +20 -0
- package/dist/cjs/interface/index.cjs +2 -0
- package/dist/esm/bin/generator.js +92 -0
- package/dist/esm/bin/helper/controller-generator.helper.js +105 -0
- package/dist/esm/bin/helper/guard-generator.helper.js +33 -0
- package/dist/esm/bin/helper/service-generator.helper.js +33 -0
- package/dist/esm/bin/meocord.js +333 -0
- package/dist/esm/common/index.js +2 -0
- package/dist/esm/common/logger.js +72 -0
- package/dist/{core/index.d.ts → esm/common/theme.js} +8 -2
- package/dist/esm/core/index.js +1 -0
- package/dist/esm/core/meocord-factory.js +28 -0
- package/dist/esm/core/meocord.app.js +267 -0
- package/dist/esm/decorator/app.decorator.js +99 -0
- package/dist/esm/decorator/command-builder.decorator.js +32 -0
- package/dist/esm/decorator/container.js +6 -0
- package/dist/esm/decorator/controller.decorator.js +218 -0
- package/dist/esm/decorator/guard.decorator.js +165 -0
- package/dist/esm/decorator/index.js +6 -0
- package/dist/esm/decorator/service.decorator.js +58 -0
- package/dist/esm/enum/controller.enum.js +43 -0
- package/dist/esm/enum/index.js +1 -0
- package/dist/esm/interface/index.js +1 -0
- package/dist/esm/package.json.js +5 -0
- package/dist/esm/util/common.util.js +68 -0
- package/dist/esm/util/embed.util.js +13 -0
- package/dist/esm/util/generator-cli.util.js +107 -0
- package/dist/{util → esm/util}/json.util.js +10 -6
- package/dist/esm/util/meocord-cli.util.js +172 -0
- package/dist/esm/util/meocord-config-loader.util.js +48 -0
- package/dist/esm/util/tsconfig.util.js +83 -0
- package/dist/{util → esm/util}/wait.util.js +5 -1
- package/dist/{common/logger.d.ts → types/common/index.d.ts} +30 -1
- package/dist/{core/meocord.app.d.ts → types/core/index.d.ts} +30 -2
- package/dist/types/decorator/index.d.ts +425 -0
- package/dist/types/enum/index.d.ts +18 -0
- package/dist/{interface → types/interface}/index.d.ts +11 -7
- package/package.json +64 -48
- package/webpack.config.js +2 -2
- package/dist/bin/generator.d.ts +0 -29
- package/dist/bin/generator.js +0 -17
- package/dist/bin/helper/controller-generator.helper.d.ts +0 -67
- package/dist/bin/helper/controller-generator.helper.js +0 -50
- package/dist/bin/helper/guard-generator.helper.d.ts +0 -32
- package/dist/bin/helper/guard-generator.helper.js +0 -25
- package/dist/bin/helper/service-generator.helper.d.ts +0 -32
- package/dist/bin/helper/service-generator.helper.js +0 -25
- package/dist/bin/meocord.d.ts +0 -19
- package/dist/bin/meocord.js +0 -34
- package/dist/common/index.d.ts +0 -19
- package/dist/common/index.js +0 -17
- package/dist/common/logger.js +0 -17
- package/dist/common/theme.d.ts +0 -24
- package/dist/common/theme.js +0 -17
- package/dist/core/index.js +0 -17
- package/dist/core/meocord-factory.d.ts +0 -24
- package/dist/core/meocord-factory.js +0 -17
- package/dist/core/meocord.app.js +0 -17
- package/dist/decorator/app.decorator.d.ts +0 -59
- package/dist/decorator/app.decorator.js +0 -61
- package/dist/decorator/command-builder.decorator.d.ts +0 -39
- package/dist/decorator/command-builder.decorator.js +0 -35
- package/dist/decorator/container.d.ts +0 -20
- package/dist/decorator/container.js +0 -17
- package/dist/decorator/controller.decorator.d.ts +0 -125
- package/dist/decorator/controller.decorator.js +0 -113
- package/dist/decorator/guard.decorator.d.ts +0 -101
- package/dist/decorator/guard.decorator.js +0 -94
- package/dist/decorator/index.d.ts +0 -23
- package/dist/decorator/index.js +0 -17
- package/dist/decorator/service.decorator.d.ts +0 -36
- package/dist/decorator/service.decorator.js +0 -36
- package/dist/enum/controller.enum.d.ts +0 -42
- package/dist/enum/controller.enum.js +0 -19
- package/dist/enum/index.d.ts +0 -18
- package/dist/enum/index.js +0 -17
- package/dist/interface/command-decorator.interface.d.ts +0 -43
- package/dist/interface/command-decorator.interface.js +0 -1
- package/dist/interface/index.js +0 -1
- package/dist/util/common.util.d.ts +0 -40
- package/dist/util/common.util.js +0 -38
- package/dist/util/embed.util.d.ts +0 -19
- package/dist/util/embed.util.js +0 -17
- package/dist/util/generator-cli.util.d.ts +0 -65
- package/dist/util/generator-cli.util.js +0 -49
- package/dist/util/index.d.ts +0 -18
- package/dist/util/index.js +0 -17
- package/dist/util/json.util.d.ts +0 -27
- package/dist/util/meocord-cli.util.d.ts +0 -62
- package/dist/util/meocord-cli.util.js +0 -50
- package/dist/util/meocord-config-loader.util.d.ts +0 -32
- package/dist/util/meocord-config-loader.util.js +0 -34
- package/dist/util/tsconfig.util.d.ts +0 -29
- package/dist/util/tsconfig.util.js +0 -32
- package/dist/util/wait.util.d.ts +0 -18
- /package/dist/{bin → esm/bin}/builder-template/builder/context-menu.builder.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/builder/slash.builder.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/controller/button.controller.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/controller/context-menu.controller.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/controller/message.controller.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/controller/modal-submit.controller.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/controller/reaction.controller.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/controller/select-menu.controller.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/controller/slash.controller.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/guard.template +0 -0
- /package/dist/{bin → esm/bin}/builder-template/service.template +0 -0
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
import 'reflect-metadata';
|
|
19
|
-
import { Message, MessageReaction, type OmitPartialGroupDMChannel, type PartialMessageReaction } from 'discord.js';
|
|
20
|
-
import { CommandType } from '../enum/index.js';
|
|
21
|
-
import { type ReactionHandlerOptions } from '../interface/index.js';
|
|
22
|
-
import { type CommandBuilderConstructor, type CommandInteractionType, type CommandMetadata } from '../interface/command-decorator.interface.js';
|
|
23
|
-
/**
|
|
24
|
-
* Decorator to register message handlers in the controller.
|
|
25
|
-
*
|
|
26
|
-
* @param keyword - An optional keyword to filter messages this handler should respond to.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* @MessageHandler('hello')
|
|
31
|
-
* async handleHelloMessage(message: Message) {
|
|
32
|
-
* await message.reply('Hello! How can I help you?');
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* @MessageHandler()
|
|
36
|
-
* async handleAnyMessage(message: Message) {
|
|
37
|
-
* console.log(`Received a message: ${message.content}`);
|
|
38
|
-
* }
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export declare function MessageHandler<T extends OmitPartialGroupDMChannel<Message<boolean>>, R extends void | Promise<void>>(keyword?: string): (target: object, propertyKey: string, _descriptor: TypedPropertyDescriptor<(message: T) => R>) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Decorator to register reaction handlers in the controller.
|
|
44
|
-
*
|
|
45
|
-
* @param emoji - Optional emoji name to filter reactions this handler should respond to.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* @ReactionHandler('👍')
|
|
50
|
-
* async handleThumbsUpReaction(reaction: MessageReaction, { user }: ReactionHandlerOptions) {
|
|
51
|
-
* console.log(`User ${user.username} reacted with 👍`);
|
|
52
|
-
* }
|
|
53
|
-
*
|
|
54
|
-
* @ReactionHandler()
|
|
55
|
-
* async handleAnyReaction(reaction: MessageReaction, { user }: ReactionHandlerOptions) {
|
|
56
|
-
* console.log(`User ${user.username} reacted with ${reaction.emoji.name}`);
|
|
57
|
-
* }
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function ReactionHandler<T extends MessageReaction | PartialMessageReaction, R extends void | Promise<void>>(emoji?: string): (target: object, propertyKey: string, _descriptor: TypedPropertyDescriptor<(reaction: T, options: ReactionHandlerOptions) => R> | TypedPropertyDescriptor<(reaction: T) => R>) => void;
|
|
61
|
-
/**
|
|
62
|
-
* Retrieves reaction handlers metadata from a given controller.
|
|
63
|
-
*
|
|
64
|
-
* @param controller - The controller class instance.
|
|
65
|
-
* @returns An array of reaction handler metadata objects.
|
|
66
|
-
*/
|
|
67
|
-
export declare function getReactionHandlers(controller: any): {
|
|
68
|
-
emoji: string | undefined;
|
|
69
|
-
method: string;
|
|
70
|
-
}[];
|
|
71
|
-
/**
|
|
72
|
-
* Retrieves message handlers metadata from a given controller.
|
|
73
|
-
*
|
|
74
|
-
* @param controller - The controller class instance.
|
|
75
|
-
* @returns An array of message handler method names.
|
|
76
|
-
*/
|
|
77
|
-
export declare function getMessageHandlers(controller: any): {
|
|
78
|
-
keyword: string | undefined;
|
|
79
|
-
method: string;
|
|
80
|
-
}[];
|
|
81
|
-
/**
|
|
82
|
-
* Decorator to register command methods in a controller.
|
|
83
|
-
*
|
|
84
|
-
* @param commandName - The name or pattern of the command.
|
|
85
|
-
* @param builderOrType - A command builder class or a command type from `CommandType`.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```typescript
|
|
89
|
-
* @Command('help', CommandType.SLASH)
|
|
90
|
-
* public async handleHelp(interaction: ChatInputCommandInteraction) {
|
|
91
|
-
* await interaction.reply('This is the help command!')
|
|
92
|
-
* }
|
|
93
|
-
*
|
|
94
|
-
* @Command('stats-{id}', CommandType.BUTTON)
|
|
95
|
-
* public async handleStats(message: ButtonInteraction, { id }) {
|
|
96
|
-
* await message.reply(`Fetching stats for ID: ${id}`);
|
|
97
|
-
* }
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
export declare function Command<CBC extends CommandType.SLASH | CommandType.CONTEXT_MENU, T extends CommandBuilderConstructor<CBC> | CommandType>(commandName: string, builderOrType: T): <P extends Record<string, any>, R extends Promise<void> | void>(target: object, propertyKey: string, _descriptor: TypedPropertyDescriptor<(interaction: CommandInteractionType<CBC, T>, params: P) => R> | TypedPropertyDescriptor<(interaction: CommandInteractionType<CBC, T>) => R>) => void;
|
|
101
|
-
/**
|
|
102
|
-
* Retrieves the command map for a given controller.
|
|
103
|
-
*
|
|
104
|
-
* @param controller - The controller class instance.
|
|
105
|
-
* @returns A record containing command metadata indexed by command names.
|
|
106
|
-
*/
|
|
107
|
-
export declare function getCommandMap<T extends string>(controller: any): Record<string, CommandMetadata<T>[]>;
|
|
108
|
-
/**
|
|
109
|
-
* Decorator to mark a class as a controller that can later be registered to the App class `(app.ts)` using the `@MeoCord` decorator.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* @Controller()
|
|
114
|
-
* export class PingSlashController {
|
|
115
|
-
* constructor(private pingService: PingService) {}
|
|
116
|
-
*
|
|
117
|
-
* @Command('ping', PingCommandBuilder)
|
|
118
|
-
* async ping(interaction: ChatInputCommandInteraction) {
|
|
119
|
-
* const response = await this.pingService.handlePing()
|
|
120
|
-
* await interaction.reply(response)
|
|
121
|
-
* }
|
|
122
|
-
* }
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
export declare function Controller(): (target: any) => void;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/import"reflect-metadata";import{injectable}from"inversify";import{mainContainer}from"./container.js";import{ButtonInteraction,ChatInputCommandInteraction,ContextMenuCommandInteraction,ModalSubmitInteraction,StringSelectMenuInteraction}from"discord.js";import{CommandType}from"../enum/index.js";var COMMAND_METADATA_KEY=Symbol("commands"),MESSAGE_HANDLER_METADATA_KEY=Symbol("message_handlers"),REACTION_HANDLER_METADATA_KEY=Symbol("reaction_handlers");/**
|
|
18
|
-
* Decorator to register message handlers in the controller.
|
|
19
|
-
*
|
|
20
|
-
* @param keyword - An optional keyword to filter messages this handler should respond to.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* @MessageHandler('hello')
|
|
25
|
-
* async handleHelloMessage(message: Message) {
|
|
26
|
-
* await message.reply('Hello! How can I help you?');
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* @MessageHandler()
|
|
30
|
-
* async handleAnyMessage(message: Message) {
|
|
31
|
-
* console.log(`Received a message: ${message.content}`);
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/export function MessageHandler(a){return function(b,c){var d=Reflect.getMetadata(MESSAGE_HANDLER_METADATA_KEY,b)||[];d.push({keyword:a,method:c.toString()}),Reflect.defineMetadata(MESSAGE_HANDLER_METADATA_KEY,d,b)}}/**
|
|
35
|
-
* Decorator to register reaction handlers in the controller.
|
|
36
|
-
*
|
|
37
|
-
* @param emoji - Optional emoji name to filter reactions this handler should respond to.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* @ReactionHandler('👍')
|
|
42
|
-
* async handleThumbsUpReaction(reaction: MessageReaction, { user }: ReactionHandlerOptions) {
|
|
43
|
-
* console.log(`User ${user.username} reacted with 👍`);
|
|
44
|
-
* }
|
|
45
|
-
*
|
|
46
|
-
* @ReactionHandler()
|
|
47
|
-
* async handleAnyReaction(reaction: MessageReaction, { user }: ReactionHandlerOptions) {
|
|
48
|
-
* console.log(`User ${user.username} reacted with ${reaction.emoji.name}`);
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*/export function ReactionHandler(a){return function(b,c){var d=Reflect.getMetadata(REACTION_HANDLER_METADATA_KEY,b)||[];d.push({emoji:a,method:c.toString()}),Reflect.defineMetadata(REACTION_HANDLER_METADATA_KEY,d,b)}}/**
|
|
52
|
-
* Retrieves reaction handlers metadata from a given controller.
|
|
53
|
-
*
|
|
54
|
-
* @param controller - The controller class instance.
|
|
55
|
-
* @returns An array of reaction handler metadata objects.
|
|
56
|
-
*/export function getReactionHandlers(a){return Reflect.getMetadata(REACTION_HANDLER_METADATA_KEY,a)||[]}/**
|
|
57
|
-
* Retrieves message handlers metadata from a given controller.
|
|
58
|
-
*
|
|
59
|
-
* @param controller - The controller class instance.
|
|
60
|
-
* @returns An array of message handler method names.
|
|
61
|
-
*/export function getMessageHandlers(a){return Reflect.getMetadata(MESSAGE_HANDLER_METADATA_KEY,a)||[]}/**
|
|
62
|
-
* Helper function to create regex and parameter mappings from a pattern string.
|
|
63
|
-
*
|
|
64
|
-
* @param pattern - The pattern string to parse.
|
|
65
|
-
* @returns An object containing the generated regex and parameter names.
|
|
66
|
-
*/function createRegexFromPattern(a){var b=[],c=a.replace(/[/\\^$*+?.()|[\]]/g,"\\$&"),d=c.replace(/\{(\w+)}/g,function(a,c){if(!/^\w+$/.test(c))throw new Error("Invalid parameter name: ".concat(c,". Parameter names must be alphanumeric."));return b.push(c),"(?<".concat(c,">[a-zA-Z0-9]+)")}),e=new RegExp("^".concat(d,"$"));// Escape special characters except for {} and -
|
|
67
|
-
// Removed hyphen `-` from this list
|
|
68
|
-
// Replace placeholders with named capturing groups
|
|
69
|
-
// Construct the final regex
|
|
70
|
-
return{regex:e,params:b}}/**
|
|
71
|
-
* Decorator to register command methods in a controller.
|
|
72
|
-
*
|
|
73
|
-
* @param commandName - The name or pattern of the command.
|
|
74
|
-
* @param builderOrType - A command builder class or a command type from `CommandType`.
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```typescript
|
|
78
|
-
* @Command('help', CommandType.SLASH)
|
|
79
|
-
* public async handleHelp(interaction: ChatInputCommandInteraction) {
|
|
80
|
-
* await interaction.reply('This is the help command!')
|
|
81
|
-
* }
|
|
82
|
-
*
|
|
83
|
-
* @Command('stats-{id}', CommandType.BUTTON)
|
|
84
|
-
* public async handleStats(message: ButtonInteraction, { id }) {
|
|
85
|
-
* await message.reply(`Fetching stats for ID: ${id}`);
|
|
86
|
-
* }
|
|
87
|
-
* ```
|
|
88
|
-
*/export function Command(a,b){return function(c,d,e){var f=e.value;if(!f)throw new Error("Missing implementation for method ".concat(d));// Wrap original method for interaction type validation
|
|
89
|
-
e.value=function(a,b){var c=h===CommandType.BUTTON&&a instanceof ButtonInteraction||h===CommandType.SELECT_MENU&&a instanceof StringSelectMenuInteraction||h===CommandType.SLASH&&a instanceof ChatInputCommandInteraction||h===CommandType.CONTEXT_MENU&&a instanceof ContextMenuCommandInteraction||h===CommandType.MODAL_SUBMIT&&a instanceof ModalSubmitInteraction;if(!c)throw new Error("Invalid interaction type passed to @Command for method: ".concat(d));return f.apply(this,[a,b])};// Retrieve existing metadata or initialize it
|
|
90
|
-
var g,h,i,j=Reflect.getMetadata(COMMAND_METADATA_KEY,c)||{},k=[];// Determine command type and builder
|
|
91
|
-
if("function"==typeof b){var l=new b;if(g=l.build(a),h=Reflect.getMetadata("commandType",b),!(h in CommandType))throw new Error("Metadata for 'commandType' is missing on builder ".concat(b.name))}else h=b;if(h!==CommandType.SLASH&&h!==CommandType.CONTEXT_MENU){var m=createRegexFromPattern(a),n=m.regex,o=m.params;i=n,k=o}// Ensure commandName supports multiple entries
|
|
92
|
-
j[a]||(j[a]=[]),j[a].push({methodName:d,builder:g,type:h,regex:i,dynamicParams:k}),Reflect.defineMetadata(COMMAND_METADATA_KEY,j,c)}}/**
|
|
93
|
-
* Retrieves the command map for a given controller.
|
|
94
|
-
*
|
|
95
|
-
* @param controller - The controller class instance.
|
|
96
|
-
* @returns A record containing command metadata indexed by command names.
|
|
97
|
-
*/export function getCommandMap(a){return Reflect.getMetadata(COMMAND_METADATA_KEY,a)}/**
|
|
98
|
-
* Decorator to mark a class as a controller that can later be registered to the App class `(app.ts)` using the `@MeoCord` decorator.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```typescript
|
|
102
|
-
* @Controller()
|
|
103
|
-
* export class PingSlashController {
|
|
104
|
-
* constructor(private pingService: PingService) {}
|
|
105
|
-
*
|
|
106
|
-
* @Command('ping', PingCommandBuilder)
|
|
107
|
-
* async ping(interaction: ChatInputCommandInteraction) {
|
|
108
|
-
* const response = await this.pingService.handlePing()
|
|
109
|
-
* await interaction.reply(response)
|
|
110
|
-
* }
|
|
111
|
-
* }
|
|
112
|
-
* ```
|
|
113
|
-
*/export function Controller(){return function(a){Reflect.hasMetadata("inversify:injectable",a)||injectable()(a);var b=Reflect.getMetadata("design:paramtypes",a)||[];b.map(function(a){mainContainer.isBound(a)||(!Reflect.hasMetadata("inversify:injectable",a)&&injectable()(a),mainContainer.bind(a).toSelf().inSingletonScope())}),Reflect.defineMetadata("inversify:container",mainContainer,a)}}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
import 'reflect-metadata';
|
|
19
|
-
import { type GuardInterface } from '../interface/index.js';
|
|
20
|
-
/**
|
|
21
|
-
* `@Guard()` decorator to mark a class as a Guard that later can be added on `@UseGuard` decorator.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* @Guard()
|
|
26
|
-
export class ButtonInteractionGuard implements GuardInterface {
|
|
27
|
-
private readonly logger = new Logger(ButtonInteractionGuard.name)
|
|
28
|
-
|
|
29
|
-
async canActivate(context: ButtonInteraction, { ownerId }: { ownerId: string }): Promise<boolean> {
|
|
30
|
-
if (context.user.id !== ownerId) {
|
|
31
|
-
this.logger.error(
|
|
32
|
-
`User with id ${context.user.id} is not allowed to use this command that initiated by user with id ${ownerId}.`,
|
|
33
|
-
)
|
|
34
|
-
const embed = generateErrorEmbed(
|
|
35
|
-
`Hi <@${context.user.id}>, this command can only be used by the person who initiated it: <@${ownerId}>.`,
|
|
36
|
-
)
|
|
37
|
-
await context.reply({
|
|
38
|
-
embeds: [embed],
|
|
39
|
-
flags: MessageFlagsBitField.Flags.Ephemeral,
|
|
40
|
-
})
|
|
41
|
-
return false
|
|
42
|
-
}
|
|
43
|
-
return true
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare function Guard(): (target: any) => void;
|
|
49
|
-
/**
|
|
50
|
-
* Type for a guard with parameters.
|
|
51
|
-
* This type defines a guard that requires additional parameters (other than the default constructor).
|
|
52
|
-
*/
|
|
53
|
-
interface GuardWithParams {
|
|
54
|
-
/**
|
|
55
|
-
* The guard class that needs to be instantiated.
|
|
56
|
-
*/
|
|
57
|
-
provide: new (...args: any[]) => GuardInterface;
|
|
58
|
-
/**
|
|
59
|
-
* Parameters to be passed to the guard during instantiation.
|
|
60
|
-
*/
|
|
61
|
-
params: Record<string, any>;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* `@UseGuard()` decorator to apply one or more guards to methods.
|
|
65
|
-
* Guards are used to handle permission checks before executing a method.
|
|
66
|
-
* Each guard must use `@Guard` decorator and implement the `canActivate` method, which determines
|
|
67
|
-
* whether the method should be allowed to execute based on the provided context (Interaction, Message, or Reaction) and arguments.
|
|
68
|
-
* This decorator ensures that all guards pass validation before calling the original method.
|
|
69
|
-
* Supports guards that are parameterized (accepting additional parameters).
|
|
70
|
-
*
|
|
71
|
-
* @param guards - One or more guard classes to apply. These can be regular guards or guards with additional parameters.
|
|
72
|
-
* - If providing a guard with parameters, it should be an object with:
|
|
73
|
-
* - `provide`: The guard class to instantiate. Must implement `GuardInterface`.
|
|
74
|
-
* - `params`: A record of key-value pairs to be passed as additional properties to the guard instance.
|
|
75
|
-
* @returns A method decorator function that applies the guards to the method.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* // Method-level usage
|
|
80
|
-
* @Command('profile-{id}', CommandType.BUTTON)
|
|
81
|
-
* @UseGuard(
|
|
82
|
-
* { provide: RateLimiterGuard, params: { limit: 2, window: 3000 } },
|
|
83
|
-
* ButtonInteractionGuard
|
|
84
|
-
* )
|
|
85
|
-
* async showProfileById(interaction: ButtonInteraction, { id }: { id: string }) {
|
|
86
|
-
* await interaction.reply(`Profile ID: ${id}`)
|
|
87
|
-
* }
|
|
88
|
-
*
|
|
89
|
-
* // Class-level usage
|
|
90
|
-
* @Controller()
|
|
91
|
-
* @UseGuard(GlobalGuard)
|
|
92
|
-
* class MyController {
|
|
93
|
-
* @Command('ping', CommandType.SLASH)
|
|
94
|
-
* async ping(interaction: ChatInputCommandInteraction) {
|
|
95
|
-
* await interaction.reply('Pong!')
|
|
96
|
-
* }
|
|
97
|
-
* }
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
export declare function UseGuard(...guards: ((new (...args: any[]) => GuardInterface) | GuardWithParams)[]): any;
|
|
101
|
-
export {};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function _createForOfIteratorHelper(b,c){var d="undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(!d){if(Array.isArray(b)||(d=_unsupportedIterableToArray(b))||c&&b&&"number"==typeof b.length){d&&(b=d);var e=0,f=function F(){};return{s:f,n:function n(){return e>=b.length?{done:!0}:{done:!1,value:b[e++]}},e:function e(a){throw a},f:f}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var g,h=!0,i=!1;return{s:function s(){d=d.call(b)},n:function n(){var a=d.next();return h=a.done,a},e:function e(a){i=!0,g=a},f:function f(){try{h||null==d["return"]||d["return"]()}finally{if(i)throw g}}}}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/import"reflect-metadata";import{injectable}from"inversify";import{mainContainer}from"./container.js";import{BaseInteraction,Message,MessageReaction}from"discord.js";import{getCommandMap,getMessageHandlers,getReactionHandlers}from"./controller.decorator.js";function applyGuards(a,b,c){var d=a.value;a.value=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(){var a,e,f,g,h,i,j,k,l,m,n,o,p,q=arguments;return _regenerator().w(function(r){for(;1;)switch(r.p=r.n){case 0:for(a=q.length,e=Array(a),f=0;f<a;f++)e[f]=q[f];if(g=e[0],g instanceof BaseInteraction||g instanceof Message||g instanceof MessageReaction){r.n=1;break}throw new Error("The first argument of ".concat(c+""," must be an instance of Interaction, Message, or MessageReaction."));case 1:h=_createForOfIteratorHelper(b),r.p=2,h.s();case 3:if((i=h.n()).done){r.n=7;break}if(k=i.value,l=void 0,isGuardWithParams(k)?(m=k.provide,n=k.params,l=mainContainer.get(m,{autobind:!0}),Object.assign(l,n)):l=mainContainer.get(k,{autobind:!0}),l.canActivate){r.n=4;break}throw new Error("Guard ".concat(k.constructor.name," applied to ").concat(c+""," does not have a valid canActivate method."));case 4:return r.n=5,(j=l).canActivate.apply(j,e);case 5:if(o=r.v,o){r.n=6;break}return r.a(2);case 6:r.n=3;break;case 7:r.n=9;break;case 8:r.p=8,p=r.v,h.e(p);case 9:return r.p=9,h.f(),r.f(9);case 10:return r.a(2,d.apply(this,e))}},_callee,this,[[2,8,9,10]])}))}/**
|
|
18
|
-
* `@Guard()` decorator to mark a class as a Guard that later can be added on `@UseGuard` decorator.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* @Guard()
|
|
23
|
-
export class ButtonInteractionGuard implements GuardInterface {
|
|
24
|
-
private readonly logger = new Logger(ButtonInteractionGuard.name)
|
|
25
|
-
|
|
26
|
-
async canActivate(context: ButtonInteraction, { ownerId }: { ownerId: string }): Promise<boolean> {
|
|
27
|
-
if (context.user.id !== ownerId) {
|
|
28
|
-
this.logger.error(
|
|
29
|
-
`User with id ${context.user.id} is not allowed to use this command that initiated by user with id ${ownerId}.`,
|
|
30
|
-
)
|
|
31
|
-
const embed = generateErrorEmbed(
|
|
32
|
-
`Hi <@${context.user.id}>, this command can only be used by the person who initiated it: <@${ownerId}>.`,
|
|
33
|
-
)
|
|
34
|
-
await context.reply({
|
|
35
|
-
embeds: [embed],
|
|
36
|
-
flags: MessageFlagsBitField.Flags.Ephemeral,
|
|
37
|
-
})
|
|
38
|
-
return false
|
|
39
|
-
}
|
|
40
|
-
return true
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
* ```
|
|
44
|
-
*/export function Guard(){return function(a){Reflect.hasMetadata("inversify:injectable",a)||injectable()(a),mainContainer.bind(a).toSelf().inTransientScope();// Bind any dependencies that the guard requires
|
|
45
|
-
var b=Reflect.getMetadata("design:paramtypes",a)||[];b.forEach(function(a){mainContainer.isBound(a)||mainContainer.bind(a).toSelf().inSingletonScope()})}}/**
|
|
46
|
-
* Type for a guard with parameters.
|
|
47
|
-
* This type defines a guard that requires additional parameters (other than the default constructor).
|
|
48
|
-
*//**
|
|
49
|
-
* Type guard to check if the object is a GuardWithParams.
|
|
50
|
-
* This function helps to check whether a guard is parameterized or not.
|
|
51
|
-
*
|
|
52
|
-
* @param guard - The guard to check.
|
|
53
|
-
* @returns `true` if the guard has parameters, otherwise `false`.
|
|
54
|
-
*/function isGuardWithParams(a){return"object"===_typeof(a)&&"provide"in a&&"params"in a}/**
|
|
55
|
-
* `@UseGuard()` decorator to apply one or more guards to methods.
|
|
56
|
-
* Guards are used to handle permission checks before executing a method.
|
|
57
|
-
* Each guard must use `@Guard` decorator and implement the `canActivate` method, which determines
|
|
58
|
-
* whether the method should be allowed to execute based on the provided context (Interaction, Message, or Reaction) and arguments.
|
|
59
|
-
* This decorator ensures that all guards pass validation before calling the original method.
|
|
60
|
-
* Supports guards that are parameterized (accepting additional parameters).
|
|
61
|
-
*
|
|
62
|
-
* @param guards - One or more guard classes to apply. These can be regular guards or guards with additional parameters.
|
|
63
|
-
* - If providing a guard with parameters, it should be an object with:
|
|
64
|
-
* - `provide`: The guard class to instantiate. Must implement `GuardInterface`.
|
|
65
|
-
* - `params`: A record of key-value pairs to be passed as additional properties to the guard instance.
|
|
66
|
-
* @returns A method decorator function that applies the guards to the method.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
|
-
* // Method-level usage
|
|
71
|
-
* @Command('profile-{id}', CommandType.BUTTON)
|
|
72
|
-
* @UseGuard(
|
|
73
|
-
* { provide: RateLimiterGuard, params: { limit: 2, window: 3000 } },
|
|
74
|
-
* ButtonInteractionGuard
|
|
75
|
-
* )
|
|
76
|
-
* async showProfileById(interaction: ButtonInteraction, { id }: { id: string }) {
|
|
77
|
-
* await interaction.reply(`Profile ID: ${id}`)
|
|
78
|
-
* }
|
|
79
|
-
*
|
|
80
|
-
* // Class-level usage
|
|
81
|
-
* @Controller()
|
|
82
|
-
* @UseGuard(GlobalGuard)
|
|
83
|
-
* class MyController {
|
|
84
|
-
* @Command('ping', CommandType.SLASH)
|
|
85
|
-
* async ping(interaction: ChatInputCommandInteraction) {
|
|
86
|
-
* await interaction.reply('Pong!')
|
|
87
|
-
* }
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*/export function UseGuard(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return function(a,c,d){if(d&&c)// Method Decorator
|
|
91
|
-
// Store guard metadata for later access (if needed)
|
|
92
|
-
applyGuards(d,b,c+""),Reflect.defineMetadata("guards",b,a,c);else if("function"==typeof a&&!c&&!d){// Class Decorator
|
|
93
|
-
var e=a.prototype,f=new Set,g=getCommandMap(e)||{};// 1. Get all methods to guard
|
|
94
|
-
Object.values(g).flat().forEach(function(a){return f.add(a.methodName)});var h=getMessageHandlers(e)||[];h.forEach(function(a){return f.add(a.method)});var i=getReactionHandlers(e)||[];i.forEach(function(a){return f.add(a.method)});var j,k=_createForOfIteratorHelper(f);try{for(k.s();!(j=k.n()).done;){var l=j.value,m=Object.getOwnPropertyDescriptor(e,l);m&&(applyGuards(m,b,l),Object.defineProperty(e,l,m),Reflect.defineMetadata("guards",b,e,l))}}catch(a){k.e(a)}finally{k.f()}}}}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
export * from './service.decorator.js';
|
|
19
|
-
export * from './command-builder.decorator.js';
|
|
20
|
-
export * from './controller.decorator.js';
|
|
21
|
-
export * from './guard.decorator.js';
|
|
22
|
-
export * from './app.decorator.js';
|
|
23
|
-
export * from './container.js';
|
package/dist/decorator/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/export*from"./service.decorator.js";export*from"./command-builder.decorator.js";export*from"./controller.decorator.js";export*from"./guard.decorator.js";export*from"./app.decorator.js";export*from"./container.js";
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
import 'reflect-metadata';
|
|
19
|
-
/**
|
|
20
|
-
* `@Service()` decorator to mark a class as a service that can be injected into controllers or used as standalone services.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* @Service()
|
|
25
|
-
* class MyService {
|
|
26
|
-
* constructor(private anotherService: AnotherService) {}
|
|
27
|
-
*
|
|
28
|
-
* doSomething() {
|
|
29
|
-
* this.anotherService.alsoDoSomething()
|
|
30
|
-
* console.log('Hello, World!')
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
* @returns A decorator function to apply to the class.
|
|
35
|
-
*/
|
|
36
|
-
export declare function Service<T>(): (target: new (...args: any[]) => T) => void;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/import"reflect-metadata";import{mainContainer}from"./container.js";import{injectable}from"inversify";import{Client}from"discord.js";/**
|
|
18
|
-
* `@Service()` decorator to mark a class as a service that can be injected into controllers or used as standalone services.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* @Service()
|
|
23
|
-
* class MyService {
|
|
24
|
-
* constructor(private anotherService: AnotherService) {}
|
|
25
|
-
*
|
|
26
|
-
* doSomething() {
|
|
27
|
-
* this.anotherService.alsoDoSomething()
|
|
28
|
-
* console.log('Hello, World!')
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
* @returns A decorator function to apply to the class.
|
|
33
|
-
*/export function Service(){return function(a){// Recursively bind dependencies
|
|
34
|
-
Reflect.hasMetadata("inversify:injectable",a)||injectable()(a),mainContainer.isBound(a)||mainContainer.bind(a).toSelf().inSingletonScope(),bindDependencies(a)}}function bindDependencies(a){// Get the constructor parameter types using Reflect metadata
|
|
35
|
-
var b=Reflect.getMetadata("design:paramtypes",a)||[];b.forEach(function(a){// Bind the dependency if not already bound
|
|
36
|
-
if(!mainContainer.isBound(a)){if(a.name===Client.name)return;try{Reflect.hasMetadata("inversify:injectable",a)||injectable()(a),mainContainer.bind(a).toSelf().inSingletonScope(),bindDependencies(a)}catch(b){console.warn("Could not bind dependency: ".concat((null===a||void 0===a?void 0:a.name)||a),b)}}})}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
export declare enum ControllerType {
|
|
19
|
-
BUTTON = "button",
|
|
20
|
-
MODAL_SUBMIT = "modal-submit",
|
|
21
|
-
SELECT_MENU = "select-menu",
|
|
22
|
-
REACTION = "reaction",
|
|
23
|
-
MESSAGE = "message",
|
|
24
|
-
SLASH = "slash",
|
|
25
|
-
CONTEXT_MENU = "context-menu"
|
|
26
|
-
}
|
|
27
|
-
export declare enum CommandType {
|
|
28
|
-
SLASH = "SLASH",
|
|
29
|
-
BUTTON = "BUTTON",
|
|
30
|
-
CONTEXT_MENU = "CONTEXT_MENU",
|
|
31
|
-
SELECT_MENU = "SELECT_MENU",
|
|
32
|
-
MODAL_SUBMIT = "MODAL_SUBMIT"
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Enum representing actions that can be performed on a message reaction.
|
|
36
|
-
*/
|
|
37
|
-
export declare enum ReactionHandlerAction {
|
|
38
|
-
/** Reaction added to a message. */
|
|
39
|
-
ADD = "ADD",
|
|
40
|
-
/** Reaction removed from a message. */
|
|
41
|
-
REMOVE = "REMOVE"
|
|
42
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/export var ControllerType=/*#__PURE__*/function(a){return a.BUTTON="button",a.MODAL_SUBMIT="modal-submit",a.SELECT_MENU="select-menu",a.REACTION="reaction",a.MESSAGE="message",a.SLASH="slash",a.CONTEXT_MENU="context-menu",a}({});export var CommandType=/*#__PURE__*/function(a){return a.SLASH="SLASH",a.BUTTON="BUTTON",a.CONTEXT_MENU="CONTEXT_MENU",a.SELECT_MENU="SELECT_MENU",a.MODAL_SUBMIT="MODAL_SUBMIT",a}({});/**
|
|
18
|
-
* Enum representing actions that can be performed on a message reaction.
|
|
19
|
-
*/export var ReactionHandlerAction=/*#__PURE__*/function(a){return a.ADD="ADD",a.REMOVE="REMOVE",a}({});
|
package/dist/enum/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MeoCord Framework
|
|
3
|
-
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
export { CommandType, ReactionHandlerAction } from './controller.enum.js';
|