# latecmds

> Command handler for Discord.JS Bots v13

Latest version **0.1.0** (published 2022-02-25) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install latecmds
pnpm add latecmds
yarn add latecmds
bun add latecmds
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-02-25 |
| First published | 2022-02-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 31.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Late |
| Maintainers | latetheidiot |

## Links

- npm: https://www.npmjs.com/package/latecmds
- Repository: https://github.com/Late-Is-Cool/latecmds
- Homepage: https://github.com/Late-Is-Cool/latecmds#readme
- Issues: https://github.com/Late-Is-Cool/latecmds/issues
- npm.io page: https://npm.io/package/latecmds

## Dependencies (2)

- [mongoose](https://npm.io/package/mongoose.md) ^6.2.3
- [discord.js](https://npm.io/package/discord.js.md) ^13.6.0

## Recent versions

- 0.1.0 (latest) — 2022-02-25

## README

��# ![latecmdslogo](./latecmds-logo.png "logo")

A command handler for Discord.JS v13 bots.


# Warnings

This documentation may or may not be hard to keep up (at least to me when editing this).

This command handler will only work with **javascript** files and not typescript. (Feature will come in the future)

## **NO SUPPORT FOR SLASH COMMANDS**

# Table of Contents

- [Installation](#installation)

- [Setting up](#setting-up)

- [Creating a command](#creating-a-command)

    - [Command Arguments](#command-arguments)

    - [Command Aliases](#command-aliases)

    - [Command Categories and Description](#command-categories-and-description)

    - [Command Permissions](#command-permissions)

    - [Bot Owner Only Commands](#bot-owner-only-commands)

    - [Test Server Commands](#test-server-commands)

    - [Command Cooldowns](#command-cooldowns)
    
        - [Global Command Cooldowns](#global-command-cooldowns)

    - [Disabling a command](#disabling-a-command)

- [Creating a feature](#creating-a-feature)

    - [Configurating a feature](#configurating-a-feature)

    - [Disabling a feature](#disabling-a-feature)

# Installation

NPM

`npm i latecmds`

<!-- Dev Build:

`npm i github:Late-Is-Cool/latecmds#dev` -->

# Setting up

After you install the package, you will need to add it to your bot.

```js
const Discord = require("discord.js")
const client = new Discord.Client({
    intents: 513
})
const latecmds = require("latecmds")

client.on("ready", () => {
    new latecmds(client, {
        prefix: "!", // Default will be ?
        commandsDir: "cmds", // Default will be "commands"
        featuresDir: "feats", // Default will be "features"
        mongoUri: "MongoDB URI", // Needed for guild prefixes and cooldowns
        dbOptions: {
            keepAlive: true,
            useNewUrlParser: true,
            useUnifiedTopology: true
        }, // MongoDB options, Default will be keepAlive
        showWarns: false, // Default will be true
        categories: [
            {
                name: "Fun",
                emoji: "=��"
            },
            {
                name: "Utility",
                emoji: "=�'�",
                hidden: true // Hidden categories will only show when an admin/bot owner uses the help command
            }
        ], // 2 default catergories being "Config" and "Help"
        color: 0x00FF00, // Default will be 0x7289DA
        botOwner: ["454882470306113872"],
        testServers: ["153841427033895615"],
    })
})

client.login("token")
```

# Creating a command

After you set up latecmds, add a js file in the commandsDir folder.

```js
// ping.js
module.exports = {
    start: ({ message, args }) => {
        message.channel.send("Pong!")
    }
}
```

When running !ping, it will send "Pong!".

If you want to specify a name for the command, you can pass in the "name" property.

```js
// ping.js
module.exports = {
    name: "ping",
    start: ({ message, args }) => {
        message.channel.send("Pong!")
    }
}
```

# Command arguments

You can add arguments to your commands.

```js
// ping.js
module.exports = {
    minArgs: 1, // Default will be 0
    maxArgs: -1, // Default will be 0, -1 means unlimited
    start: ({ message, args }) => {
        message.channel.send(`Pong! + ${args.join(" ")}`)
    }
}
```

# Command Aliases

Aliases for the same command

```js
// ping.js
module.exports = {
    aliases: ["p"],
    start: ({ message, args }) => {
        message.channel.send(`Pong!`)
    }
}
```

The command can be ran by using !ping or !p.

# Command Categories and Description

Category is a way to organize commands.

Description is a way to describe the command.

Both are used in the help command.

Both are **required** for slash commands in the future.

```js
// ping.js
module.exports = {
    category: "Fun",
    description: "Test command!",
    start: ({ message, args }) => {
        message.channel.send(`Pong!`)
    }
}
```

# Command Permissions

Command permissions are used to determine if a user can run a command according to their permissions.

Example:

```js
// ping.js
module.exports = {
    permissions: ["MANAGE_MESSAGES"],
    start: ({ message, args }) => {
        message.channel.send(`Pong!`)
    }
}
```

# Bot Owner Only Commands

Self explanatory, only the bot owner can use these commands.

First you need to declare one or more user ids in the botOwner array.

```js
new latecmds(client, {
    botOwner: ["454882470306113872", "218404789723493888"],
})
```

Then you can use the `botOwner` option like so:

```js
module.exports = {
    botOwner: true,
    start: ({ message, args }) => {
        message.channel.send("You are the bot owner!")
    }
}
```

# Test Server Commands

Similar to bot owner commands, but only for test servers.

Declare one or more server ids in the testServers array.

```js
new latecmds(client, {
    testServers: ["153841427033895615", "732956239079181824"],
})
```

Then you can use the `testServers` option like so:

```js
module.exports = {
    testServers: true,
    start: ({ message, args }) => {
        message.channel.send("You are in a test server!")
    }
}
```

# Command Cooldowns

Command cooldowns are used to prevent a user from spamming a command.

Bot owners bypass cooldowns.

They can use the `cooldown` option like so:

```js
module.exports = {
    cooldown: "5s", // 5 seconds
    start: ({ message, args }) => {
        message.channel.send("Pong!")
    }
}
```

Cooldown types are:

| Character | Duration | Min | Max | Example |
| --------- | -------- | ---- | --- | ------- |
| s | Seconds | 1 | 60 | 5s |
| m | Minutes | 1 | 60 | 5m |
| h | Hours | 1 | 24 | 5h |
| d | Days | 1 | 365 | 5d |

# Global Command Cooldowns

Like command cooldowns, but for everyone in a guild.

They can use the `globalCooldown` option like so:

```js
module.exports = {
    globalCooldown: "5s", // 5 seconds
    start: ({ message, args }) => {
        message.channel.send("Pong!")
    }
}
```

Types are the same as above.

# Disabling a command

You can use a command that is built in to disable it.

`[PREFIX]command {Disable/Enable} [command]`

# Creating a feature

Making a feature is as easy and similar as making a command (and pie! [not included.])

Make a js file in the featuresDir folder.

```js
// log.js
module.exports = (client) => {
    client.on("messageCreate", (message) => {
        console.log(`${message.author.tag}: ${message.content}`)
    })
}
```

A feature is actively running while the bot is online.

# Configuring a feature

Coming soon!

<!-- 
Configuring a feature requires a database.

```js
module.exports = (client) => {
    console.log("Requiring a database")
}

module.exports.config = {
    name: "test", // Name of the feature, can be changed anytime
    dbName: "TEST", // Name of the feature in the database, CAN'T be changed at all. 
}
``` -->

# Disabling a feature

Similar to disabling a command.

You can use a built in command to disable a feature.

`[PREFIX]feature {Disable/Enable} [command]`

#

---
_Source: https://npm.io/package/latecmds · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
