Giter Site home page Giter Site logo

ebaacode / djs-v13-bot-template Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 4.0 54 KB

A Discord v13 bot template with Slash commands, Buttons, Select-Menus, Context-Menus, Prefix-command, handlers, and boilerplate code for building your next bot!

Home Page: https://ebaa.dev

License: GNU General Public License v3.0

Shell 0.16% JavaScript 99.84%
nodejs discord discord-bot discord-api slash-commands discord-js command-handler discord-bot-template context-menus select-menus

djs-v13-bot-template's Introduction

Logo

Version License Ko-fi

This Discord.js Template was designed to make building a Discord bot as simple as possible. Eliminate the hassle of setting up a new project with all the structures and handlers and get right to work on your bot with reusable embeds, dynamic handlers and a config file to customize everything!

Features

  1. Interaction Handler

    • This is a handler for all of Discord.js v13 new interaction. Slash-commands, Context-menus, Select-menus, and Buttons.
    • Dynamic file loading, organize your various commands in different folders to keep everything organized.
    • Permissions and Cooldown system.
  2. Legacy Command Handler

    • This is a handler for the leagacy message prefix commands.
    • Dynamic file loading, organize your various commands in different folders to keep everything organized.
    • Permissions and Cooldown system.
  3. Reusable Embeds

    • Embeds with preset configurations, such as an error embed with a customizable description, footer.
errorEmbed(interaction, 'Error embed example description', 'Error embed example footer')

Installation

Clone or Download this repository then get the dependencies by running:

  npm install

After that go to your.env and config.json files and change these configurations:

BOT_TOKEN, prefix, guildID, clientID

make sure you're using node.js version v16.6.0 or higher, run node -v in your terminal to check.

Configuration

You can find the config.json file in the ./util folder.

Add custom emojis and extra color values by using this format:

"emoji" : "<:emoji-name:emoji-ID>"
"color" : "hex-color-value"

Examples

Events format
module.exports = {
    name: 'eventName',
    once: 'true', //run once true/false
    async execute( < args > ) {
        //Code
    },
}

Slash commands format
const { SlashCommandBuilder } = require('@discordjs/builders') 

module.exports = {
    data: new SlashCommandBuilder()
        .setName('commandName')
        .setDescription('command description'),
    async execute( < args > ) {
        // Code
    }
}

Context menus format
const { ContextMenuCommandBuilder } = require('@discordjs/builders')

module.exports = {
    data: new ContextMenuCommandBuilder()
        .setName('context-menu-name')
        .setType(2), // (2): USER , (3): MESSAGE
    async execute( < args > ) {
        // Code
    },
}

Buttons format

Adding buttons to a message:

const { MessageButton, MessageActionRow } = require('discord.js') // At the top of the file.

let exampleButton = new MessageButton()
    .setLabel('Example')
    .setStyle('PRIMARY') // PRIMARY, SECONDARY, SUCCESS, DANGER, LINK
    .setCustomId('example_button')
const row = new MessageActionRow().addComponents(exampleButton)
interaction.reply({
    content: 'Example message',
    components: [row],
})

Button event format:

module.exports = {
    name: 'example_button',
    aliases: ['aliase1_button', 'aliase2_button'],
    async execute(interaction) {
        if (interaction.customId == 'example_button') {
            // Code
        } else if (interaction.customId == 'aliase1_button') {
            // Code
        }
    }
}

Select menu format

Adding select menu to a message:

const { MessageSelectMenu, MessageActionRow} = require('discord.js') // At the top of the file.

let selectMenu = new MessageSelectMenu()
    .setCustomId('select_example')
    .setPlaceholder('Nothing selected')
    .setMinValues(1)
    .setMaxValues(2)
    .addOptions([{
            label: 'Option #1',
            description: 'This is a description for option #1',
            value: 'first_option',
            emoji: '1️⃣',
        },
        {
            label: 'Option #2',
            description: 'This is a description for option #2',
            value: 'second_option',
            emoji: '2️⃣',
        },
    ])
const row = new MessageActionRow().addComponents(selectMenu)
interaction.reply({
    content: 'Example message',
    components: [row],
})

Select menu event format:

module.exports = {
	name: 'select_example',
	async execute(interaction) {
		interaction.reply({
			content: `${interaction.values[0]} option selected.`,
			ephemeral: true,
		})
	},
}

Permissions/Cooldown format
const { SlashCommandBuilder } = require('@discordjs/builders')

module.exports = {
    data: new SlashCommandBuilder()
        .setName('perms-cooldown-example')
        .setDescription('Permissions & Cooldown example'),
    cooldown: 5000, // Time in milliseconds.
    permissions: ['ADMINISTRATOR'],
    async execute(interaction) {
        interaction.reply({
            content: 'You have permission to run this command!',
        })
    }
}

Legacy commands format
module.exports = {
    name: 'commandName',
    aliases: ['aliase1', 'aliase2'],
    description: 'command description',
    async execute(message) {
        // Code
    },
}

Support & Documentation

Join this Discord server if you need any help.

Documentations coming soon.

Contributing

Before creating an issue, please ensure that it hasn't already been reported/suggested You can also take a look at the contributing guide if you'd like to submit a PR.

Disclaimer

This project is not affiliated/associated/partnered with Discord or even Discord.js.

visitor badge

djs-v13-bot-template's People

Contributors

ebaacode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

djs-v13-bot-template's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.