Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gary50613/discord.js-command-handler

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gary50613/discord.js-command-handler - npm Package Compare versions

Comparing version 2.3.4 to 2.4.0

docs/README-zh.md

6

package.json
{
"name": "@gary50613/discord.js-command-handler",
"version": "2.3.4",
"version": "2.4.0",
"description": "simple discord.js command handler",
"main": "index.js",
"main": "src/index.js",
"types": "types/index.d.ts",
"directories": {
"doc": "doc",
"doc": "docs",
"test": "test"

@@ -10,0 +10,0 @@ },

# djs-command-handler
> Simple command handler for discord.js
[繁體中文](doc/README-zh.md)
[繁體中文](docs/README-zh.md)

@@ -6,0 +6,0 @@ ***

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

const Command = require("../../Base/Command");
const Command = require("../../src/base/Command");

@@ -3,0 +3,0 @@ class Ping extends Command {

const Discord = require('discord.js')
const bot = new Discord.Client()
require("../index")(bot, {
require("../src")(bot, {
prefix: '.',

@@ -11,4 +11,6 @@ ratelimit: {

bot.commands.register(new (require("./commands/ping"))())
// bot.commands.register(new (require("./commands/ping"))())
bot.commands.loadFolder('./commands')
bot.commands.on("error", (e) => console.error(e))

@@ -15,0 +17,0 @@ bot.commands.on("promiseError", (e) => console.error(e))

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

const Interaction = require("../../Base/Interaction")
const Interaction = require("../../src/base/Interaction")
const Discord = require("discord.js")

@@ -3,0 +3,0 @@

@@ -6,130 +6,127 @@ import { Message, MessageEmbed, Client, PermissionResolvable, GuildMember, Guild } from "discord.js"

export default function (client: Client, initOptions: initOption): void;
}
export type InteractionMessageContent = string | { embeds?: MessageEmbed, content: string }
export type InteractionMessageContent = string | { embeds?: MessageEmbed, content: string }
export interface RateLimitOptions {
enable?: boolean
interval?: number
bypass?: {
users?: string[], // specific users ID can bypass ratelimit
permissions?: keyof PermissionResolvable[], // specific perimissions FLAG can bypass ratelimit
roles?: string[] // // specific roles ID can bypass ratelimit
}
export interface RateLimitOptions {
enable?: boolean
interval?: number
bypass?: {
users?: string[], // specific users ID can bypass ratelimit
permissions?: keyof PermissionResolvable[], // specific perimissions FLAG can bypass ratelimit
roles?: string[] // // specific roles ID can bypass ratelimit
}
}
export interface initOption {
ratelimit?: RateLimitOptions,
prefix: string, // bot's prefix
dm?: boolean, // whether accept dm commands
bot?: boolean // whether accept bot execute command
command?: true,
interaction?: true
}
export interface initOption {
ratelimit?: RateLimitOptions,
prefix: string, // bot's prefix
dm?: boolean, // whether accept dm commands
bot?: boolean // whether accept bot execute command
command?: true,
interaction?: true
}
export class Command {
public name: string;
public description: string;
public usage: string;
public group: string;
public aliases: string[]
public constructor(name: string, description: string, usage: string, group: string, alias?: string[])
public execute(bot: Client, message: Message, args: string[], member: GuildMember, guild: Guild): Promise<any>
}
export class Command {
public name: string;
public description: string;
public usage: string;
public group: string;
public aliases: string[]
public constructor(name: string, description: string, usage: string, group: string, alias?: string[])
public execute(bot: Client, message: Message, args: string[], member: GuildMember, guild: Guild): Promise<any>
}
class Group {
public name: string
public description: string
public commands: Command[]
public constructor(name: string, description: string)
public register(command: string): void
}
export class Group {
public name: string
public description: string
public commands: Command[]
public constructor(name: string, description: string)
public register(command: string): void
}
class Interaction {
public name: string
public description: string;
public options: any[]
public execute(bot: Client, interaction: any, options: any, member: any): Promise<any>
}
export class Interaction {
public name: string
public description: string;
public options: any[]
public execute(bot: Client, interaction: InteractionHandler, options: any, member: GuildMember): Promise<any>
}
class InteractionResponse {
public bot: Client;
public interaction: any;
public message: any
public edit(content: any): Promise<any>
public delete(): Promise<void>
public buildInteractionData(content: any): InteractionMessageContent
public constructor(bot: Client, interaction: any, message: any)
}
export class InteractionResponse {
public bot: Client;
public interaction: any;
public message: any
public edit(content: any): Promise<any>
public delete(): Promise<void>
public buildInteractionData(content: any): InteractionMessageContent
public constructor(bot: Client, interaction: any, message: any)
}
class User {
public id: string;
public lastMessage: number;
}
export class User {
public id: string;
public lastMessage: number;
}
class InteractionHandler {
public EPHEMERAL_FLAG_ID: number;
private firstReply: boolean;
public constructor(bot: Client, interaction: any)
/**
* @param content
* @param publicVisible whether the message is visible to everyone
* @return {Promise<InteractionResponse>}
*/
public reply(content: any, publicVisible: boolean): Promise<InteractionResponse>
/**
* @param publicVisible whether the message is visible to everyone
* @return {Promise<*>}
*/
public thinking(publicVisible: boolean): Promise<any>
public buildInteractionData(content: any): InteractionResponse
}
export class InteractionHandler {
public EPHEMERAL_FLAG_ID: number;
private firstReply: boolean;
public constructor(bot: Client, interaction: any)
/**
* @param content
* @param publicVisible whether the message is visible to everyone
* @return {Promise<InteractionResponse>}
*/
public reply(content: any, publicVisible: boolean): Promise<InteractionResponse>
/**
* @param publicVisible whether the message is visible to everyone
* @return {Promise<*>}
*/
public thinking(publicVisible: boolean): Promise<any>
public buildInteractionData(content: any): InteractionResponse
}
class CommandManager extends EventEmitter {
public commands: Command[]
public groups: Map<string, Group>
/**
* @description register command
* @param command command to register
*/
public register(...command: Command[]): this
/**
* @description Register commands in folder
* @param {String} folderPath Path to folder
* @example bot.commands.loadCommands("./commands")
*/
public loadFolder(folderPath: string): Promise<void>
/**
* @description return command by name or alias
* @param name command's name or alias
* @return command
*/
public get(cmdName: string): Command
public getGroup(groupName: string): Group
}
export class CommandManager extends EventEmitter {
public commands: Command[]
public groups: Map<string, Group>
/**
* @description register command
* @param command command to register
*/
public register(...command: Command[]): this
/**
* @description Register commands in folder
* @param {String} folderPath Path to folder
* @example bot.commands.loadFolder("./commands")
*/
public loadFolder(folderPath: string): void
/**
* @description return command by name or alias
* @param name command's name or alias
* @return command
*/
public get(name: string): Command
public getGroup(groupName: string): Group
class InteractionManager extends EventEmitter {
public interactions: Map<string, Interaction>
public bot: Client
public constructor(bot: Client, options: RateLimitOptions)
public init(bot: Client, options: RateLimitOptions): Promise<void>
public register(interaction: Interaction): Promise<void>
public _createCommand(command: any): Promise<void>
}
public ratelimit?: RatelimitManager
}
class RatelimitManager {
public options: RateLimitOptions
public ratelimit: Map<string, User>
public isRatelimited(user: GuildMember): boolean
public getRatelimit(user: GuildMember): number
public updateRatelimit(user: GuildMember): void
}
export class InteractionManager extends EventEmitter {
public interactions: Map<string, Interaction>
public bot: Client
public constructor(bot: Client, options: RateLimitOptions)
public init(bot: Client, options: RateLimitOptions): Promise<void>
public register(...interaction: Interaction[]): this
public loadFolder(folderPath: string): void
}
export class Util {
static isObject(o: any): boolean
static assignObject(o: object, t: object): object
}
export class RatelimitManager {
public options: RateLimitOptions
public ratelimit: Map<string, User>
public isRatelimited(user: GuildMember): boolean
public getRatelimit(user: GuildMember): number
public updateRatelimit(user: GuildMember): void
}
declare module "discord.js" {
interface Client {
export interface Client {
commands: CommandManager

@@ -136,0 +133,0 @@ interaction: InteractionManager

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