Faf4a / aoi.js-mongo

Easy to use package for the implementation of MongoDB in aoi.js with minimal changes.

Home Page:https://www.npmjs.com/package/aoi.js-mongo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

aoi.js-mongo

  • Easy to use package for the implementation of MongoDB in aoi.js with minimal changes.

Setup

To get started with aoi.js-mongo, we have to do a couple things.

  • Install the package.
npm install aoi.js-mongo@latest
  • Update your index.js file.
const { AoiClient, LoadCommands } = require("aoi.js");
const { Database } = require("aoi.js-mongo");

const client = new AoiClient({
  token: "DISCORD BOT TOKEN",
  prefix: "DISCORD BOT PREFIX",
  intents: ["Guilds", "GuildMessages", "GuildMembers", "MessageContent"],
  events: ["onInteractionCreate", "onMessage"],
  disableAoiDB: true // This is important, ensure it's set to true. You can't use both at once.
});

const database = new Database(client, {
    url: "mongodb+srv://...", // your mongoDB server uri
    cleanup: {
      collection: "cooldown", // the collection where you store your cooldown data ("cooldown" by default)
      enabled: true, // enable cleanup of not used variables within the given collection
      duration: 86400000 // the duration of the cleanup, once a day is enough (in ms)
    },
    logging: true // enables or disables logs
});

client.variables({
    variable: "value"
});

// rest of your index.js..

MongoDB URI

  • How do I get one?

You need to be registered at https://cloud.mongodb.com/, and create a database accordingly, after you did so follow the steps below:

https://i.imgur.com/sibh7dA.png

https://i.imgur.com/YerNHad.png

https://i.imgur.com/ZTMbq4h.png

Then paste it in the URL field of the database setup, and you're pretty much done!

Server Connection Timeout

  • Make sure you allowed ALL IPS to connect to your mongoDB server.

Security -> Network Access -> Allow all IPs

img

About

Easy to use package for the implementation of MongoDB in aoi.js with minimal changes.

https://www.npmjs.com/package/aoi.js-mongo


Languages

Language:JavaScript 100.0%