Skip to content

This is the version 1.0 of this bot in future I am planning add more features to it

Notifications You must be signed in to change notification settings

Dragon4926/Discord-Bot-with-MySQL-Database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord Bot with MySQL Database

This is a simple Discord bot that connects to a MySQL database and responds to user requests to display images stored in the database.

Prerequisites

  • A Discord account
  • A Discord server where you have permission to add a bot
  • A MySQL database with at least one table that contains image URLs and corresponding IDs
  • Node.js and npm installed on your computer

Installation

  1. Clone this repository to your local machine
  2. Install the required dependencies by running npm install
  3. Create a .env file in the root directory of the project with the following variables:
  4. PASSWORD=your_mysql_password
    TOKEN=your_discord_bot_token
    GUILD_ID=your_channel_id
    CLIENT_ID=your_bot_application_id
    

    Replace your_mysql_password with the password for your MySQL database, and your_discord_bot_token with the token for your Discord bot. You can obtain a bot token by creating a new bot application in the Discord developer portal.

  5. Update the db constant in index.js with your MySQL database credentials:
  6. const db = mysql.createConnection({
    host: 'your_mysql_host',
    user: 'your_mysql_username',
    password: process.env.PASSWORD,
    database: 'your_mysql_database_name'
    });
    

    Replace your_mysql_host, your_mysql_username, and your_mysql_database_name with your MySQL database information.

  7. Create a table in your MySQL database to store your images. The table should have at least two columns: id and url.
  8. Insert some images into the database with their corresponding IDs.

Usage

To run the bot, use the command npm start. The bot will connect to your Discord server and listen for user requests to display images. Users can request an image by typing !show <id> in the chat, where <id> is the ID of the image they want to display.

Contributing

If you have any suggestions or find any bugs, please feel free to open an issue or submit a pull request.

About

This is the version 1.0 of this bot in future I am planning add more features to it

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published