npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kakashi-self-handler

v0.0.0-beta.0

Published

package handler for discord bot

Downloads

13

Readme

KAKASHI SELF HANDLER

Dev info

Mongo: Removed

Bug Found? Please contact us or issue on github you can also provide suggestions

Installation

  npm install kakashi-self-handler

Documentation

  • Index.js
const { Client, Partials, GatewayIntentBits } = require("discord.js");

/// Requiring the handler
const {Kakashi} = require('kakashi-self-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']
    },
  }
);

const clientID = client.user.id;
/// Using the Handlers

client.kakashi = 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
  },
  GuildCommands : {
    path: './src/scommands', // your path to guildcommands
    clientId: '1230503138629259418', // your bot id
    guildId: '761857421701414912', // your guild id to register slash commands in that guild
    token: process.env.hyperzone // 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.TOKEN)
  • Interaction Event
module.exports = {
  name: "interactionCreate",
  async execute(interaction, client) {
    try{
    await client.kakashi.Interaction(interaction)
    } catch(err) {
      return console.log(err)
    }
  },
};
  • Message Event
const prefix = '!'; /// prefix for bot
module.exports = {
  name: "messageCreate",
  async execute(message, client) {
    try{
    await client.kakashi.MessageEvents(message, prefix)
    } catch(err) {
      return console.log(err)
    }
  },
};
  • Slash command Example
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
    async execute(interaction, client) {
        interaction.reply({
            content: 'pong',
            ephemeral: true
        })
    }
}
  • Message Command Example
const { EmbedBuilder } = require('discord.js')
module.exports = {
  name: 'embed',
  description: 'Return embed',
  aliases: ['embed-create', 'em'],
  botPerms: ['EmbedLinks'],
  userPerms: ['ManageMessages'],
  category: 'Bot',
  cooldown: '9',
  voteonly: false, /// it will run if user hasnt voted
  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
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
  • Normal vote message without embed and without server button

  • Vote message with embed and without server button

  • Cooldown Embed without server button

Cooldown embed screenshot

  • Permission Message and without server button

Authors

Discord

Support

Discord