# kakashi-handler

> a discord handler with topgg voteonly, commands, buttons, message commands, contextmenu handler

Latest version **0.0.3** (published 2024-05-10) · 0 weekly downloads

## Install

```sh
npm install kakashi-handler
pnpm add kakashi-handler
yarn add kakashi-handler
bun add kakashi-handler
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2024-05-10 |
| First published | 2024-05-06 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 48.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | KAKASHI |
| Maintainers | kakashi-dracq |
| Keywords | discord.js, discord v14, discord handler, discord version 14, discord button handler, discord cooldown, discord vote only, topgg |

## Links

- npm: https://www.npmjs.com/package/kakashi-handler
- npm.io page: https://npm.io/package/kakashi-handler

## Dependencies (3)

- [path](https://npm.io/package/path.md) ^0.12.7
- [discord.js](https://npm.io/package/discord.js.md) ^14.6.0
- [topgg-votes](https://npm.io/package/topgg-votes.md) ^2.2.1

## Recent versions

- 0.0.3 (latest) — 2024-05-10
- 0.0.2 — 2024-05-10
- 0.0.1 — 2024-05-06

## README

# KAKASHI HANDLER

## Installation
```bash
  npm install kakashi-handler
```
    
## Documentation
- Creating the main file index.js
- [dotenv link](https://www.npmjs.com/package/dotenv)
```js
const { Client, Partials, GatewayIntentBits } = require("discord.js");
require('dotenv').config()
/// Requiring the handler
const {Kakashi} = require('kakashi-handler');

/// creating the client
const client = new Client(
  {
    intents: [GatewayIntentBits.Guilds,GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers],
    partials: [Partials.Channel, Partials.Message, Partials.User, Partials.GuildMember, Partials.Reaction],
    allowedMentions: {
      parse: ['users']
    },
  }
);
/// Using the Handlers

Kakashi.Create(client, {
  Vote: {
    url: 'https://top.gg/bot/760923630212874251/vote', // your bot vote url
    webhook: {
      token: 'topggwebtoken', // your topgg token
      path: '/dblwebhook', // web path
      port: 8081, // web port
      auth: 'kakashi-self-handler' // web auth
    },
    // vote embed is for customizing vote embed message which will be sent when user is required to vote before using command
    embed: {
      enabled: true, // To use embed or not
      message: 'Hey please vote first', // your custom vote message to send this will overwrite emoji you should use emoji inside message if you want
      emoji: '<:emoji_24:959075020217405550>', //custom emoji for default embed message
      footer: false, //whether to send footer
    },
    // vote button is for customizing vote button emoji and whether to send the button or not
    button: {
      enabled: true, // whether to send vote url button with mesage
      emoji: '1158760255476486225' // custom emoji id for button
    }
  },
  Events: {
    path: './src/events/' // your path to events
  },
  GlobalCommands : {
    path: './src/scommands', // your path to guildcommands
    clientId: '1230503138629259418', // your bot id
    token: process.env.kakashitoken // your bot token
  },
  MessageCommands: {
    path: './src/commands' // your path to Messagecommand
  },
  // cooldown is for customizing cooldown message and button
  Cooldown: {
      // embed is for customizing your embed or rather not to send embed
    embed: {
      enabled: true, // To use embed or not
      message: 'Please wait remainingtime to use this command again', // your custom cooldown message to send this will overwrite emoji you should use emoji inside message if you want
// please use remainingtime text to send time
      footer: true, //whether to send footer
      emoji: '<:emoji_24:959075020217405550>', // custom emoji for default embed message
    },
    // cooldown button is for customizing support server button emoji and whether to send the button or not
    button: {
      enabled: true, // enable support server button or not
    },
  },
  //support is for defining your server url and support server button customization
  Support: {
    server: 'https://discord.gg/mTxBX87Bdr', // your support server url
    button: {
      enabled: true, // here enabling this button the handler will send support server button on perms error and vote message
      emoji: '1128799007452430387' // custom emoji id for button
    }
  },
  Components: {
    path: './src/interaction'
  },
})
client.login(process.env.kakashitoken)
```
- Interaction Event
```js
module.exports = {
  name: "interactionCreate",
  async execute(interaction, client) {
    try{
    await client.Interaction(interaction)
    } catch(err) {
      return console.log(err)
    }
  },
};
```
- Interaction event with vote only bypass
```js
const badge = require('./src/mongo/badge'); /// Remember you have to set the userid as _userid: 'id',and also if user have data then they can skip vote requirements
module.exports = {
  name: "interactionCreate",
  async execute(interaction, client) {
    try{
    await client.Interaction(interaction, await badge)
    } catch(err) {
      return console.log(err)
    }
  },
};
```
*Note: You can do same on Message Event to for bypass.*
- Message Event
```js
const prefix = '!'; /// prefix for bot
module.exports = {
  name: "messageCreate",
  async execute(message, client) {
    try{
    await client.Message(message, prefix)
    } catch(err) {
      return console.log(err)
    }
  },
};
```
- Slash command Example
```js
const {SlashCommandBuilder} = require('discord.js')
module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Get pong reply'),
        category: 'Bot', /// optional can be usefull in help command
        cooldown: '7', /// 7 second cooldown the cooldown is optional.
        voteonly: true, /// sets this command to only run when user has voted
        defer: true, /// whether to defer reply or not
        ephemeral: true, //if defer that ephemeral true or false
    async execute(interaction, client) {
        interaction.editReply({
            content: 'pong',
            ephemeral: true
        })
    }
}
```
- Context Menu Example
```js
const { ContextMenuCommandBuilder, ApplicationCommandType } = require('discord.js');
    module.exports = {
        data: new ContextMenuCommandBuilder()
            .setName('ping')
            .setType(ApplicationCommandType.User)
        ,
        async execute(interaction) {
            interaction.reply({content: 'pong', ephemeral: true})
        }
    }
