Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lvorex/lvhandler
Simple and useful discord command and event handler.
https://github.com/lvorex/lvhandler
discord discord-bot discord-command-handler discord-commands discord-events discord-handler discord-js discord-js-bot discord-js-handler discord-js-v13 discord-js-v14 discord-js-v14-command-handler discord-slash-commands slash-commands-handler
Last synced: 2 months ago
JSON representation
Simple and useful discord command and event handler.
- Host: GitHub
- URL: https://github.com/lvorex/lvhandler
- Owner: lvorex
- License: mit
- Created: 2023-05-14T21:28:04.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-19T19:21:09.000Z (about 1 year ago)
- Last Synced: 2024-09-28T09:04:44.228Z (3 months ago)
- Topics: discord, discord-bot, discord-command-handler, discord-commands, discord-events, discord-handler, discord-js, discord-js-bot, discord-js-handler, discord-js-v13, discord-js-v14, discord-js-v14-command-handler, discord-slash-commands, slash-commands-handler
- Language: TypeScript
- Homepage:
- Size: 49.8 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![GitHub Repo](https://img.shields.io/github/stars/lvorex/LVHandler?style=social)
# LVHandler
LVHandler is a discord command/event handler. It is very easy to use and makes it easy to create commands and events.
It also automatically integrates the files in the command/event folder you specify into your bot.
You can better understand what I have explained with the following examples.## Example Usage
**Install NPM Package:**
```css
npm install lvhandler
```**Setup LVHandler:**
> _index.ts_
```ts
import { Client, Events, IntentsBitField } from "discord.js";
import LVHandler from "lvhandler";
import path from "path";const client = new Client({ intents: [/* Your Intents */] })
client.on(Events.ClientReady, () => {
new LVHandler({
client: client, // Your client instance
commandDir: path.join(__dirname, "Commands"), // Bots command dir.
eventDir: path.join(__dirname, "Events"), // Bots event dir.
autoDelete: true, // Auto delete slash command when file not exists.
defaultPrefix: "!" // Default prefix for non-slash (regular) commands.
})
})client.login("TOKEN")
```**Command Creation:**
> _Commands/ping.ts_
```ts
import { LVCommand } from "lvhandler";
import { TypeOfCommand } from "lvhandler";export default {
description: "Replies With Pong.", // Command Description.
type: TypeOfCommand.SLASH, // Command Type. (BOTH, SLASH, REGULAR)
options: [], // Command Options.execute: async ({ interaction }) => {
if (!interaction) return
await interaction.reply({ content: "Pong!" })
}
} as LVCommand
```**Event Creation:**
> _Events/replyToHi.ts_
```ts
import { Events } from "discord.js";
import { LVEvent } from "lvhandler";export default {
execute: (client) => {
client.on(Events.MessageCreate, async (message) => {
if (message.content.toLowerCase() === "hi") {
await message.reply("Hi!")
}
})
}
} as LVEvent
```