Socket
Socket
Sign inDemoInstall

discordx

Package Overview
Dependencies
Maintainers
1
Versions
617
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discordx - npm Package Compare versions

Comparing version 11.1.2 to 11.1.3

4

build/cjs/Client.d.ts
import type { AutocompleteInteraction, ButtonInteraction, CommandInteraction, ContextMenuCommandInteraction, Interaction, Message, MessageReaction, ModalSubmitInteraction, PartialMessageReaction, PartialUser, SelectMenuInteraction, Snowflake, User } from "discord.js";
import { Client as ClientJS } from "discord.js";
import type { ClientOptions, DApplicationCommand, DApplicationCommandGroup, DApplicationCommandOption, DComponent, DDiscord, DiscordEvents, DOn, DReaction, DSimpleCommand, GuardFunction, IGuild, InitCommandOptions, IPrefix, IPrefixResolver, ISimpleCommandByName, SimpleCommandConfig } from "./index.js";
import type { ClientOptions, DApplicationCommand, DApplicationCommandGroup, DApplicationCommandOption, DComponent, DDiscord, DOn, DReaction, DSimpleCommand, GuardFunction, IGuild, InitCommandOptions, IPrefix, IPrefixResolver, ISimpleCommandByName, SimpleCommandConfig } from "./index.js";
import { MetadataStorage, SimpleCommandMessage, SimpleCommandParseType } from "./index.js";

@@ -236,3 +236,3 @@ /**

*/
trigger(event: DiscordEvents, params: any, once?: boolean): Promise<any[]>;
trigger(event: string, params: any, once?: boolean, rest?: boolean): Promise<any[]>;
/**

@@ -239,0 +239,0 @@ * Manually build client

@@ -938,5 +938,8 @@ "use strict";

*/
trigger(event,
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
trigger(event, params, once = false) {
return this.instance.trigger(this.guards, event, this, once)(params);
params, once = false, rest = false
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) {
return this.instance.trigger(this.guards, event, this, once, rest)(params);
}

@@ -958,7 +961,17 @@ /**

this.instance.usedEvents.map((on) => {
if (on.once) {
this.once(on.event, this.instance.trigger(this.guards, on.event, this, true));
if (on.rest) {
if (on.once) {
this.rest.once(on.event, this.instance.trigger(this.guards, on.event, this, true, true));
}
else {
this.rest.on(on.event, this.instance.trigger(this.guards, on.event, this, false, true));
}
}
else {
this.on(on.event, this.instance.trigger(this.guards, on.event, this));
if (on.once) {
this.once(on.event, this.instance.trigger(this.guards, on.event, this, true, false));
}
else {
this.on(on.event, this.instance.trigger(this.guards, on.event, this, false, false));
}
}

@@ -965,0 +978,0 @@ });

@@ -1,8 +0,7 @@

import type { ClientEvents } from "discord.js";
import type { DiscordEvents } from "../../index.js";
import { Method } from "./Method.js";
declare type CreateStructure = {
botIds?: string[];
event: DiscordEvents;
event: string;
once: boolean;
rest: boolean;
};

@@ -13,11 +12,14 @@ /**

export declare class DOn extends Method {
protected _event: DiscordEvents;
protected _event: string;
protected _once: boolean;
protected _rest: boolean;
protected _botIds: string[];
get botIds(): string[];
set botIds(value: string[]);
get event(): keyof ClientEvents;
set event(value: DiscordEvents);
get event(): string;
set event(value: string);
get once(): boolean;
set once(value: boolean);
get rest(): boolean;
set rest(value: boolean);
protected constructor(data: CreateStructure);

@@ -24,0 +26,0 @@ static create(data: CreateStructure): DOn;

@@ -11,2 +11,3 @@ "use strict";

_once;
_rest;
_botIds;

@@ -31,2 +32,8 @@ get botIds() {

}
get rest() {
return this._rest;
}
set rest(value) {
this._rest = value;
}
constructor(data) {

@@ -36,2 +43,3 @@ super();

this._once = data.once;
this._rest = data.rest;
this._botIds = data.botIds ?? [];

@@ -38,0 +46,0 @@ }

import type { MethodDecoratorEx } from "@discordx/internal";
import type { EventOptions } from "../../index.js";
import type { EventOptions, RestEventOptions } from "../../index.js";
/**

@@ -23,1 +23,4 @@ * Handle discord events with a defined handler

export declare function On(options: EventOptions): MethodDecoratorEx;
export declare namespace On {
var rest: (options?: RestEventOptions | undefined) => MethodDecoratorEx;
}

@@ -22,2 +22,3 @@ "use strict";

once: false,
rest: false,
}).decorate(clazz.constructor, key, descriptor?.value);

@@ -28,2 +29,24 @@ index_js_1.MetadataStorage.instance.addOn(on);

exports.On = On;
/**
* Handle discord rest events with a defined handler
*
* @param options - Rest event options
* ___
*
* [View Documentation](https://discord-ts.js.org/docs/decorators/general/on#rest)
*
* @category Decorator
*/
On.rest = function (options) {
return function (target, key, descriptor) {
const clazz = target;
const on = index_js_1.DOn.create({
botIds: options?.botIds,
event: options?.event ?? key,
once: false,
rest: true,
}).decorate(clazz.constructor, key, descriptor?.value);
index_js_1.MetadataStorage.instance.addOn(on);
};
};
//# sourceMappingURL=On.js.map
import type { MethodDecoratorEx } from "@discordx/internal";
import type { EventOptions } from "../../index.js";
import type { EventOptions, RestEventOptions } from "../../index.js";
/**

@@ -23,1 +23,4 @@ * Handle discord events once only with a defined handler

export declare function Once(options: EventOptions): MethodDecoratorEx;
export declare namespace Once {
var rest: (options?: RestEventOptions | undefined) => MethodDecoratorEx;
}

@@ -22,2 +22,3 @@ "use strict";

once: true,
rest: false,
}).decorate(clazz.constructor, key, descriptor.value);

@@ -28,2 +29,24 @@ index_js_1.MetadataStorage.instance.addOn(on);

exports.Once = Once;
/**
* Handle discord rest events with a defined handler
*
* @param options - Rest event options
* ___
*
* [View Documentation](https://discord-ts.js.org/docs/decorators/general/once#rest)
*
* @category Decorator
*/
Once.rest = function (options) {
return function (target, key, descriptor) {
const clazz = target;
const on = index_js_1.DOn.create({
botIds: options?.botIds,
event: options?.event ?? key,
once: true,
rest: true,
}).decorate(clazz.constructor, key, descriptor?.value);
index_js_1.MetadataStorage.instance.addOn(on);
};
};
//# sourceMappingURL=Once.js.map
import type { Decorator } from "@discordx/internal";
import { Modifier } from "@discordx/internal";
import type { ArgsOf, Client, DApplicationCommandGroup, DDiscord, DGuard, DiscordEvents, DSimpleCommandOption, GuardFunction, ISimpleCommandByName } from "../../index.js";
import type { Client, DApplicationCommandGroup, DDiscord, DGuard, DSimpleCommandOption, GuardFunction, ISimpleCommandByName } from "../../index.js";
import { DApplicationCommand, DApplicationCommandOption, DComponent, DOn, DReaction, DSimpleCommand } from "../../index.js";

@@ -83,3 +83,3 @@ /**

*/
trigger<Event extends DiscordEvents>(guards: GuardFunction[], event: Event, client: Client, once?: boolean): (...params: ArgsOf<Event>) => Promise<any>;
trigger(guards: GuardFunction[], event: string, client: Client, once?: boolean, rest?: boolean): (...params: any[]) => Promise<any>;
}

