TFAGaming / DiscordJS-V14-Bot-Template

A Discord bot with commands, components and events handler based on the latest discord.js v14 and fully written in JavaScript.
GNU General Public License v3.0
354 stars 153 forks source link
bot-template discord discord-bot discord-bot-template discord-command-handler discord-js discord-js-handler discord-js-handler-v14 discord-js-v14 discord-js-v14-handler discord-v14 discordhandler discordjs discordjs-v14 v14-discord-bot-template

DiscordJS-V14-Bot-Template v3

A Discord bot commands, components and events handler based on discord.js v14 and fully written in JavaScript.

Did you like the project? Click on the star button (⭐️) right above your screen, thank you!

Features

Commands, Components, and Events structure:

Message commands:

Partial.
Awaitable means the function might be async.

new MessageCommand({
    command: {
        name: string, // The command name
        description?: string, // The command description (optional)
        aliases?: string[], // The command aliases (optional)
        permissions?: PermissionResolvable[], // The command permissions (optional)
    },
    options?: Partial<{
        cooldown: number, // The command cooldown, in milliseconds
        botOwner: boolean, // Bot owner can only run it? (true = yes, false = no)
        guildOwner: boolean, // Guild owner can only run it? (true = yes, false = no)
        botDevelopers: boolean, // Bot developers can only run it? (true = yes, false = no)
        nsfw: boolean // The command contains NSFW content? (true = yes, false = no)
    }>,
    run: Awaitable<(client: DiscordBot, message: Message, args: string[]) => void> // The main function to execute the command
});

Application commands (Chat input, User context, Message context):

APIApplicationCommand, Partial.
Awaitable means the function might be async.

new ApplicationCommand({
    command: APIApplicationCommand,
    options?: Partial<{
        cooldown: number, // The command cooldown, in milliseconds
        botOwner: boolean, // Bot owner can only run it? (true = yes, false = no)
        guildOwner: boolean, // Guild owner can only run it? (true = yes, false = no)
        botDevelopers: boolean, // Bot developers can only run it? (true = yes, false = no)
    }>,
    run: Awaitable<(client: DiscordBot, interaction: Interaction) => void> // The main function to execute the command
});

Components:

Autocomplete:

Awaitable means the function might be async.

new AutocompleteComponent({
    commandName: string,
    run: Awaitable<(client: DiscordBot, interaction: AutocompleteInteraction) => void> // The main function to execute the command
});

Buttons, Select Menus, and Modals:

Partial.
Awaitable means the function might be async.

new Component({
    customId: string,
    type: 'modal' | 'select' | 'button',
    options?: Partial<{
        public: boolean // Other users can use the main interaction author button/select? (true = yes, false = no)
    }>
    run: Awaitable<(client: DiscordBot, interaction: Interaction) => void> // The main function to execute the command
});

Events:

Awaitable means the function might be async.
K is a type parameter, extends keyof ClientEvents.

new Event({
    event: K,
    once?: boolean, // The event can only happen once? (true = yes, false = no)
    run: Awaitable<(client: DiscordBot, ...args: ClientEvents[K]) => void>
});

Dependencies

[!NOTE] Node.js v16.11.0 or newer is required to run discord.js.

Setup

  1. Install a code editor (Visual Studio Code for an example).
  2. Download this project as a .zip file: Download
  3. Extract the .zip file into a normal folder.
  4. Open your code editor, click on Open Folder, and select the new created folder.
  5. Rename the following files:
  1. Fill all the required values in config.js and .env.

[!CAUTION] Please remember not to share your Discord bot token! This will give access to attackers to do anything they want with your bot, so please keep the token in a safe place, which is the .env file.

  1. Initialize a new project: npm init (To skip every step, do npm init -y).

  2. Install all required dependencies: npm install colors discord.js dotenv quick-yaml.db

  3. Run the command node . or npm run start to start the bot.

  4. Enjoy! The bot should be online.

Contributing

Feel free to fork the repository and submit a new pull request if you wish to contribute to this project.

Before you submit a pull request, ensure you tested it and have no issues. Also, keep the same coding style, which means don't use many unnecessary spaces or tabs.

Thank you to all the people who contributed to DiscordJS-V14-Bot-Template!

Support

Join our Discord server if you have any questions to ask, or if you have a problem with this project, you can go to the issues section and submit a new issue.

License

GPL-3.0, General Public License v3