From 35a49015eb032cb2e21e2001920ec66ecde6c07e Mon Sep 17 00:00:00 2001 From: DeathVenom54 Date: Thu, 10 Mar 2022 20:44:34 +0530 Subject: [PATCH 1/3] [feat](README) slight tweaks --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4ba2be8..b4c915a 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,14 @@ # djs-marshal -![npm](https://img.shields.io/npm/v/djs-marshal?style=for-the-badge) -![downloads](https://img.shields.io/npm/dm/djs-marshal?style=for-the-badge) -![discord](https://img.shields.io/discord/873232757508157470?color=5865F2&label=discord&style=for-the-badge) +[![npm](https://img.shields.io/npm/v/djs-marshal?style=for-the-badge)](https://www.npmjs.com/package/djs-marshal) +[![downloads](https://img.shields.io/npm/dm/djs-marshal?style=for-the-badge)](https://www.npmjs.com/package/djs-marshal) +[![discord](https://img.shields.io/discord/873232757508157470?color=5865F2&label=discord&style=for-the-badge)](https://discord.gg/qJnrRvt7wW) A lightweight command handler for discord.js interactions > This package requires discord.js v13 or higher to be installed -[**Technical documentation**](https://deathvenom54.github.io/djs-marshal): Refer this because I am too lazy to write documentation - ## Installation ```bash @@ -23,6 +21,10 @@ yarn add djs-marshal npm install discord.js --save ``` +## Documentation + +You can find the full documentation [here](https://deathvenom54.github.io/djs-marshal) + ## Setup You can set up your bot to handle commands in 2 ways: From c8c06e375c7f6628da19e9ac6550140df8fc0812 Mon Sep 17 00:00:00 2001 From: DeathVenom54 Date: Thu, 10 Mar 2022 20:46:53 +0530 Subject: [PATCH 2/3] [feat](docs) generate documentation --- docs/index.html | 12 ++++++--- docs/interfaces/MarshalOptions.html | 16 +++++------ docs/modules.html | 42 ++++++++++++++--------------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/docs/index.html b/docs/index.html index 60ceacb..298f21f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,14 +2,13 @@

djs-marshal

-

npm -downloads -discord

+

npm +downloads +discord

A lightweight command handler for discord.js interactions

This package requires discord.js v13 or higher to be installed

-

Technical documentation: Refer this because I am too lazy to write documentation

Installation

@@ -17,6 +16,11 @@

Installation

# with npm
npm install djs-marshal --save
# with yarn
yarn add djs-marshal

# this package also requires discord.js
npm install discord.js --save
+
+

Documentation

+
+

You can find the full documentation here

+

Setup

diff --git a/docs/interfaces/MarshalOptions.html b/docs/interfaces/MarshalOptions.html index dfa30f4..1ae8d19 100644 --- a/docs/interfaces/MarshalOptions.html +++ b/docs/interfaces/MarshalOptions.html @@ -1,21 +1,21 @@ MarshalOptions | djs-marshal
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface MarshalOptions

Options for initializing bot. Intents are required

-

Hierarchy

  • ClientOptions
    • MarshalOptions

Index

Properties

Optional allowedMentions

allowedMentions?: MessageMentionOptions

Optional buttonsPath

buttonsPath?: string
+

Hierarchy

  • ClientOptions
    • MarshalOptions

Index

Properties

Optional allowedMentions

allowedMentions?: MessageMentionOptions

Optional buttonsPath

buttonsPath?: string

Path to the buttons directory

-

Optional failIfNotExists

failIfNotExists?: boolean

Optional http

http?: HTTPOptions

intents

intents: BitFieldResolvable<IntentsString, number>

Optional invalidRequestWarningInterval

invalidRequestWarningInterval?: number

Optional logLevel

logLevel?: logLevel
+

Optional failIfNotExists

failIfNotExists?: boolean

Optional http

http?: HTTPOptions

intents

intents: BitFieldResolvable<IntentsString, number>

Optional invalidRequestWarningInterval

invalidRequestWarningInterval?: number

Optional logLevel

logLevel?: logLevel

Specifies what information should be logged to the console

-

Optional logStyle

logStyle?: logStyle
+

Optional logStyle

logStyle?: logStyle

How much information should be logged

Optional makeCache

makeCache?: CacheFactory

Optional messageCacheLifetime

