Providing a MongoDB Connection

Before starting to get the full features of the command, you will need to provide a MongoDB database connection first. This is because some features of this command handler needs a MongoDB connection.

To setup a MongoDB database, you will need to create a MongoDB Atlas Database in the Cloud. Unless you already have a local/cloud database, please follow these steps.

Once you get your connection string, paste it into mongoDB.uri option in the NoCliHandler instance. If you are using your local MongoDB database, I recommend you to use this type of connection string:

# With username and password
mongodb://<username>:<password>@localhost/<database_name>
# Without username and password
mongodb://localhost/<database_name>
index.js
// Library Imports
const { Client, IntentsBitField, Partials, version } = require('discord.js');
const NoCliHandler = require('nocli-handler.js').default;
const path = require('path');

// Setting Up Client Object
const client = new Client({
    // These intents are recommended for nocli-handler.js to handle commands
    intents: [
        IntentsBitField.Flags.Guilds,
        IntentsBitField.Flags.GuildMessages,
        IntentsBitField.Flags.GuildMessageReactions,
        IntentsBitField.Flags.DirectMessages,
        IntentsBitField.Flags.MessageContent,
        IntentsBitField.Flags.GuildMessageTyping
    ],
    partials: [Partials.Channel, Partials.Message]
});

client.on("ready", () => {
    const instance = new NoCliHandler({
        client,
        mongoDB: {
            uri: '<paste your connection string here>'
        },
        configuration: {
            defaultPrefix: "", // Current: !
            commandsDir: path.join(__dirname, 'commands'),
        },
        // clientVersion is required so that nocli-handler.js can help check
        // if you are on the right version as the handler
        language: "JavaScript"
    });
});

Last updated