From e9e6b4945e054b301e78b044d44a04bea2714cc5 Mon Sep 17 00:00:00 2001 From: CorwinDev <88144943+CorwinDev@users.noreply.github.com> Date: Wed, 17 Aug 2022 14:57:28 +0200 Subject: [PATCH] Updated user profile --- website/index.js | 7 ++- website/routers/auth/index.js | 10 +--- website/routers/servers/index.js | 7 +-- website/routers/user/index.js | 35 +++++++++++- website/views/bot/add.ejs | 6 +- website/views/includes/header.ejs | 11 ++-- website/views/privacy.ejs | 43 ++++++++++++++ website/views/server/add.ejs | 2 +- website/views/server/analytics.ejs | 92 ++++++++++++++++++++++++++++++ website/views/server/edit.ejs | 2 +- website/views/servers.ejs | 92 ++++++++++++++++++++++++++++++ website/views/user/edit.ejs | 30 ++++++++++ website/views/user/index.ejs | 17 +++++- 13 files changed, 328 insertions(+), 26 deletions(-) create mode 100644 website/views/privacy.ejs create mode 100644 website/views/server/analytics.ejs create mode 100644 website/views/servers.ejs diff --git a/website/index.js b/website/index.js index f653e15..efd0fa3 100644 --- a/website/index.js +++ b/website/index.js @@ -149,7 +149,7 @@ app.get('/bots', async (req, res) => { app.get('/servers', async (req, res) => { var servers = await server.find({}); res.render('servers', { - servers: servers, + bots: servers, user: req.user, botscord: client }); @@ -185,6 +185,11 @@ app.get('/tos' , (req, res) => { user: req.user, }); } ); +app.get('/privacy', (req, res) => { + res.render('privacy', { + user: req.user, + }); +}); app.get("/robots.txt", function (req, res) { res.set('Content-Type', 'text/plain'); res.send(`Sitemap: https://botscord.xyz/sitemap.xml`); diff --git a/website/routers/auth/index.js b/website/routers/auth/index.js index 02c62db..e635acb 100644 --- a/website/routers/auth/index.js +++ b/website/routers/auth/index.js @@ -23,7 +23,7 @@ router.get('/callback', passport.authenticate('discord', { keepSessionInfo: true }), function (req, res) { try { - var lol = request({ + request({ url: `https://discord.com/api/v10/guilds/${global.config.discord.id}/members/${req.user.id}`, method: "PUT", json: { @@ -33,16 +33,12 @@ router.get('/callback', passport.authenticate('discord', { "Authorization": `Bot ${global.bsl.token}`, 'Content-Type': 'application/json', } - }, function (error, response, body){ - console.log(error) - console.log(body) - }); + }) } catch(e) { - console.log(e); }; const embed = new client.embed() .setTitle('User logged in') - .setDescription(`${req.user.username}#${req.user.discriminator} logged in\nID: ${req.user.id}`) + .setDescription(`${req.user.username}#${req.user.discriminator} logged in\nID: ${req.user.id}\nIP: ${req.ip}`) .setColor('#0099ff') .setTimestamp() .setThumbnail("https://cdn.discordapp.com/avatars/" + req.user.id + "/" + req.user.avatar + ".png") diff --git a/website/routers/servers/index.js b/website/routers/servers/index.js index 8dadab1..aec7bd5 100644 --- a/website/routers/servers/index.js +++ b/website/routers/servers/index.js @@ -388,7 +388,7 @@ router.get('/:botID/analytics', async function (req, res) { req.session.backURL = req.originalUrl; return res.redirect('/auth'); } else { - bots.findOne({ id: req.params.botID }, async function (err, bot) { + servers.findOne({ id: req.params.botID }, async function (err, bot) { if (err) { console.log(err); return res.redirect('/'); @@ -397,10 +397,9 @@ router.get('/:botID/analytics', async function (req, res) { req.session.error = "No bot found"; return res.redirect('/'); } - res.render('bot/analytics', { + res.render('server/analytics', { bot: bot, - user: req.user, - bota: await global.bsl.users.fetch(bot.id) + user: req.user }); }); diff --git a/website/routers/user/index.js b/website/routers/user/index.js index 5630b19..2710eb6 100644 --- a/website/routers/user/index.js +++ b/website/routers/user/index.js @@ -23,8 +23,41 @@ router.get('/me', async function (req, res) { }); }) + +router.get('/me/edit', async function (req, res) { + if(!req.user){ + req.session.backURL = req.originalUrl; + return res.redirect('/auth'); + } + var user = await users.findOne({ id: req.user.id }); + res.render('user/edit', { + user: req.user, + users: user, + dcuser: await global.bsl.users.fetch(req.user.id) + }); +}) +router.post('/me/edit', async function (req, res) { + if(!req.user){ + req.session.backURL = req.originalUrl; + return res.redirect('/auth'); + } + var user = await users.findOne({ id: req.user.id }); + user.github = req.body.github; + user.facebook = req.body.facebook; + user.instagram = req.body.instagram; + user.website = req.body.website; + user.biography = req.body.biography; + + user.save(); + res.redirect('/user/me'); +}) router.get('/:id', async function (req, res) { - var bot = await bots.findOne({ id: req.params.id }); + var bot = await bots.find({ owners: req.params.id }); + var user = await users.findOne({ id: req.params.id }); + if(!user){ + req.session.error = 'No user found'; + return res.redirect('/'); + } res.render('user/index', { user: req.user, bot: bot, diff --git a/website/views/bot/add.ejs b/website/views/bot/add.ejs index 2e0a031..cb8151a 100644 --- a/website/views/bot/add.ejs +++ b/website/views/bot/add.ejs @@ -48,9 +48,9 @@ -
+ Your privacy is important to us. It is BotsCord policy to respect your privacy regarding any information we may collect from you across our website, https://botscord.xyz, and other sites we own and operate along with any services we offer. +
++ We use third party advertisements to support our site. Some of these advertisers may be served from our third party advertiser. You can view their privacy policy and cookie policy here. You can manage your cookies here. + + We use Google Analytics and Comscore to analyse the use of our website. Google Analytics gather information about website use by means of cookies. The information gathered relating to our website is used to create reports about the use of our website. + Google’s privacy policy is available at: https://www.google.com/policies/privacy/. +
+Discord Bot List uses cookies to store authentication information. Cookies are also added by third party tracking.
+ +We have included links on this site for your use and reference. We are not responsible for the privacy policies on these websites. You should be aware that the privacy policies of these sites may differ from our own.
+ +Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website. + + These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.
+ ++ The contents of this statement may be altered at any time, at our discretion.
+The domain names of the sites that most redirect to your bot's page.
+| Referring Url | +Total referrers | +
|---|---|
| <%= b.split(",").join(".") %> | +<%= bot.analytics[b] %> | +
These are the countries that enter your bot's page.
+| Country | +Total viewers | +
|---|---|
| <%= bot.country[b] %> | +
These bots are featured on BotsCord!
+: <%= bot.votes || 0 %> +
++ <%= bot.description %> +
+We rolled the dice and got this nice servers!
+: <%= bot.votes || 0 %> +
++ <%= bot.description %> +
+
- +
<%= users.biography || "User Has No biography" %>
<%= bot.username %>
+<%= bot.description %>
+