NAV Navbar

Introduction

The Kleidi Auth Bot is organized and setup on a variety of differrent paramters and settings to ensure the most customizability possible while retaining easy to use and quick features for Discord group users and admins. For the most part it isn't all that hard to get up and running. For starters I recommend that you have the latest version of Node.js installed to get everything up and running for the most part. Depending on where you've retrieved the source code from, simply cd into the the server directory and run the npm install command. If you have trouble installing the dependencies on macOS or Linux, be sure to run sudo npm install instead.

After all you have installed everything you can simply run the npm start command to get the server up and running. Before you do so it is important to create a configuration file. Using your favorite text-editor be sure to rename the config.example.json to config.json. After doing so you can make changes to the fields in the file.

Creating a Configuration File

Example config.json file:

{
    "production": true,
    "groupName": "Kleidi Auth Bot",
    "domain": "https://domain.com",
    "session_secret": "xxxxx",
    "botToken": "xxxxx",
    "botClientID": "xxxx",
    "serverPort": 3000,
    "mongodb_uri": "mongodb://user:pass@domain.com:port/db-name",
    "mode": "paypal",
    "paypal": {
        "mode": "sandbox",
        "client_id": "xxxxx",
        "client_secret": "xxxxx"
    },
    "stripe": {
        "secret_key": "xxxxx",
        "publishable_key": "xxxxx"
    },
    "mailer_settings": {
        "host": "mail.privateemail.com",
        "port": 587,
        "secure": false,
        "auth": {
          "user": "admin@domain.com",
          "pass": "1234"
        }
    },
    "discord_embed": {
        "icon_url": "https://i.imgur.com/6kYYPE5.jpg",
        "title": "Auth Bot",
        "url": "https://domain.com/"
    },
    "additional_routes": []
}

Make sure to your production value is set as true if you intent on publishing to the public.

Key Type Description
production Boolean Server Enviroment
groupName String Name of your Discord group, this will appear on confirmation emails.
domain String Domain name where the website is being hosted. (ex: http://domain.com)
session_secret String Secret Key for web sessions which can be generated on a site like this.
botToken String Discord Bot token which can be generated on the Discord Developer Site
botClientID String Discord Bot client ID which can be generated on the Discord Developer Site
serverPort Number Designated port for the server (example: 3000, 8080, 4891)
mongodb_uri String MongoDB URI, following this format: mongodb://user:pass@domain.com:port/db-name
mode String Payment method mode, which can be set as paypal or stripe depnding on the use case.
paypal Object (Optional) Credentials pertaining to your PayPal Business account. Click here to view details.
stripe Object (Optional) Credentials pertaining to your Stripe account. Click here to view details.
mailer_settings Object Click here to view details.
discord_embed Object Click here to view details.
additional_routes Array Click here to view details.

PayPal

{
  "mode": "live",
  "client_id": "xxxxx",
  "client_secret": "xxxxx"
}

In order to setup your keybot with PayPal, you must ensure that your PayPal account is in good standing and is a verified PayPal business account. In order to retrieve your PayPal client_id and client_secret you must first go to the PayPal Developer's website and create a REST API App pertaining to your keybot, be sure to get the live keys if you intend on running in production. Live and sandbox are different, if you want to test out the payment system, you must make sure that production is set to false and that paypal.mode is set to "sandbox".

Key Type Description
mode String If set to true, the result will also include cats.
client_id String If set to false, the result will include kittens that have already been adopted.
client_secret String If set to false, the result will include kittens that have already been adopted.

1 2

Stripe

{
  "secret_key": "xxxxx",
  "publishable_key": "xxxxx"
}

In order to setup your keybot with Stripe you must ensure that the mode in your configuration file is set to "stripe" and assign the correct keys attached to your Stripe account.

Stripe API keys can be found here when logged in: 3

Key Type Description
secret_key String Stripe API secret key found on the developer's tab of the Stripe website.
publishable_key String Stripe API publishable key found on the developer's tab of the Stripe website.

Email Sender

Example using Namecheap's Private Email Hosting via SMTP:

{
  "host": "mail.privateemail.com",
  "port": 587,
  "secure": false,
  "auth": {
      "user": "admin@domain.com",
      "pass": "1234"
  }
}

In order for keys and various notifications to be sent out to users, an email account must be setup with the server. From my personal experience, most people tend to go straight to typical Gmail accounts. This is something I personally don't recommend whatsoever. If you're goal is to gain personal attraction through professionality, an email tied to your own domain is the wave. Depending on how your mail server is setup may vary.

To find more about mail settings you can check out the Nodemailer SMTP Guide.

Key Type Description
host String The hostname or IP address to connect to (defaults to ‘localhost’).
port Number The port to connect to (defaults to 587 if is secure is false or 465 if true).
secure Boolean If true the connection will use TLS when connecting to server. If false (the default) then TLS is used if server supports the STARTTLS extension. In most cases set this value to true if you are connecting to port 465. For port 587 or 25 keep it false.
auth Object Defines authentication data (docs).

Discord Embed

{
  "icon_url": "https://i.imgur.com/sCr0tRD.png",
  "title": "Auth Bot",
  "url": "https://domain.com/"
}

4

Key Type Description
icon_url String Icon URL to your group's logo or choice of imagery.
title String Usually the name of the bot or the group, but can be anything that matches the embed for you.
url String Hyperlink to the title

Customization

Adding Additional Routes

[
  {
    "route": "/",
    "file": "index.html"
  },
  {
    "route": "/about",
    "file": "about.html"
  },
  {
    "route": "*",
    "file": "404.html"
  }
]

When setting up Kleidi for your group, you most likely want to ditch my boring landing page and add your own custom resources. Doing this is incredibly simple. All you have to do is create a folder in the views dirrectory called "extras" and in doing this you can add as many HTML files as you want with custom routes and resources. In order to add another route or override on an existing route such as /, /success, or the 404 page (*). The additional_routes field in your config.json file will contain an array of objects like the example displayed to the side of the page. If you're overriding the main page or order confirmation page I advice checking out the views/index.html and views/success.html files in the project folder.

Key Type Description
route String Desired route you want to create or override.
file String Name of the HTML file in your views/extras folder.

Adding page resources

<!doctype html>
<html>
  <head>
    <link rel="stylesheet" href="/resources/styles.css">
  </head>
  <body>
    <h1>This is my custom image!</h1>
    <img src="/resources/image.png"/>
  </body>
</html>

In the event when you want to add additional resources such as CSS, JavaScript, images, etc. You can simply do so by creating a folder called extras in the resources directory. You can easily access these resources like shown in the example.