Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximKing1 committed Dec 23, 2020
1 parent 6dbefa8 commit 4028730
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 55 deletions.
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
"callbackURL": "https://dash.striderbot.net/auth/callback",
"scope": ["identify", "guilds"]
}

71 changes: 38 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const discord = require("discord.js");
const passport = require("passport");
const client = new discord.Client({ fetchAllMembers: true });
const mongoose = require("mongoose");
const moment = require("moment");
require("moment-duration-format");
const moment = require('moment');
require('moment-duration-format');
const {
token,
mongo,
Expand Down Expand Up @@ -71,8 +71,12 @@ console.log(`[WEB STARTUP] Web Is Listening On Port ${port}`);

app.use(
session({
<<<<<<< HEAD
secret:
"gyutfgdtufatufdfauyfdtuafw62f3wtf26qf75t23qtftdfq57dftq7u2fd7q2tfcd7tq2ft7qftyye55auheguipafeguifeagufeg9ufea5u80a09hj08ha08yh0aihe5y08ihe508d752fq7tdt7qfad7qtfd68q2fdr6q275d75qd75q75q75di75q",
=======
secret: "gyutfgdtufatufdfauyfdtuafw62f3wtf26qf75t23qtftdfq57dftq7u2fd7q2tfcd7tq2ft7qfd752fq7tdt7qfad7qtfd68q2fdr6q275d75qd75q75q75di75q",
>>>>>>> parent of 525bd1e... fixed the dashboard status command, you were fetching info weirdly. Mongoose error was explained in the dms
resave: false,
saveUninitialized: false,
})
Expand Down Expand Up @@ -105,7 +109,7 @@ app.get("/logout", function (req, res) {
});
});

app.get("/stats", (req, res) => {
app.get('/stats', (req, res) => {
const guilds = client.guilds.size;
res.render(path.resolve(`./views/stats.ejs`), {
bot: client,
Expand All @@ -121,8 +125,8 @@ app.get("/stats", (req, res) => {
memoryUsage: (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2),
dVersion: Discord.version,
nVersion: process.version,
bVersion: client.version,
},
bVersion: client.version
}
});
});

Expand All @@ -133,7 +137,17 @@ const doauth = require("discord-oauth2");
const { access } = require("fs");
const { profile } = require("console");
const oauth = new doauth();
<<<<<<< HEAD

=======
mongoose.connect(mongo, {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true,
useFindAndModify: false
});
mongoose.set('returnOriginal', false);
>>>>>>> parent of 525bd1e... fixed the dashboard status command, you were fetching info weirdly. Mongoose error was explained in the dms
app.get("/dashboard", async (req, res) => {
if (!req.isAuthenticated()) return res.redirect("/auth");
await res.render("dashboard", {
Expand Down Expand Up @@ -221,10 +235,7 @@ app.post("/settings/:guildID", async (req, res, next) => {
await GuildSettings.findOneAndUpdate(
{ guildID: req.params.guildID },
{ welcome: !req.body.welcomes ? false : true, welchid: req.body.welcomech },
{
leave: !req.body.leaves ? false : true,
leavechannelid: req.body.leavech,
},
{ leave: !req.body.leaves ? false : true, leavechannelid: req.body.leavech },
{ new: true, upsert: true, setDefaultsOnInsert: true }
);
const guild = client.guilds.cache.get(req.params.guildID);
Expand Down Expand Up @@ -318,10 +329,7 @@ app.post("/information/:guildID", async (req, res, next) => {
await GuildSettings.findOneAndUpdate(
{ guildID: req.params.guildID },
{ welcome: !req.body.welcomes ? false : true, welchid: req.body.welcomech },
{
leave: !req.body.leaves ? false : true,
leavechannelid: req.body.leavech,
},
{ leave: !req.body.leaves ? false : true, leavechannelid: req.body.leavech },
{ new: true, upsert: true, setDefaultsOnInsert: true }
);
const guild = client.guilds.cache.get(req.params.guildID);
Expand Down Expand Up @@ -412,19 +420,13 @@ app.post("/logs/:guildID", async (req, res, next) => {
await logs.findOneAndUpdate(
{ guildID: req.params.guildID },
{ logging: !req.body.logs ? false : true, logchid: req.body.logch },
{
serverupdates: !req.body.serverupdates ? false : true,
serverupdatesid: req.body.serverupdatesid,
},
{ serverupdates: !req.body.serverupdates ? false : true, serverupdatesid: req.body.serverupdatesid },
{ new: true, upsert: true, setDefaultsOnInsert: true }
);
await GuildSettings.findOneAndUpdate(
{ guildID: req.params.guildID },
{ welcome: !req.body.welcomes ? false : true, welchid: req.body.welcomech },
{
leave: !req.body.leaves ? false : true,
leavechannelid: req.body.leavech,
},
{ leave: !req.body.leaves ? false : true, leavechannelid: req.body.leavech },
{ new: true, upsert: true, setDefaultsOnInsert: true }
);
const guild = client.guilds.cache.get(req.params.guildID);
Expand Down Expand Up @@ -520,10 +522,7 @@ app.post("/giveaways/:guildID", async (req, res, next) => {
await GuildSettings.findOneAndUpdate(
{ guildID: req.params.guildID },
{ welcome: !req.body.welcomes ? false : true, welchid: req.body.welcomech },
{
leave: !req.body.leaves ? false : true,
leavechannelid: req.body.leavech,
},
{ leave: !req.body.leaves ? false : true, leavechannelid: req.body.leavech },
{ new: true, upsert: true, setDefaultsOnInsert: true }
);
const guild = client.guilds.cache.get(req.params.guildID);
Expand Down Expand Up @@ -558,12 +557,18 @@ app.post("/giveaways/:guildID", async (req, res, next) => {
});
});
client.on("message", async (message) => {
const settings = await server.findOne({ guildID: message.guild.id });
const prefix = settings.prefix;
const args = message.content.trim().split(/ +/g);
const cmd = args[0].slice(prefix.length).toLowerCase();
if (!message.content.toLowerCase().startsWith(prefix)) return;
if (cmd === "dashboardstatus") {
message.reply("The Dashboard Is Online!\n**Dashboard Node:** Online");
}
server.findOneAndUpdate(
{ guildID: message.guild.id },
{},
{ new: true, upsert: true, setDefaultsOnInsert: true },
async (err, p) => {
const prefix = p.prefix;
const args = message.content.trim().split(/ +/g);
const cmd = args[0].slice(prefix.length).toLowerCase();
if (!message.content.toLowerCase().startsWith(prefix)) return;
if (cmd === "dashboardstatus") {
message.reply("The Dashboard Is Online!\n**Dashboard Node:** Online");
}
}
);
});
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"express-session": "^1.17.1",
"moment": "^2.29.1",
"moment-duration-format": "^2.3.2",
"mongoose": "^5.11.8",
"mongoose": "^5.11.1",
"passport": "^0.4.1",
"passport-discord": "^0.1.4"
}
Expand Down

0 comments on commit 4028730

Please sign in to comment.