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.
- Clone the repository
git clone https://github.com/FantaCovid-19/discord.js-bot-template.git
- Install the dependencies
npm install
or
yarn install
- 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"
- Start the bot
npm start
or
yarn start
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');
},
};
If you would like to contribute to this project, please open an issue or a pull request.