```
*Note: You should put context menu commands inside same as slash commands folder*

- Message Command Example
```js
const { EmbedBuilder } = require('discord.js')
module.exports = {
  name: 'embed',
  description: 'Return embed',
  aliases: ['embed-create', 'em'],
  userPerms: [PermissionsBitField.Flags.SendMessages,],
	botPerms: [PermissionsBitField.Flags.EmbedLinks, PermissionsBitField.Flags.UseExternalEmojis, PermissionsBitField.Flags.EmbedLinks],
	cooldown: 20,
  voteonly: true,
  async execute(message, client, args) {
    const embed = new EmbedBuilder()
      .setColor('Green')
      .setTitle(`${message.author.username}`)
      .setDescription(`this is an embed`);
    await message.reply({
      embeds: [embed],
    })

  }
}
```
- Button Example
```js
module.exports = {
  data: {
    name: 'ok-button', /// customID 
    cooldown: '15' /// 15 second cooldown the cooldown is optional.
    voteonly: true, /// it wil only run this button if the user has voted
  },
  async execute(interaction, client) {
    interaction.reply({
      content: 'This button is working',
      ephemeral: true
    })
  }
}
```

## Information 

#### For other components like select menu and other handler same use customID on name

#### The handler only handles mongo schemas so you need to connect to mongo yourself

#### If you dont want cooldowns on your command dont put the cooldown: '7' part on your commands, buttons


## Screenshots
- vote button with everything customized
![](https://i.imgur.com/tVVfcTf.png)
- Normal vote message without embed and without server button

![](https://i.imgur.com/0FQv87q.png?1)

- Vote message with embed and without server button

![](https://i.imgur.com/b4j7Rhn.png)

- Cooldown Embed without server button

![Cooldown embed screenshot](https://i.imgur.com/3DkmpaW.png)

- Permission Message and without server button

![](https://i.imgur.com/q8nLVQF.png)
## Authors

- [@kakashidracq](https://github.com/kakashidracq)

![Discord](https://discord.c99.nl/widget/theme-2/614018799212953611.png)
## Support

[Discord](https://discord.gg/mTxBX87Bdr)

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