# revolthandler.js

> Handle your code for revolt.js

Latest version **2.4.31** (published 2024-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install revolthandler.js
pnpm add revolthandler.js
yarn add revolthandler.js
bun add revolthandler.js
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.4.31 |
| Published | 2024-10-19 |
| First published | 2021-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 19.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | ramco |
| Maintainers | mrturk |
| Keywords | revolt, revolthandler.js, revolt.js, revolt, handler, uploader |

## Links

- npm: https://www.npmjs.com/package/revolthandler.js
- Repository: https://github.com/ramazaneris/revolthandler.js
- Homepage: https://github.com/ramazaneris/revolthandler.js#readme
- Issues: https://github.com/ramazaneris/revolthandler.js/issues
- npm.io page: https://npm.io/package/revolthandler.js

## Dependencies (4)

- [clcn](https://npm.io/package/clcn.md) ^2.0.1
- [dotenv](https://npm.io/package/dotenv.md) ^16.0.3
- [revolt.js](https://npm.io/package/revolt.js.md) ^7.0.3
- [revolthandler.js](https://npm.io/package/revolthandler.js.md) file:

## Recent versions

- 2.4.31 (latest) — 2024-10-19
- 2.3.0-beta.1 (beta) — 2023-09-14
- 2.4.3 — 2024-10-12
- 2.4.21 — 2024-10-12
- 2.4.2 — 2024-10-12
- 2.4.1 — 2024-10-12
- 2.4.0 — 2024-10-12
- 2.3.1 — 2024-07-20
- 2.3.0 — 2024-07-20
- 2.2.0 — 2023-06-09
- 2.1.2 — 2023-05-06
- 2.1.11 — 2023-04-23
- 2.1.1 — 2023-04-23
- 2.1.0 — 2023-04-23
- 2.0.11 — 2023-04-09
- … 25 more at https://npm.io/package/revolthandler.js/versions

## README

# revolthandler.js

## Description

Easy command handling for revolt.js

## Table of contents

-   [About](#about)
-   [Installation](#install)
-   [Example Usage](#example)
    -   [Handler](#handler)
        -   [Setup](#setup)
        -   [Standart](#standart-using-example)
        -   [Aliases](#aliases-example)
        -   [ownerOnly](#only-owner-command-example)
        -   [permissions](#only-perms-command-example)
        -   [guildOnly](#guild-only)
        -   [NonPrefixed](#non-prefixed)
    -   [Embed Builder & Uploader](#embed-builder--uploader)

## About

command handler for revolt.js bot project

## Badges

[![NPM Downloads](https://img.shields.io/npm/dt/revolthandler.js.svg?style=flat-square)](https://www.npmjs.com/package/revolthandler.js)

## Install

> npm i revolthandler.js

## Example

### Handler

#### Setup

CommonJS

```js
const revolt = require("revolt.js");
const client = new revolt.Client();
const revoltHandler = require("revolthandler.js");
const handler = new revoltHandler.Handler({
    client: client, //required
    prefix: "!", //required
    owners: ["Your Revolt ID"], //optional , optional add more owner Id
    path: "./commands", //optional, (default : "./commands")
});
client.once("ready", () => {
    handler.start();
});
client.loginBot("YOUR_BOT_TOKEN_HERE");
```

EsModule

```js
//...
import { Handler } from "revolthandler.js";
const handler = new Handler({
    client: client, //required
    prefix: "!", //required
    owners: ["Your Revolt ID"], //optional , optional add more owner Id
    path: "./commands", //optinal, (default : "./commands")
});
//...
```

#### Standart using example

CommonJS

```js
//"./commands/general/ping.js"
exports.default = {
    name: "ping",
    description: "Ping!", //description :P
    //Be careful
    code(message, args, client) {
        //Your code here
        message.channel.sendMessage("Pong");
    },
};
```

EsModule

```ts
export default {
  name:"ping",
  description:"Ping!"
  code(message:any,args:string[],client:any){
    //Your code here
  }
}
```

#### Aliases example

```js
//"./commands/general/ping.js"
exports.default = {
    name: ["ping", "delay"],
    description: "Ping!", //description :P
    //Be careful
    code(message, args, client /*,command*/) {
        //Your code here
    },
};
```

#### Only owner command example

```js
//"./commands/owner/test.js"
exports.default = {
    name: ["eval", "deneme"],
    ownerOnly: {
        errorMsg(message, args, client, command) {
            //optional
            message.reply("You can't use this command");
        },
    },
    code(message, args, client) {
        //your code here
    },
};
```

#### Only perms command example

```js
//"./commands/moderate/perm.js"
exports.default = {
    name: "perm",
    permissions: {
        perms: {
            user: ["KickMembers"],
            bot: ["KickMembers"],
        }, //You can see the perm names in : https://revolt.js.org/classes/ServerMember.html#hasPermission
        errorMsg(message, args, client, command) {
            //optional
            message.reply(
                `You must have ${command.permission.perms.user.join(
                    ","
                )} permission(s) to use this command`
            );
        },
        botErrorMsg(message, args, client, command) {
            //optional
            message.reply(
                `I need the ${command.permission.perms.bot.join(
                    ","
                )} permission(s) to execute this command`
            );
        },
    },
    code(msg, args, client) {
        //Your code here
    },
};
```

#### Guild Only

```js
//"./commands/general/indm.js"
exports.default = {
    name: "in-server",
    guildOnly: {
        errorMsg(message, author, client) {
            //optional
            message.reply("You can't use this commmand in dm or group");
        },
    },
    code(message, args, client) {
        //Your code here
    },
};
```

#### Non Prefixed

```js
//"./commands/general/nonprefixed.js"
exports.default = {
    name: "withoutprefix", //WARN : The command name is case sensitive here!
    nonPrefixed: true,
    code(message, args, client) {
        //Your code here
    },
};
```

### Embed Builder & Uploader

#### All in one

```js
const { EmbedBuilder, Uploader } = require("revolthandler.js");
exports.default = {
    name: "coolembed",
    async code(message, args, client) {
        const myuploader = new Uploader(client);
        const myemb = new EmbedBuilder();
        myemb
            .setDescription("Cool describe")
            .setColour("red") //hex code or name is acceptable
            .setTitle("Cool title")
            .setMedia(
                await myuploader.upload("imagelink/imagebuffer", "filename.png")
            ) ////You can add an big picture or file
            .setUrl("https://www.npmjs.com/package/revolthandler.js")
            .setIconUrl("imagelink"); //You can add an picture in front of the title
        message.channel.sendMessage({ embeds: [myemb] });
    },
};
```

-   [Come to my server](https://rvlt.gg/zrmFWtJz)

## Will add new features in the future

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