Logging of Cmdr commands (Through the website)

By using this open-source project, you can configure your website and CMDR tool so that commands entered by your employees are displayed on a website accessible through Discord authentication, provided that the user’s ID is added to the list of employees with access to the site. Currently, the website is designed to be deployed on the Netlify platform, which allows you to keep your site running for free 24/7 (note that there are limits on monthly requests; please review Netlify’s terms). On the website, you can select the type of command (Notify, Warn, Alarm); for instance, you can view only Warn or Alarm, or see all logs mixed together. I will explain how to configure the project so you can implement this system for your own project!

How to configure CMDR to send information to the website?

Go to GitHub and download the project; it contains all the necessary files for further configuration (including files for the website).

Navigate to the CMDR folder and drag the “init” and “CmdrLogsModule” files into your Roblox Studio project.

The init file contains the standard CMDR setup but with code lines for module interaction. In init, under the Constant “CommandType,” you can add commands to the list for which you want to assign one of the three types (Notif, Warn, and Alarm). Notif will be the default for all commands. Next, go to the “CmdrLogsModule” and specify the link to your website (if you haven’t set it up yet, skip this step). Then, create a secret code to ensure that no one but your project can interact with your website.

Congratulations! You have successfully configured CMDR to send data to the website, but that’s not all—read the following tips!

Screenshots


How to configure a Discord project for website authentication?

Create a project on the Discord Developer Portal, name it as you wish, then go to the “OAuth2” section and copy the CLIENT ID and CLIENT SECRET. Next, in the same section under “Redirects,” click on “Add Redirect,” and paste the link to your website, specifying the path “/.netlify/functions/callback” (if you haven’t set up your website yet, skip this step).

Congratulations! You have completed the second setup step, but we still need to deploy and configure the website!

Screenshots

How to create a database in MongoDB?

Now let’s figure out how to create a database in MongoDB. Go to the MongoDB website and log in. Then, create a project with any name you prefer.

After creating the project, go to the “Database” section and click the “Build a Cluster” button. Choose a plan (there is a free one), enter a convenient name for your cluster, and click the “Create Deployment” button. After that, click the “Choose a connection method” button and select the “Drivers” method. Copy the connection string for your cluster (it looks like this: mongodb+srv://<email>:<password>@cluster0.a9ou03d.mongodb.net/?retryWrites=true&w=majority&appName=<appName>) and click “Done.”

Congratulations! You have completed setting up your database!

How to deploy and configure the website?

Now that you have configured CMDR and set up your project in the Discord Developer Portal, we need to deploy and configure the website. To do this, go to the downloaded files from GitHub and find the “CLS” folder. Open this folder in your preferred editor (I prefer Visual Studio Code).

Then open the console and enter the command “npm I” to install all dependencies.

Next, go to the “public/js” folder and open the “check-access.js” file. On line 91, specify the “CLIENT ID” from your Discord project, which I asked you to save earlier. Save the project and create a new repository on GitHub, publishing this folder there.

After that, go to the Netlify website and log in using a method convenient for you (you can use GitHub). Then, on the “Sites” page, click the “Add new site” button, select “Import an existing project,” and choose the project where you added the “CLS” folder. In the “Publish directory” field, enter “public,” and in the “Functions directory” field, enter “netlify-functions.” Now, click the “Add environment variables” button five times to add five variables. In the first row, write “DISCORD_CLIENT_ID” and in the value, enter the ID of your Discord project. In the second row, write “DISCORD_CLIENT_SECRET” and enter the secret ID of your Discord project. In the third row, write “MONGODB_URI” and enter the URI of your MongoDB database in the format (mongodb+srv://<email>:<password>@cluster0.a9ou03d.mongodb.net/?retryWrites=true&w=majority&appName=<appName>).

In the fourth row, write “SECRET_API_KEY” and enter your secret API key, which you set up in the CMDR “CmdrLogsModule.” In the fifth row, write “STAFF_IDS” and enter the Discord IDs of users who will have access to your site. Now click the button below, and the project will start deploying. Open the edited folder in your preferred editor.

Once your project on Netlify is published, you will receive the URL of your website, which you need to specify in the script at (netlify-functions/callback.js). Insert your site’s URL in line 7 and specify the path /.netlify/functions/callback. In line 49, specify your site’s URL again without any additional paths. Next, go to the “check-access.js” script located in (public/js), and in line 92, insert your site’s URL with the path “/.netlify/functions/callback”. Save the project and publish it in your created GitHub repository. Netlify will rebuild your project, and all that’s left is to visit your site, log in, and start viewing logs.

I hope everything worked out for you. If you have any questions, problems, or suggestions, feel free to leave a message under this post!

I agree that there is a lot of material to learn, but it’s not as difficult as it might seem. I have described each step to make it clear what to do at each stage. I hope everything worked out for you and that you are satisfied with the result. If you encounter any problems, errors, questions, or suggestions, leave your message under this post, and I will try to help you as soon as possible :blush:

Screenshots

Link to the project on Github: GO
Support Server: Ellefire Company (Discord)
Demo Site: cmdr-logs-demo

The project is registered under the MIT license

2 Likes

Thanks for the detailed instructions. This will be useful in my game

1 Like