nayeon
v1.0.0
Published
This package its for Discord Bots Devs who needs commands in slash and normal with a easy setup
Downloads
5
Maintainers
Readme
Nayeon
Quick Start
- Main file (JS: CommonJS)
const { Client, Collection } = require('discord.js')
const { Nayeon } = require('nayeon')
/** ESModule:
import { Client, Collection } from 'discord.js'
import { Nayeon } from 'nayeon'
*/
const client = new Client({...}) //Creates discord client
const nayeon = new Nayeon({
client: client, //Sets the client
events: new Collection(), //Sets the collection to save events
commands: new Collection() //Sets the collection to save commands
})
nayeon.load_commands('./Commands/') //Loads commands
nayeon.load_events('./Events/') //Loads events
client.on('ready', () => nayeon.sync()) //Syncs the slashes
client.login('TOKEN') //Login with the bot's token
- Event Example (CommonJS)
module.exports['event'] = {
name: 'ready', //The name of event
once: true, //If the event only execute one-time
code: (client) => console.log(`Logged as ${client.user.username}`) //Code of the event
}
/**
* This as same as:
* client.once('ready', (client) => console.log(`Logged as ${client.user.username}`))
*/
- Command Example (CommonJS)
module.exports['command'] = {
data: {
name: 'ping',
description: 'Responses with "pong"!'
}, //Here is the name(s) and description(s) of your command
config: {...}, //Here you can add all data you want (If you use TS, in giving the type, you must give a object of types for your config)
slash: true, //Allows command to be a slash
params: [], //Here is where you sets command's params
code: async(ctx) => {...} //Code of your command, do anything
}
Guide
- Command with TypeScript
import { Command } from 'nayeon'
const config = {...}
export const command: Command<typeof config> = {...}
- CTX Content
Context {
client: [Client],
data: [Message]/[ChatInputCommandInteraction],
args: [Array],
user: [User],,
member: [GuildMember],
channel: [TextBasedChannel],
command: [Command]
}
- Custom Context
const { Context } = require('nayeon')
class CustomContext extends Context {
constructor(op){
super(op)
//Do anything
}
}