- Easy to use package for the implementation of MongoDB in aoi.js with minimal changes.
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..
- 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:
Then paste it in the URL field of the database setup, and you're pretty much done!
- Make sure you allowed ALL IPS to connect to your mongoDB server.
Security
-> Network Access
-> Allow all IPs