- 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 github:faf4a/aoi.mongo
- Update your index.js file.
const { AoiClient, LoadCommands } = require("aoi.js");
const { Database } = require("aoi.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
tables: ["main"],
logging: true // enables or disables logs
});
client.variables({
variable: "value"
});
// rest of your index.js..
You can indeed transfer your database!
const { AoiClient, LoadCommands } = require("aoi.js");
const { Database } = require("aoi.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
tables: ["main"],
logging: true, // enables or disables logs
convertOldData: {
enabled: true,
dir: "./database"
},
});
client.variables({
variable: "value"
});
// rest of your index.js..
Then use https://github.com/NanotechPikachu/aoi.mongodb this version made by NanotechPikachu!
- 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!
Important
This is NOT recommended to do as it'll allow anyone to connect to your database. Only do this if your host changes your IP regularly. Otherwise provide the specific IP or a wildcard!
- Make sure you allowed ALL IPS to connect to your mongoDB server.
Security
-> Network Access
-> Allow all IPs