Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mongo Gen

A modern Discord.js bot that provisions MongoDB Atlas projects and returns the connection string in a private DM.

What changed

  • Rebuilt the project around a clean src/ layout.
  • Upgraded the bot to Discord.js v14 style.
  • Replaced embeds with component v2 container cards.
  • Added public-repo friendly config handling and ignored secrets.
  • Refreshed the docs so the project is easier to publish and maintain.

Features

  • /gen generates a fresh Atlas project, cluster, user, and connection string.
  • /custom-gen lets you choose the Atlas database username and password.
  • /mongo-status checks whether a MongoDB URI is reachable.
  • /ping shows gateway latency, API latency, and uptime in a modern card.
  • Private delivery for secrets through DMs.

Requirements

  • Node.js 18.17 or newer
  • A Discord bot application
  • MongoDB Atlas API credentials
  • An Atlas organization ID

Project Structure

Mongo Gen/
  index.js
  src/
    commands/
    config/
    services/
    ui/
    utils/

Setup

  1. Install dependencies.
npm install
  1. Create a local config.json by copying config.example.json.

  2. Fill in your values.

{
  "token": "DISCORD_BOT_TOKEN",
  "clientId": "DISCORD_APPLICATION_CLIENT_ID",
  "public_key": "MONGODB_ATLAS_PUBLIC_KEY",
  "private_key": "MONGODB_ATLAS_PRIVATE_KEY",
  "org_Id": "MONGODB_ATLAS_ORG_ID",
  "atlasRegion": "US_EAST_1",
  "projectPrefix": "mongo-gen"
}

Configuration Fields

  • token is your Discord bot token.
  • clientId is your Discord application client ID.
  • public_key and private_key are MongoDB Atlas API keys.
  • org_Id is the Atlas organization ID.
  • atlasRegion is the cluster region. US_EAST_1 is the default.
  • projectPrefix is the base name used for generated Atlas projects.

Running the Bot

npm start

On startup, the bot logs in and syncs its slash commands automatically.

Slash Commands

/gen

Generates a new Atlas project and a random username/password pair.

/custom-gen

Generates a new Atlas project using the username and password you provide.

/mongo-status

Checks whether a MongoDB URI can connect and respond to a ping.

/ping

Shows bot latency and uptime.

How It Works

  1. You run a generation command.
  2. The bot creates an Atlas project.
  3. It provisions an M0 cluster.
  4. It creates the database user.
  5. It whitelists the IP access list.
  6. It waits for the cluster to finish provisioning.
  7. It DMs the final connection string to you in a component v2 card.

Public Repo Notes

  • Keep config.json out of version control.
  • Do not publish real Atlas keys or Discord tokens.
  • If you want to distribute this publicly, rotate your keys before pushing.
  • The generator can create real cloud resources, so make sure your Atlas organization is configured the way you expect.

Troubleshooting

  • If commands do not appear, restart the bot and give Discord a moment to refresh global slash commands.
  • If DMs fail, enable direct messages from server members and rerun the command.
  • If Atlas provisioning fails, verify the Atlas API keys, organization ID, and region.
  • If /mongo-status fails, confirm the URI is valid and the cluster allows your current IP.

Recommended Workflow

  1. Configure config.json.
  2. Start the bot.
  3. Invite it to your Discord server.
  4. Run /ping to verify the bot is alive.
  5. Run /gen or /custom-gen.

License

No license file is included yet. Add one before publishing the repository publicly if you want others to reuse the code.

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages