discordx
Advanced tools
Comparing version 5.1.2 to 5.1.3
import { ApplicationCommandOptionChoice } from "discord.js"; | ||
import { Decorator } from "../classes/Decorator"; | ||
import { Decorator } from "./Decorator"; | ||
export declare class DChoice extends Decorator { | ||
@@ -4,0 +4,0 @@ private _name; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DChoice = void 0; | ||
const Decorator_1 = require("../classes/Decorator"); | ||
const Decorator_1 = require("./Decorator"); | ||
class DChoice extends Decorator_1.Decorator { | ||
@@ -6,0 +6,0 @@ constructor() { |
@@ -15,6 +15,4 @@ export declare class Decorator { | ||
get isClass(): boolean; | ||
protected constructor(); | ||
decorateUnknown(classRef: Function | Object, key?: string, method?: PropertyDescriptor, index?: number): this; | ||
decorateUnknown(classRef: Record<string, any>, key?: string, method?: PropertyDescriptor, index?: number): this; | ||
decorate(classRef: Function, key: string, method?: Function, from?: Function, index?: number): this; | ||
update(): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Decorator = void 0; | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
const logic_1 = require("../../logic"); | ||
@@ -8,3 +9,2 @@ class Decorator { | ||
this._index = undefined; | ||
// empty constructor | ||
} | ||
@@ -38,6 +38,4 @@ get index() { | ||
const decorateAClass = logic_1.DecoratorUtils.decorateAClass(method) && index === undefined; | ||
const finalClassRef = decorateAClass | ||
? classRef | ||
: classRef.constructor; | ||
const finalKey = decorateAClass ? finalClassRef.name : key; | ||
const finalClassRef = classRef.constructor; | ||
const finalKey = key !== null && key !== void 0 ? key : finalClassRef.name; | ||
const finalMethod = decorateAClass ? finalClassRef : method === null || method === void 0 ? void 0 : method.value; | ||
@@ -52,10 +50,6 @@ return this.decorate(finalClassRef, finalKey, finalMethod, finalClassRef, index); | ||
this._index = index; | ||
this.update(); | ||
return this; | ||
} | ||
update() { | ||
// empty function | ||
} | ||
} | ||
exports.Decorator = Decorator; | ||
//# sourceMappingURL=Decorator.js.map |
import { ApplicationCommandOptionData } from "discord.js"; | ||
import { Decorator } from "../classes/Decorator"; | ||
import { Decorator } from "./Decorator"; | ||
import { DChoice, OptionValueType, StringOptionType } from "../.."; | ||
@@ -4,0 +4,0 @@ export declare class DOption extends Decorator { |
@@ -5,3 +5,3 @@ "use strict"; | ||
const discord_js_1 = require("discord.js"); | ||
const Decorator_1 = require("../classes/Decorator"); | ||
const Decorator_1 = require("./Decorator"); | ||
const __1 = require("../.."); | ||
@@ -8,0 +8,0 @@ class DOption extends Decorator_1.Decorator { |
@@ -33,3 +33,3 @@ import { DGuard, DDiscord } from "../.."; | ||
*/ | ||
abstract parseParams(...params: any[]): any; | ||
abstract parseParams(...params: any[]): any[]; | ||
/** | ||
@@ -36,0 +36,0 @@ * Execute a guard with params |
@@ -1,2 +0,3 @@ | ||
export declare function Bot(botID: string): any; | ||
export declare function Bot(...botIDs: string[]): any; | ||
import { ClassMethodDecorator } from "../../types/public/decorators"; | ||
export declare function Bot(botID: string): ClassMethodDecorator; | ||
export declare function Bot(...botIDs: string[]): ClassMethodDecorator; |
@@ -12,3 +12,3 @@ "use strict"; | ||
function Bot(...botIDs) { | ||
return (target, key, descriptor) => { | ||
return function (target, key, descriptor) { | ||
__1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { | ||
@@ -15,0 +15,0 @@ original.botIds = [ |
@@ -1,1 +0,2 @@ | ||
export declare function Button(id: string): any; | ||
import { MethodDecoratorEx } from "../../types/public/decorators"; | ||
export declare function Button(id: string): MethodDecoratorEx; |
@@ -1,2 +0,3 @@ | ||
export declare function Choice(name: string, value: number): any; | ||
export declare function Choice(name: string, value: string): any; | ||
import { ParameterDecoratorEx } from "../../types/public/decorators"; | ||
export declare function Choice(name: string, value: number): ParameterDecoratorEx; | ||
export declare function Choice(name: string, value: string): ParameterDecoratorEx; |
import { ChoicesType } from "../.."; | ||
export declare function Choices(choices: ChoicesType): any; | ||
import { ParameterDecoratorEx } from "../../types/public/decorators"; | ||
export declare function Choices(choices: ChoicesType): ParameterDecoratorEx; |
@@ -6,3 +6,3 @@ "use strict"; | ||
function Choices(choices) { | ||
return (target, key, index) => { | ||
return function (target, key, index) { | ||
__1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { | ||
@@ -9,0 +9,0 @@ const arrayChoices = Object.keys(choices).map((key) => { |
@@ -0,4 +1,5 @@ | ||
import { MethodDecoratorEx } from "../../types/public/decorators"; | ||
import { CommandParams } from "../params/CommandParams"; | ||
export declare function Command(): any; | ||
export declare function Command(name: string): any; | ||
export declare function Command(name: string, params: CommandParams): any; | ||
export declare function Command(): MethodDecoratorEx; | ||
export declare function Command(name: string): MethodDecoratorEx; | ||
export declare function Command(name: string, params: CommandParams): MethodDecoratorEx; |
@@ -8,3 +8,3 @@ "use strict"; | ||
function Command(name, params) { | ||
return (target, key) => { | ||
return function (target, key) { | ||
name = name !== null && name !== void 0 ? name : key; | ||
@@ -11,0 +11,0 @@ name = name.toLocaleLowerCase(); |
import "reflect-metadata"; | ||
export declare function CommandOption(name: string): any; | ||
import { ParameterDecoratorEx } from "../../types/public/decorators"; | ||
export declare function CommandOption(name: string): ParameterDecoratorEx; | ||
export declare function CommandOption(name: string, params: { | ||
description?: string; | ||
type?: "string" | "number" | "boolean"; | ||
}): any; | ||
}): ParameterDecoratorEx; |
@@ -9,6 +9,7 @@ "use strict"; | ||
function CommandOption(name, params) { | ||
return (target, key, index) => { | ||
return function (target, key, index) { | ||
var _a; | ||
const type = (_a = params === null || params === void 0 ? void 0 : params.type) !== null && _a !== void 0 ? _a : Reflect.getMetadata("design:paramtypes", target, key)[index] | ||
.name.toLowerCase(); | ||
const type = (_a = params === null || params === void 0 ? void 0 : params.type) !== null && _a !== void 0 ? _a : | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
Reflect.getMetadata("design:paramtypes", target, key)[index].name.toLowerCase(); | ||
const option = DCommandOption_1.DCommandOption.create(name !== null && name !== void 0 ? name : key, type, params === null || params === void 0 ? void 0 : params.description).decorate(target.constructor, key, target[key], target.constructor, index); | ||
@@ -15,0 +16,0 @@ __1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { |
@@ -1,2 +0,2 @@ | ||
export declare function DefaultPermission(): any; | ||
export declare function DefaultPermission(permission: boolean): any; | ||
import { ClassMethodDecorator } from "../../types/public/decorators"; | ||
export declare function DefaultPermission(permission?: boolean): ClassMethodDecorator; |
@@ -9,3 +9,5 @@ "use strict"; | ||
function DefaultPermission(permission) { | ||
return (target, key, descriptor) => { | ||
return function ( | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
target, key, descriptor) { | ||
__1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { | ||
@@ -12,0 +14,0 @@ original.defaultPermission = permission !== null && permission !== void 0 ? permission : true; |
@@ -1,1 +0,2 @@ | ||
export declare function Description(description: string): any; | ||
import { MethodDecoratorEx } from "../../types/public/decorators"; | ||
export declare function Description(description: string): MethodDecoratorEx; |
@@ -8,3 +8,3 @@ "use strict"; | ||
function Description(description) { | ||
return (target, key, descriptor) => { | ||
return function (target, key, descriptor) { | ||
__1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { | ||
@@ -11,0 +11,0 @@ original.description = description; |
@@ -5,2 +5,2 @@ /** | ||
*/ | ||
export declare function Discord(): (target: Function) => void; | ||
export declare function Discord(): (target: Record<string, any>) => void; |
@@ -10,4 +10,4 @@ "use strict"; | ||
function Discord() { | ||
return (target) => { | ||
const instance = __1.DDiscord.create(target.name).decorate(target, target.name); | ||
return function (target) { | ||
const instance = __1.DDiscord.create(target.name).decorate(target.constructor, target.name); | ||
__1.MetadataStorage.instance.addDiscord(instance); | ||
@@ -14,0 +14,0 @@ }; |
import { SubCommand } from "../../types"; | ||
export declare function Group(group: string): any; | ||
export declare function Group(subCommands: SubCommand): any; | ||
export declare function Group(group: string, description: string): any; | ||
export declare function Group(group: string, subCommands: SubCommand): any; | ||
export declare function Group(group: string, description: string, subCommands: SubCommand): any; | ||
import { ClassMethodDecorator } from "../../types/public/decorators"; | ||
export declare function Group(group: string): ClassMethodDecorator; | ||
export declare function Group(subCommands: SubCommand): ClassMethodDecorator; | ||
export declare function Group(group: string, description: string): ClassMethodDecorator; | ||
export declare function Group(group: string, subCommands: SubCommand): ClassMethodDecorator; | ||
export declare function Group(group: string, description: string, subCommands: SubCommand): ClassMethodDecorator; |
@@ -7,38 +7,30 @@ "use strict"; | ||
function Group(groupOrSubcommands, subCommandsOrDescription, subCommands) { | ||
return (target, key, descriptor) => { | ||
var _a; | ||
return function (target, key, descriptor) { | ||
// Detect the type of parameters for overloading | ||
const isGroup = typeof groupOrSubcommands === "string"; | ||
const group = isGroup | ||
? groupOrSubcommands.toLocaleLowerCase() | ||
: undefined; | ||
const isDescription = typeof subCommandsOrDescription === "string"; | ||
const description = isDescription | ||
? subCommandsOrDescription | ||
: undefined; | ||
if (subCommandsOrDescription !== undefined && !isDescription) { | ||
subCommands = subCommandsOrDescription; | ||
} | ||
subCommands = isGroup ? subCommands : groupOrSubcommands; | ||
if (!descriptor) { | ||
if (typeof groupOrSubcommands === "string") { | ||
const groupName = groupOrSubcommands.toLocaleLowerCase(); | ||
const groupDescription = typeof subCommandsOrDescription === "string" | ||
? subCommandsOrDescription | ||
: undefined; | ||
// Add the group to groups if @Group decorate a class | ||
if (group) { | ||
const group = DGroup_1.DGroup.create((_a = groupOrSubcommands) !== null && _a !== void 0 ? _a : key, { description }).decorate(target, target.name); | ||
if (!descriptor) { | ||
const group = DGroup_1.DGroup.create(groupName, { | ||
description: groupDescription, | ||
}).decorate(target.constructor, target.name); | ||
__1.MetadataStorage.instance.addGroup(group); | ||
} | ||
// Create a subgroup if @Group decorate a method | ||
if (subCommands) { | ||
Object.keys(subCommands).forEach((key) => { | ||
const group = DGroup_1.DGroup.create(key, { | ||
description: subCommands === null || subCommands === void 0 ? void 0 : subCommands[key], | ||
}).decorate(target, target.name); | ||
__1.MetadataStorage.instance.addSubGroup(group); | ||
}); | ||
else { | ||
__1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { | ||
original.subgroup = groupName; | ||
}, __1.DSlash).decorate(target.constructor, key !== null && key !== void 0 ? key : target.constructor.name)); | ||
} | ||
} | ||
else { | ||
// If @Group decorate a method edit the method and add it to subgroup | ||
__1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { | ||
original.subgroup = group; | ||
}, __1.DSlash).decorate(target.constructor, key)); | ||
// Create a subgroup if @Group decorate a method | ||
Object.keys(groupOrSubcommands).forEach((key) => { | ||
const group = DGroup_1.DGroup.create(key, { | ||
description: subCommands === null || subCommands === void 0 ? void 0 : subCommands[key], | ||
}).decorate(target.constructor, target.name); | ||
__1.MetadataStorage.instance.addSubGroup(group); | ||
}); | ||
} | ||
@@ -45,0 +37,0 @@ }; |
import { GuardFunction } from "../.."; | ||
export declare function Guard<Type = any, DatasType = any>(...fns: GuardFunction<Type, DatasType>[]): (target: Function | Object, key?: string | undefined, descriptor?: PropertyDescriptor | undefined) => void; | ||
export declare function Guard<Type = any, DatasType = any>(...fns: GuardFunction<Type, DatasType>[]): (target: Record<string, any>, key?: string | undefined, descriptor?: PropertyDescriptor | undefined) => void; |
@@ -12,3 +12,3 @@ "use strict"; | ||
function Guard(...fns) { | ||
return (target, key, descriptor) => { | ||
return function (target, key, descriptor) { | ||
const guards = fns.map((fn) => { | ||
@@ -15,0 +15,0 @@ return __1.DGuard.create(fn).decorateUnknown(target, key, descriptor); |
@@ -1,2 +0,3 @@ | ||
export declare function Guild(guildID: string): any; | ||
export declare function Guild(...guildIDs: string[]): any; | ||
import { ClassMethodDecorator } from "../../types/public/decorators"; | ||
export declare function Guild(guildID: string): ClassMethodDecorator; | ||
export declare function Guild(...guildIDs: string[]): ClassMethodDecorator; |
@@ -11,3 +11,3 @@ "use strict"; | ||
function Guild(...guildIDs) { | ||
return (target, key, descriptor) => { | ||
return function (target, key, descriptor) { | ||
__1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { | ||
@@ -14,0 +14,0 @@ original.guilds = [ |
@@ -1,1 +0,1 @@ | ||
export declare function Name(name: string): any; | ||
export declare function Name(name: string): (target: Record<string, any>, key?: string | undefined, descriptor?: PropertyDescriptor | undefined) => void; |
@@ -7,3 +7,3 @@ "use strict"; | ||
function Name(name) { | ||
return (target, key, descriptor) => { | ||
return function (target, key, descriptor) { | ||
__1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { | ||
@@ -10,0 +10,0 @@ original.name = name; |
import { DiscordEvents } from "../.."; | ||
import { MethodDecoratorEx } from "../../types/public/decorators"; | ||
import { EventParams } from "../params/EventParams"; | ||
@@ -7,3 +8,3 @@ /** | ||
*/ | ||
export declare function On(event: DiscordEvents): any; | ||
export declare function On(event: DiscordEvents, params?: EventParams): any; | ||
export declare function On(event: DiscordEvents): MethodDecoratorEx; | ||
export declare function On(event: DiscordEvents, params?: EventParams): MethodDecoratorEx; |
@@ -6,3 +6,3 @@ "use strict"; | ||
function On(event, params) { | ||
return (target, key, descriptor) => { | ||
return function (target, key, descriptor) { | ||
const on = __1.DOn.create(event, false, params === null || params === void 0 ? void 0 : params.botIds).decorate(target.constructor, key, descriptor === null || descriptor === void 0 ? void 0 : descriptor.value); | ||
@@ -9,0 +9,0 @@ __1.MetadataStorage.instance.addOn(on); |
import { DiscordEvents } from "../.."; | ||
import { MethodDecoratorEx } from "../../types/public/decorators"; | ||
import { EventParams } from "../params/EventParams"; | ||
@@ -7,3 +8,3 @@ /** | ||
*/ | ||
export declare function Once(event: DiscordEvents): any; | ||
export declare function Once(event: DiscordEvents, params?: EventParams): any; | ||
export declare function Once(event: DiscordEvents): MethodDecoratorEx; | ||
export declare function Once(event: DiscordEvents, params?: EventParams): MethodDecoratorEx; |
@@ -6,3 +6,3 @@ "use strict"; | ||
function Once(event, params) { | ||
return (target, key, descriptor) => { | ||
return function (target, key, descriptor) { | ||
const on = __1.DOn.create(event, true, params === null || params === void 0 ? void 0 : params.botIds).decorate(target.constructor, key, descriptor.value); | ||
@@ -9,0 +9,0 @@ __1.MetadataStorage.instance.addOn(on); |
import "reflect-metadata"; | ||
import { OptionParams } from "../.."; | ||
export declare function Option(name: string): any; | ||
export declare function Option(name: string, params: OptionParams): any; | ||
import { ParameterDecoratorEx } from "../../types/public/decorators"; | ||
export declare function Option(name: string): ParameterDecoratorEx; | ||
export declare function Option(name: string, params: OptionParams): ParameterDecoratorEx; |
@@ -10,3 +10,7 @@ "use strict"; | ||
var _a; | ||
const type = (_a = params === null || params === void 0 ? void 0 : params.type) !== null && _a !== void 0 ? _a : Reflect.getMetadata("design:paramtypes", target, key)[index]; | ||
const type = (_a = params === null || params === void 0 ? void 0 : params.type) !== null && _a !== void 0 ? _a : | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
Reflect.getMetadata("design:paramtypes", target, key)[index].name.toUpperCase(); | ||
if (type === "OBJECT") | ||
throw Error("invalid option type"); | ||
const option = __1.DOption.create(name !== null && name !== void 0 ? name : key, type, params === null || params === void 0 ? void 0 : params.description, params === null || params === void 0 ? void 0 : params.required, index).decorate(target.constructor, key, target[key], target.constructor, index); | ||
@@ -13,0 +17,0 @@ option.isNode = true; |
import { ApplicationCommandPermissionData } from "discord.js"; | ||
export declare function Permission(permission: ApplicationCommandPermissionData): any; | ||
export declare function Permission(...permission: ApplicationCommandPermissionData[]): any; | ||
import { ClassMethodDecorator } from "../../types/public/decorators"; | ||
export declare function Permission(permission: ApplicationCommandPermissionData): ClassMethodDecorator; | ||
export declare function Permission(...permission: ApplicationCommandPermissionData[]): ClassMethodDecorator; |
@@ -9,3 +9,3 @@ "use strict"; | ||
function Permission(...permission) { | ||
return (target, key, descriptor) => { | ||
return function (target, key, descriptor) { | ||
__1.MetadataStorage.instance.addModifier(__1.Modifier.create((original) => { | ||
@@ -12,0 +12,0 @@ original.permissions = [...original.permissions, ...permission]; |
export declare function SelectMenu(id: string, params?: { | ||
guilds?: string[]; | ||
botIds?: []; | ||
}): (target: Object, key: string) => void; | ||
botIds?: string[]; | ||
}): (target: Record<string, any>, key: string) => void; |
@@ -6,3 +6,3 @@ "use strict"; | ||
function SelectMenu(id, params) { | ||
return (target, key) => { | ||
return function (target, key) { | ||
const button = __1.DSelectMenu.create(id, params === null || params === void 0 ? void 0 : params.guilds, params === null || params === void 0 ? void 0 : params.botIds).decorate(target.constructor, key, target[key]); | ||
@@ -9,0 +9,0 @@ __1.MetadataStorage.instance.addSelectMenu(button); |
import { SlashParams } from "../.."; | ||
export declare function Slash(): any; | ||
export declare function Slash(name: string): any; | ||
export declare function Slash(name: string, params: SlashParams): any; | ||
import { MethodDecoratorEx } from "../../types/public/decorators"; | ||
export declare function Slash(name?: string): MethodDecoratorEx; | ||
export declare function Slash(name?: string, params?: SlashParams): MethodDecoratorEx; |
@@ -6,3 +6,3 @@ "use strict"; | ||
function Slash(name, params) { | ||
return (target, key) => { | ||
return function (target, key) { | ||
name = name !== null && name !== void 0 ? name : key; | ||
@@ -9,0 +9,0 @@ name = name.toLocaleLowerCase(); |
{ | ||
"name": "discordx", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"description": "Create your discord bot by using TypeScript and decorators!", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
191180
180
3043