https://github.com/matta-official/discord-bot
🤖 A simple Discord bot framework/template.
https://github.com/matta-official/discord-bot
bot discord nodejs
Last synced: 3 months ago
JSON representation
🤖 A simple Discord bot framework/template.
- Host: GitHub
- URL: https://github.com/matta-official/discord-bot
- Owner: MattA-Official
- Created: 2021-07-31T18:08:41.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-10T16:24:14.000Z (almost 5 years ago)
- Last Synced: 2024-05-02T05:24:12.912Z (about 2 years ago)
- Topics: bot, discord, nodejs
- Language: JavaScript
- Homepage:
- Size: 116 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🤖 Discord Bot
A simple Discord bot & command/event framework. Supporting slash and message commands.
## Features
- Slash Commands
- Message Commands
- Full API coverage (using [discord.js](https://discord.js.org))
- Runs on Node
- `es6` syntax
## Run Locally
Clone the project
```bash
git clone https://github.com/matta-official/bot.git
```
Go to the project directory
```bash
cd bot
```
Install dependencies
```bash
yarn install
#or
npm install
```
Start the server
```bash
yarn start
#or
npm run start
```
## Environment Variables
To run this project, you will need to add the following environment variables to your .env file
1. `BOT_TOKEN` - Your bot token found at the [Discord Developer Portal](https://discord.com/developers)
2. `REDIS_URI` - The URI to your [Redis](https://redis.io) db instance. Usually `redis://:@127.0.0.1:6379`
3. `GUILD_ID` - The ID of the guild you want to run the bot in.
## Contributing
Contributions are always welcome!
See [`contributing.md`](/contributing.md) for ways to get started.
Please adhere to this project's [`code of conduct`](/code_of_conduct.md).
## Authors
- [@matta-official](https://www.github.com/matta-official)
# Reference
## Commands
All commands require the following data export:
```js
export const data = {
name: 'name',
description: 'a description of what the command does',
options: [], // optional - array of #ApplicationCommandOption
defaultPermissions: false, // optional - boolean whether to allow access by default
};
export const permissions = []; // optional - array of #ApplicationCommandPermission
```
### Message
Message commands should be exported as shown below:
```js
export const message = true;
export const execute = async (client, msg, args) => {
// command logic in here
};
```
### Slash
Slash commands should be exported as shown below:
```js
export const slash = true;
export const interaction = async (client, interaction) => {
// command logic in here
};
```
## Components
Components are are a framework for adding interactive elements to messages. All components require the following exports:
```js
export const data = {
id: 'id',
};
export const interaction = async (client, interaction) => {
// component logic in here
};
```
## Events
Events have a different number of arguments passed, check the discord.js documentation for information on each. Always pass the client before any additional arguments.
```js
export const name = 'name';
export const once = true;
export const execute = async (client, ...args) => {
// event logic in here
};
```
## Database
Currently, the database only supports Redis. However, it is planned to support other databases in the future. This is due to the ease of using mulitple databases in Keyv. The database is accessed through the `client.db` object. It is not required to use a persistant database, but it is recommended. If `REDIS_URI` is not set, an in-memory store will be used.