- What is this bot?
- Setup Instructions
- REST API Usage
- Dashboard Setup Instructions
- Contributing
- Issues
- License
The Discord Community Bot is designed to make community management easier for server admins and mods, regardless of the size of the community.
To set up the Discord Community Bot, follow these steps:
-
Clone the Repository:
git clone https://github.com/krushna06/Community-Bot
-
Install Dependencies:
npm install
-
Rename
example.config.json
toconfig.json
and fill it inside theconfig
folder. -
Start the Bot:
node index.js
The REST API provides information about the commands available in the Discord bot. Here are the details on how to use the API.
http://localhost:3000/api/v1
- URL:
/commands
- Method:
GET
- Description: Retrieves a list of command categories and the commands within each category.
const express = require('express');
const cors = require('cors');
const fs = require('fs');
const path = require('path');
const router = express.Router();
router.use(cors());
// Middleware to log requests
router.use((req, res, next) => {
console.log(`[${new Date().toISOString()}] ${req.method} ${req.originalUrl}`);
next();
});
const getCommandDetails = (dir) => {
const commandDetails = [];
const commandFolders = fs.readdirSync(dir);
for (const folder of commandFolders) {
const commandFiles = fs.readdirSync(path.join(dir, folder)).filter(file => file.endsWith('.js'));
const commands = commandFiles.map(file => path.basename(file, '.js'));
if (commands.length > 0) {
commandDetails.push({
category: folder,
commands: commands,
});
}
}
return commandDetails;
};
router.get('/commands', (req, res) => {
const commandDetails = getCommandDetails(path.join(__dirname, '../../commands'));
res.json({ commandDetails });
});
module.exports = router;
To get the command details, you can use any HTTP client like curl
, Postman, or simply open your browser and navigate to the following URL:
http://localhost:3000/api/v1/commands
{
"commandDetails": [
{
"category": "Info",
"commands": ["help", "uptime"]
},
{
"category": "Moderation",
"commands": ["kick"]
}
]
}
- Open Postman.
- Create a new GET request.
- Enter the request URL:
http://localhost:3000/api/v1/commands
. - Send the request.
- View the response in JSON format, showing the command categories and the commands within each category.
To set up the Discord Community Bot's Dashboard, follow these steps:
-
Install Dependencies:
npm install
-
Enter your
base api url
indashboard/config.json
ordashboard/.env
. -
Build the nextjs project:
npm run build
-
Start the dashboard:
npm run start
If you disable the REST API in the config.json, the dashboard won't be able to fetch the stats & commands.
Contributions to this project are welcome! If you'd like to contribute, please fork the repository and submit a pull request with your changes.
If you encounter any issues or have suggestions, please open an issue on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for details.