/Discord-bot-js-2024

CS discord bot js implementation

Primary LanguageJavaScript

Discord Bot Repository Readme

Welcome to CS discord bot repository. This repository contains the code for the Discord bot that is used in the CS discord server. The bot is built using Discord.js and uses Google Sheets and MongoDB as its database.

Prerequisites

Before you begin, make sure you have the following installed:

Steps to Set Up Your Discord Bot

1. Install Dependencies

Before running the bot, install the required dependencies by running:

npm install

Don't forget to adjust the config.json file to your server .

2. Create a Discord Bot

  • Visit the Discord Developer Portal.
  • Click on "New Application" to create a new Discord application.
  • In the "Bot" tab, click on "Add Bot" to create a bot user.
  • Copy the token generated for your bot and paste it into the .env file under the key BOT_TOKEN.

3. Set Up Google APIs

  • Create a new project on the Google Cloud Console.
  • Enable the Google Sheets API for your project.
  • Create credentials for your project and download the JSON file.
  • Place the downloaded creds.json file in the root of your repository.
  • Run npm run encrypt to encrypt the credentials for security.

4. Create a Google Spreadsheet

  • Create a new Google Spreadsheet in your Google Drive.
  • Share the spreadsheet with the email address of your bot user.
  • Copy the Spreadsheet ID from the URL and paste it into the .env file under the key GOOGLE_SHEET_ID.

5. Set Up MongoDB

  • Create a MongoDB cluster on MongoDB Atlas.
  • Get the connection string for your cluster.
  • Paste the connection string into the .env file under the key MONGODB_URI.
  • don't forget to add your password and database name to the connection string.
  • don't forget to open your IP address in the network access tab or it for all IP.

6. Run the Bot

Now that everything is set up, you can run the bot using:

npm run dev

Your bot should now be active on Discord, connected to Google Sheets, and using MongoDB as its database.

Feel free to explore the code, customize the bot to your liking, and add more features as needed. Happy coding!