A web site and a discord bot?

I want to make a discord bot and have a website dashboard. My Project is randombot4211

Hey @MrDiamond64,

After creating all the bot related code and commands in server.js, install Express and do the basic routing for GET requests to a index.html (which will serve as a webpage) in the views folder. Something like this (if your webpage is located in a views folder):

const express = require('express');
const app = express();

// The public folder will have all the styles and scripts 

app.get("/", function(req, res) {
  res.sendFile(__dirname + "/views/index.html");

Do you need help with something speciffically? Or are you just wanting starting code

Hi @shadowdevelopment,

Yes i would like starting code.

Hi @MrDiamond64

To integrate the Discord Bot with the dashboard. You’ll need to have Discord Authentication setup and the database too (i think, I haven’t made a dashboard in a long time so I kinda forgot lol), you can get the Client Secret, Client ID and callback URI links which is used for authentication (with a module called passport).

You will then need to make a base server.js file which must have express.js defined and installed to do routing for GET requests to a index.html file as @khalby786 said. Although, people have used .ejs as their html files to make the dashboard development easier since using <% username %> for example will output the username in the webpage.

So for ejs, don’t use sendFile as that will actually download the file, do render:

app.get("/", function(req, res) {
  res.render(__dirname + "/views/index.ejs");

and another example

app.get("/dashboard", checkAuth, function(request, response) {
response.render(__dirname + '/public/new.ejs', {
  tag: request.user.username + " #" + request.user.discriminator,
  username: request.user.username,
  id: request.user.id,
  connections: request.user.connection,
  avatar: "https://cdn.discordapp.com/avatars/" + request.user.id + "/" + request.user.avatar + ""

checkAuth is whats used to determine if the user has logged in or not.


I have a good tutorial here: https://tutorial.botcord.site