Code Monkey home page Code Monkey logo

cwa-bot's Introduction

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

  • Updated to the latest version of discord.js v14.x.
  • Supports all possible type of commands.
    • Message commands.
    • Application commands:
      • Chat Input
      • User context
      • Message context
  • Handles components.
    • Buttons
    • Select menus
    • Modals
    • Autocomplete
  • Easy and simple to use.
  • Advanced command options.
  • Simple Database included (YAML).

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

  • colors → latest
  • discord.js → 14.13.0 or newer
  • dotenv → latest
  • quick-yaml.db → latest

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:
  • src/example.config.jssrc/config.js: Used for handler configuration.
  • .env.example.env: Used for secrets, like the Discord bot token.
  • example.database.ymldatabase.yml: Used as a main file for the database.
  • example.terminal.logterminal.log: Used as a clone of terminal (to save previous terminal messages).
  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

cwa-bot's People

Contributors

tfagaming avatar provant15 avatar codeblitz97 avatar adamt20054 avatar atreeshine avatar panintegralus avatar saunakghosh10 avatar codixer avatar slendertaker avatar

Stargazers

Jack avatar

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.