npm.io
2.1.1 • Published 3 years ago

simple-djs-framework

Licence
MIT
Version
2.1.1
Deps
2
Size
19 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

Moved to @made-simple/discord.js

Simple Discord.JS Framework


Makes it extremely easy to create and get a bot up and running with Discord.JS. This framework is designed to get a bot up and running as quickly as possible with minimal effort.

Installation

npm install simple-djs-framework

Example Usage

const { Client, SlashCommandBuilder } = require("simple-djs-framework")
const client = new Client([ "Guilds" ])

client.addCommand("ping", {
    description: "Pings the bot.",
    execute: (client, interaction) => {
        interaction.reply("Pong!")
    }
})

client.addEvent("ready", () => console.log("Ready!"))

client.registerCommands() // registers the commands globally
client.start("token")

Examples

Adding a command
client.addCommand("ping", {
    description: "Pings the bot.",
    execute: (client, interaction) => {
        interaction.reply("Pong!")
    }
})

// commands also support adding more fields

client.addCommand("userjoined", {
    description: "Tells you when a user joined.",
    allowedInDMs: false,
    args: [{
        name: "user",
        type: "user",
        description: "The user to check.",
        required: true
    }],
    execute: (client, interaction) => {
        const user = interaction.options.getUser("user")
        interaction.reply(`${user.username} joined on ${user.createdAt}`)
    }
})
Registering a command
client.registerCommands() // registers the commands globally
client.registerCommands("guildID") // registers the commands in a guild
Adding an event
client.addEvent("ready", (client) => console.log("Ready!"))
Using folders instead of a single file
client.addCommandsFolder("./commands")
client.addEventsFolder("./events")
client.addModalsFolder("./modals")
Creating a command file
// commands/ping.js

const { SlashCommandBuilder } = require("simple-djs-framework")

export const builder = new SlashCommandBuilder()
    .setName("ping")
    .setDescription("Pings the bot.")

export const execute = (client, interaction) => {
    interaction.reply("Pong!")
}
Creating an event file
// events/ready.js

export const execute = (client) => console.log("Ready!")
Using dotenv
require("dotenv").config()
client.start() // token will be read from .env as DISCORD_TOKEN or TOKEN

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Repository

Contributors

@alexasterisk

Keywords