messageCacheLifetime?: number
deprecated

Use makeCache with a LimitedCollection for MessageManager instead.

Optional messageSweepInterval

messageSweepInterval?: number
deprecated

Use makeCache with a LimitedCollection for MessageManager instead.

-

Optional partials

partials?: PartialTypes[]

Optional presence

presence?: PresenceData

Optional readyMessage

readyMessage?: string
+

Optional partials

partials?: PartialTypes[]

Optional presence

presence?: PresenceData

Optional readyMessage

readyMessage?: string

Message to be logged when bot is ready

-

Optional rejectOnRateLimit

rejectOnRateLimit?: string[] | ((data: RateLimitData) => boolean | Promise<boolean>)

Optional restGlobalRateLimit

restGlobalRateLimit?: number

Optional restRequestTimeout

restRequestTimeout?: number

Optional restSweepInterval

restSweepInterval?: number

Optional restTimeOffset

restTimeOffset?: number

Optional restWsBridgeTimeout

restWsBridgeTimeout?: number

Optional retryLimit

retryLimit?: number

Optional selectMenusPath

selectMenusPath?: string
+

Optional rejectOnRateLimit

rejectOnRateLimit?: string[] | ((data: RateLimitData) => boolean | Promise<boolean>)

Optional restGlobalRateLimit

restGlobalRateLimit?: number

Optional restRequestTimeout

restRequestTimeout?: number

Optional restSweepInterval

restSweepInterval?: number

Optional restTimeOffset

restTimeOffset?: number

Optional restWsBridgeTimeout

restWsBridgeTimeout?: number

Optional retryLimit

retryLimit?: number

Optional selectMenusPath

selectMenusPath?: string

Path to the select menus directory

-

Optional shardCount

shardCount?: number

Optional shards

shards?: number | number[] | "auto"

Optional slashCommandsPath

slashCommandsPath?: string
+

Optional shardCount

shardCount?: number

Optional shards

shards?: number | number[] | "auto"

Optional slashCommandsPath

slashCommandsPath?: string

Path to the slash commands directory

-

Optional token

token?: string
+

Optional token

token?: string

The bot token. Logs in the bot if provided

-

Optional userAgentSuffix

userAgentSuffix?: string[]

Optional ws

ws?: WebSocketOptions

Methods

Optional logMethod

  • logMethod(message: string, level: logLevel): void

Optional userAgentSuffix

userAgentSuffix?: string[]

Optional ws

ws?: WebSocketOptions

Methods

Optional logMethod

  • logMethod(message: string, level: logLevel): void

Legend

  • Property
  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules.html b/docs/modules.html index 6e55fab..f41a784 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1,6 +1,6 @@ -djs-marshal
Options
All
  • Public
  • Public/Protected
  • All
Menu

djs-marshal

Index

Type aliases

BaseSlashCommand

BaseSlashCommand: ChatInputApplicationCommandData & { allowWithPermission?: PermissionString[]; beforeExecute?: { defer?: boolean; deferEphemeral?: boolean }; execute: any }
+djs-marshal
Options
All
  • Public
  • Public/Protected
  • All
Menu

djs-marshal

Index

Type aliases

BaseSlashCommand

BaseSlashCommand: ChatInputApplicationCommandData & { allowRoles?: Snowflake[]; allowUsers?: Snowflake[]; allowWithPermission?: PermissionString[]; beforeExecute?: { defer?: boolean; deferEphemeral?: boolean }; denyRoles?: Snowflake[]; denyUsers?: Snowflake[]; handleError?: boolean; execute: any }

The base options present in all types of SlashCommand

-

ButtonCommand

ButtonCommand: { beforeExecute?: { deferReply?: boolean; deferReplyEphemeral?: boolean; deferUpdate?: boolean }; customId: string | RegExp; execute: any }
+

ButtonCommand

ButtonCommand: { beforeExecute?: { deferReply?: boolean; deferReplyEphemeral?: boolean; deferUpdate?: boolean }; customId: string | RegExp; execute: any }

Data for a ButtonInteraction to be executed