@@ -403,3 +403,3 @@ "use strict";

*/
trigger(guards, event, client, once = false
trigger(guards, event, client, once = false, rest = false
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -410,4 +410,5 @@ ) {

const eventsToExecute = this._events.filter((on) => {
return on.event === event && on.once === once;
return on.event === event && on.once === once && on.rest === rest;
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return async (...params) => {

@@ -414,0 +415,0 @@ await Promise.all(eventsToExecute.map(async (ev) => {

@@ -1,2 +0,2 @@

import type { ClientEvents, LocalizationMap, PermissionResolvable } from "discord.js";
import type { ClientEvents, LocalizationMap, PermissionResolvable, RestEvents } from "discord.js";
import type { Client, IGuild, Next, NotEmpty } from "../../index.js";

@@ -10,6 +10,22 @@ /**

/**
* Discord events
* Type the arguments of an event
* ___
* [View Documentation](https://discord-ts.js.org/docs/general/restargsof)
*/
export declare type DiscordEvents = keyof ClientEvents;
export declare type RestArgsOf<K extends keyof RestEvents> = RestEvents[K];
/**
* Event options
*/
export declare type EventOptions = {
botIds?: string[];
event: keyof ClientEvents;
};
/**
* Rest event options
*/
export declare type RestEventOptions = {
botIds?: string[];
event: keyof RestEvents;
};
/**
* Guard function

@@ -71,9 +87,2 @@ */

/**
* Event options
*/
export declare type EventOptions = {
botIds?: string[];
event: DiscordEvents;
};
/**
* Reaction options

@@ -80,0 +89,0 @@ */

import type { AutocompleteInteraction, ButtonInteraction, CommandInteraction, ContextMenuCommandInteraction, Interaction, Message, MessageReaction, ModalSubmitInteraction, PartialMessageReaction, PartialUser, SelectMenuInteraction, Snowflake, User } from "discord.js";
import { Client as ClientJS } from "discord.js";
import type { ClientOptions, DApplicationCommand, DApplicationCommandGroup, DApplicationCommandOption, DComponent, DDiscord, DiscordEvents, DOn, DReaction, DSimpleCommand, GuardFunction, IGuild, InitCommandOptions, IPrefix, IPrefixResolver, ISimpleCommandByName, SimpleCommandConfig } from "./index.js";
import type { ClientOptions, DApplicationCommand, DApplicationCommandGroup, DApplicationCommandOption, DComponent, DDiscord, DOn, DReaction, DSimpleCommand, GuardFunction, IGuild, InitCommandOptions, IPrefix, IPrefixResolver, ISimpleCommandByName, SimpleCommandConfig } from "./index.js";
import { MetadataStorage, SimpleCommandMessage, SimpleCommandParseType } from "./index.js";

@@ -236,3 +236,3 @@ /**

*/
trigger(event: DiscordEvents, params: any, once?: boolean): Promise<any[]>;
trigger(event: string, params: any, once?: boolean, rest?: boolean): Promise<any[]>;
/**

@@ -239,0 +239,0 @@ * Manually build client

@@ -934,5 +934,8 @@ import { DIService } from "@discordx/di";

*/
trigger(event,
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
trigger(event, params, once = false) {
return this.instance.trigger(this.guards, event, this, once)(params);
params, once = false, rest = false
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) {
return this.instance.trigger(this.guards, event, this, once, rest)(params);
}

@@ -954,7 +957,17 @@ /**

this.instance.usedEvents.map((on) => {
if (on.once) {
this.once(on.event, this.instance.trigger(this.guards, on.event, this, true));
if (on.rest) {
if (on.once) {
this.rest.once(on.event, this.instance.trigger(this.guards, on.event, this, true, true));
}
else {
this.rest.on(on.event, this.instance.trigger(this.guards, on.event, this, false, true));
}
}
else {
this.on(on.event, this.instance.trigger(this.guards, on.event, this));
if (on.once) {
this.once(on.event, this.instance.trigger(this.guards, on.event, this, true, false));
}
else {
this.on(on.event, this.instance.trigger(this.guards, on.event, this, false, false));
}
}

@@ -961,0 +974,0 @@ });

@@ -1,8 +0,7 @@

import type { ClientEvents } from "discord.js";
import type { DiscordEvents } from "../../index.js";
import { Method } from "./Method.js";
declare type CreateStructure = {
botIds?: string[];
event: DiscordEvents;
event: string;
once: boolean;
rest: boolean;
};

@@ -13,11 +12,14 @@ /**

export declare class DOn extends Method {
protected _event: DiscordEvents;
protected _event: string;
protected _once: boolean;
protected _rest: boolean;
protected _botIds: string[];
get botIds(): string[];
set botIds(value: string[]);
get event(): keyof ClientEvents;
set event(value: DiscordEvents);
get event(): string;
set event(value: string);
get once(): boolean;
set once(value: boolean);
get rest(): boolean;
set rest(value: boolean);
protected constructor(data: CreateStructure);

@@ -24,0 +26,0 @@ static create(data: CreateStructure): DOn;

@@ -8,2 +8,3 @@ import { Method } from "./Method.js";

_once;
_rest;
_botIds;

@@ -28,2 +29,8 @@ get botIds() {

}
get rest() {
return this._rest;
}
set rest(value) {
this._rest = value;
}
constructor(data) {

@@ -33,2 +40,3 @@ super();

this._once = data.once;
this._rest = data.rest;
this._botIds = data.botIds ?? [];

@@ -35,0 +43,0 @@ }

import type { MethodDecoratorEx } from "@discordx/internal";
import type { EventOptions } from "../../index.js";
import type { EventOptions, RestEventOptions } from "../../index.js";
/**

@@ -23,1 +23,4 @@ * Handle discord events with a defined handler

export declare function On(options: EventOptions): MethodDecoratorEx;
export declare namespace On {
var rest: (options?: RestEventOptions | undefined) => MethodDecoratorEx;
}

@@ -19,2 +19,3 @@ import { DOn, MetadataStorage } from "../../index.js";

once: false,
rest: false,
}).decorate(clazz.constructor, key, descriptor?.value);

@@ -24,2 +25,24 @@ MetadataStorage.instance.addOn(on);

}
/**
* Handle discord rest events with a defined handler
*
* @param options - Rest event options
* ___
*
* [View Documentation](https://discord-ts.js.org/docs/decorators/general/on#rest)
*
* @category Decorator
*/
On.rest = function (options) {
return function (target, key, descriptor) {
const clazz = target;
const on = DOn.create({
botIds: options?.botIds,
event: options?.event ?? key,
once: false,
rest: true,
}).decorate(clazz.constructor, key, descriptor?.value);
MetadataStorage.instance.addOn(on);
};
};
//# sourceMappingURL=On.js.map
import type { MethodDecoratorEx } from "@discordx/internal";
import type { EventOptions } from "../../index.js";
import type { EventOptions, RestEventOptions } from "../../index.js";
/**

@@ -23,1 +23,4 @@ * Handle discord events once only with a defined handler

export declare function Once(options: EventOptions): MethodDecoratorEx;
export declare namespace Once {
var rest: (options?: RestEventOptions | undefined) => MethodDecoratorEx;
}

@@ -19,2 +19,3 @@ import { DOn, MetadataStorage } from "../../index.js";

once: true,
rest: false,
}).decorate(clazz.constructor, key, descriptor.value);

@@ -24,2 +25,24 @@ MetadataStorage.instance.addOn(on);

}
/**
* Handle discord rest events with a defined handler
*
* @param options - Rest event options
* ___
*
* [View Documentation](https://discord-ts.js.org/docs/decorators/general/once#rest)
*
* @category Decorator
*/
Once.rest = function (options) {
return function (target, key, descriptor) {
const clazz = target;
const on = DOn.create({
botIds: options?.botIds,
event: options?.event ?? key,
once: true,
rest: true,
}).decorate(clazz.constructor, key, descriptor?.value);
MetadataStorage.instance.addOn(on);
};
};
//# sourceMappingURL=Once.js.map
import type { Decorator } from "@discordx/internal";
import { Modifier } from "@discordx/internal";
import type { ArgsOf, Client, DApplicationCommandGroup, DDiscord, DGuard, DiscordEvents, DSimpleCommandOption, GuardFunction, ISimpleCommandByName } from "../../index.js";
import type { Client, DApplicationCommandGroup, DDiscord, DGuard, DSimpleCommandOption, GuardFunction, ISimpleCommandByName } from "../../index.js";
import { DApplicationCommand, DApplicationCommandOption, DComponent, DOn, DReaction, DSimpleCommand } from "../../index.js";

@@ -83,3 +83,3 @@ /**

*/
trigger<Event extends DiscordEvents>(guards: GuardFunction[], event: Event, client: Client, once?: boolean): (...params: ArgsOf<Event>) => Promise<any>;
trigger(guards: GuardFunction[], event: string, client: Client, once?: boolean, rest?: boolean): (...params: any[]) => Promise<any>;
}

@@ -399,3 +399,3 @@ import { DIService } from "@discordx/di";

*/
trigger(guards, event, client, once = false
trigger(guards, event, client, once = false, rest = false
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -406,4 +406,5 @@ ) {

const eventsToExecute = this._events.filter((on) => {
return on.event === event && on.once === once;
return on.event === event && on.once === once && on.rest === rest;
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return async (...params) => {

@@ -410,0 +411,0 @@ await Promise.all(eventsToExecute.map(async (ev) => {

@@ -1,2 +0,2 @@

import type { ClientEvents, LocalizationMap, PermissionResolvable } from "discord.js";
import type { ClientEvents, LocalizationMap, PermissionResolvable, RestEvents } from "discord.js";
import type { Client, IGuild, Next, NotEmpty } from "../../index.js";

@@ -10,6 +10,22 @@ /**

/**
* Discord events
* Type the arguments of an event
* ___
* [View Documentation](https://discord-ts.js.org/docs/general/restargsof)
*/
export declare type DiscordEvents = keyof ClientEvents;
export declare type RestArgsOf<K extends keyof RestEvents> = RestEvents[K];
/**
* Event options
*/
export declare type EventOptions = {
botIds?: string[];
event: keyof ClientEvents;
};
/**
* Rest event options
*/
export declare type RestEventOptions = {
botIds?: string[];
event: keyof RestEvents;
};
/**
* Guard function

@@ -71,9 +87,2 @@ */

/**
* Event options
*/
export declare type EventOptions = {
botIds?: string[];
event: DiscordEvents;
};
/**
* Reaction options

@@ -80,0 +89,0 @@ */

{
"name": "discordx",
"version": "11.1.2",
"version": "11.1.3",
"private": false,

@@ -5,0 +5,0 @@ "description": "Create a discord bot with TypeScript and Decorators!",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc