/discord.js-bot-template

Discord.js Bot Template

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

Discord Bot Template - README.md

GitHub Version wakatime

GitHub License GitHub Issues GitHub Pull Requests

Table of Contents

Description

This is a template for a Discord bot. It is written in Javascript and uses the discord.js library. This template is designed to be a starting point for creating a new Discord bot. It includes a basic command handler and example commands.

Installation

  1. Clone the repository
git clone https://github.com/FantaCovid-19/discord.js-bot-template.git
  1. Install the dependencies
npm install

or

yarn install
  1. Create a .env file in the root directory of the project and add your bot token and any other configuration variables.
# Discord Configuration
DISCORD_TOKEN="your-bot-token"

# Github Configuration
GITHUB_TOKEN="your-github-token"
GITHUB_REPO="your-github-repo"
  1. Start the bot
npm start

or

yarn start

Usage

The default command prefix is !. You can change this in the config.json file.

To create a new command, create a new file in the commands directory with the following template:

/** @type {import('@types/CommandType')} */
module.exports = {
  name: '',
  description: '',
  cooldown: 0,
  category: '',
  botPermissions: [],
  userPermissions: [],
  command: {
    enabled: true,
    aliases: [],
    usage: '',
    minArgsCount: 0,
    subCommands: [],
  },
  slashCommand: {
    enabled: true,
    ephemeral: false,
    options: [],
  },
  messageExecute: (_message, _args, _data) => {
    throw new Error('messageExecute function not implemented');
  },
  interactionExecute: (_interaction, _data) => {
    throw new Error('interactionExecute function not implemented');
  },
};

To create a new context menu, create a new file in the contexts directory with the following template:

/** @type {import('@types/ContextType')} */
module.exports = {
  name: '',
  description: '',
  type: '',
  enabled: true,
  ephemeral: false,
  userPermissions: [],
  cooldown: 0,
  execute: (_interaction) => {
    throw new Error('execute function not implemented');
  },
};

To create a new event, create a new file in the events directory with the following template:

/** @type {import('@types/EventType')} */
module.exports = {
  name: '',
  enabled: true,
  once: false,
  execute: async (_client, ..._args) => {
    throw new Error('execute function not implemented');
  },
};

Acknowledgements

Authors

Contributing

If you would like to contribute to this project, please open an issue or a pull request.