Type declaration

  • Optional beforeExecute?: { deferReply?: boolean; deferReplyEphemeral?: boolean; deferUpdate?: boolean }

    Options to do stuff before button is executed

    @@ -13,15 +13,15 @@
  • customId: string | RegExp

    The customId to be executed

    remark

    Ensure that there aren't multiple executors for the same customId

    -
  • execute:function
    • execute(int: ButtonInteraction): void | Promise<void>
  • GuildSlashCommand

    GuildSlashCommand: BaseSlashCommand & { commandType: "guild"; guildId: Snowflake }
    +

    Returns void | Promise<void>

    GuildSlashCommand

    GuildSlashCommand: BaseSlashCommand & { commandType: "guild"; guildId: Snowflake }

    A slash command registered in a specific guild

    -

    RegularSlashCommand

    RegularSlashCommand: BaseSlashCommand & { commandType: "global" | "allGuild" }
    +

    RegularSlashCommand

    RegularSlashCommand: BaseSlashCommand & { commandType: "global" | "allGuild" }

    A slash command registered either globally or in all guilds

    -

    SelectMenuCommand

    SelectMenuCommand: { beforeExecute?: { deferReply?: boolean; deferReplyEphemeral?: boolean }; customId: string | RegExp; execute: any }

    Type declaration

    • Optional beforeExecute?: { deferReply?: boolean; deferReplyEphemeral?: boolean }
      +

    SelectMenuCommand

    SelectMenuCommand: { beforeExecute?: { deferReply?: boolean; deferReplyEphemeral?: boolean }; customId: string | RegExp; execute: any }

    Type declaration

    • Optional beforeExecute?: { deferReply?: boolean; deferReplyEphemeral?: boolean }

      Options to do stuff before button is executed

      • Optional deferReply?: boolean

        defer the reply before executing

        @@ -30,15 +30,15 @@
    • customId: string | RegExp

      The customId to be executed

      remark

      Ensure that there aren't multiple executors for the same customId

      -
    • execute:function
      • execute(int: SelectMenuInteraction): void | Promise<void>

    SlashCommand

    +

    Returns void | Promise<void>

    SlashCommand

    A slash command which will be executed when a CommandInteraction is received

    -

    logLevel

    logLevel: "verbose" | "warn" | "erroronly"
    +

    logLevel

    logLevel: "verbose" | "warn" | "erroronly"

    The level of logs to log

    -

    logStyle

    logStyle: "none" | "simple" | "expanded"
    +

    logStyle

    logStyle: "none" | "simple" | "expanded"

    Different console styles

    Properties

    default

    default: { handlers: { handleGuildJoin: (guild: Guild) => void; handleGuildMemberUpdate: (oldM: GuildMember | PartialGuildMember, newM: GuildMember) => Promise<void>; handleInteraction: (int: Interaction) => Promise<void> }; initializeBot: (options: MarshalOptions) => Client<boolean>; loadButtons: (client: Client<boolean>, buttons: ButtonCommand[]) => void; loadButtonsFromDir: (client: Client<boolean>, path: string) => Promise<void>; loadCommands: (client: Client<boolean>, commands: SlashCommand[]) => Promise<void>; loadCommandsFromDir: (client: Client<boolean>, dir: string) => Promise<void>; loadSelectMenus: (client: Client<boolean>, selectMenus: SelectMenuCommand[]) => void; loadSelectMenusFromDir: (client: Client<boolean>, path: string) => Promise<void> }

    Type declaration

    • handlers: { handleGuildJoin: (guild: Guild) => void; handleGuildMemberUpdate: (oldM: GuildMember | PartialGuildMember, newM: GuildMember) => Promise<void>; handleInteraction: (int: Interaction) => Promise<void> }
      • handleGuildJoin: (guild: Guild) => void
          • (guild: Guild): void
          • Registers commands in a guild when joined

            @@ -85,38 +85,38 @@

            The bot's Client

          • selectMenus: SelectMenuCommand[]

            The SelectMenuCommands to load

            -

          Returns void

    • loadSelectMenusFromDir: (client: Client<boolean>, path: string) => Promise<void>
        • (client: Client<boolean>, path: string): Promise<void>
        • Parameters

          • client: Client<boolean>
          • path: string

          Returns Promise<void>

    Functions

    Const handleGuildJoin

    • handleGuildJoin(guild: Guild): void

    Returns void

  • loadSelectMenusFromDir: (client: Client<boolean>, path: string) => Promise<void>
      • (client: Client<boolean>, path: string): Promise<void>
      • Parameters

        • client: Client<boolean>
        • path: string

        Returns Promise<void>

  • Functions

    Const handleGuildJoin

    • handleGuildJoin(guild: Guild): void

    Const handleGuildMemberUpdate

    • handleGuildMemberUpdate(oldM: GuildMember | PartialGuildMember, newM: GuildMember): Promise<void>

    Returns void

    Const handleGuildMemberUpdate

    • handleGuildMemberUpdate(oldM: GuildMember | PartialGuildMember, newM: GuildMember): Promise<void>
    • Refreshes command permissions when a member is updated

      Parameters

      • oldM: GuildMember | PartialGuildMember

        The old member

      • newM: GuildMember

        The updated member

        -

      Returns Promise<void>

    Const handleInteraction

    • handleInteraction(int: Interaction): Promise<void>

    Returns Promise<void>

    Const handleInteraction

    • handleInteraction(int: Interaction): Promise<void>

    Const initializeBot

    Returns Promise<void>

    Const initializeBot

    • Create and set up a bot for slash commands

      remark

      Intents need to be specified for creating the client

      Parameters

      Returns Client<boolean>

    Const loadButtons

    • loadButtons(client: Client<boolean>, buttons: ButtonCommand[]): void

    Returns Client<boolean>

    Const loadButtons

    • loadButtons(client: Client<boolean>, buttons: ButtonCommand[]): void

    Const loadButtonsFromDir

    • loadButtonsFromDir(client: Client<boolean>, path: string): Promise<void>

    Const loadCommands

    • loadCommands(client: Client<boolean>, commands: SlashCommand[]): Promise<void>

    Returns void

    Const loadButtonsFromDir

    • loadButtonsFromDir(client: Client<boolean>, path: string): Promise<void>

    Const loadCommands

    • loadCommands(client: Client<boolean>, commands: SlashCommand[]): Promise<void>
    • Loads slash commands and stores them as client.commands, then syncs them with Discord

      Parameters

      • client: Client<boolean>

        The bot's Client

      • commands: SlashCommand[]

        An array of SlashCommands to load

        -

      Returns Promise<void>

    Const loadCommandsFromDir

    • loadCommandsFromDir(client: Client<boolean>, dir: string): Promise<void>

    Returns Promise<void>

    Const loadCommandsFromDir

    • loadCommandsFromDir(client: Client<boolean>, dir: string): Promise<void>
    • Loads slash commands from a specified directory (does not check sub-folders)

      remark

      All commands that need to be loaded should be in the root level

      remark

      All command files should export by default a SlashCommand structure

      @@ -124,21 +124,21 @@

      The bot's Client

  • dir: string

    The full path of the directory containing the command files

    -
  • Returns Promise<void>

    Const loadSelectMenus

    Returns Promise<void>

    Const loadSelectMenus

    Const loadSelectMenusFromDir

    • loadSelectMenusFromDir(client: Client<boolean>, path: string): Promise<void>

    Const syncCommands

    • syncCommands(client: Client<boolean>): Promise<void>

    Returns void

    Const loadSelectMenusFromDir

    • loadSelectMenusFromDir(client: Client<boolean>, path: string): Promise<void>

    Const syncCommands

    • syncCommands(client: Client<boolean>): Promise<void>

    Const syncGuildCommands

    • syncGuildCommands(guild: Guild): Promise<void>

    Returns Promise<void>

    Const syncGuildCommands

    • syncGuildCommands(guild: Guild): Promise<void>

    Const syncPermissions

    • syncPermissions(guild: Guild, command: SlashCommand, existing: ApplicationCommand<{}>): Promise<void>

    Returns Promise<void>

    Const syncPermissions

    • syncPermissions(guild: Guild, command: SlashCommand, existing: ApplicationCommand<{}>): Promise<void>
    • Makes sure users with only selected permissions can use the command

      Parameters

      • guild: Guild

        The guild in which command should be checked

        From 915938cac2864c636d4e24cb4f83698fe73b7f9f Mon Sep 17 00:00:00 2001 From: DeathVenom54 Date: Thu, 10 Mar 2022 20:47:22 +0530 Subject: [PATCH 3/3] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9a4afed..4987ce4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "djs-marshal", "description": "A simple slash command manager for typescript", - "version": "1.1.3", + "version": "1.2.0", "main": "dist/index.js", "types": "dist/index.d.ts", "repository": "https://github.com/DeathVenom54/djs-marshal.git",