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 @@ -
- \ -
+
+ +
\ No newline at end of file diff --git a/website/views/includes/header.ejs b/website/views/includes/header.ejs index e6cee11..579ee2d 100644 --- a/website/views/includes/header.ejs +++ b/website/views/includes/header.ejs @@ -1,6 +1,5 @@ - @@ -13,7 +12,7 @@ <% } %> - + @@ -41,7 +40,7 @@ <% } %> - + @@ -103,8 +102,8 @@
Add server - -
  • Edit server +
    +
  • Add bot
    @@ -116,7 +115,7 @@ <% if (typeof user=="undefined" ) { %> Login <% }else { %> - Profile + Profile Logout <% } %>
    diff --git a/website/views/privacy.ejs b/website/views/privacy.ejs new file mode 100644 index 0000000..c6e80c2 --- /dev/null +++ b/website/views/privacy.ejs @@ -0,0 +1,43 @@ +<%- include('./includes/header.ejs', {title: 'Privacy Policy'}) %> +
    +
    +
    + +

    Privacy Policy

    +

    + 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. +

    +

    Stored Data

    +

    + We collect your personal information provided by Discord upon sign in, this includes: + + Username + User ID + Avatar + Discriminator + Any data submitted to BotsCord such as bot pages will be stored and displayed on the site until deleted by a user or site administrator. +

    +

    Advertising

    +

    + 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/. +

    +

    Cookies

    +

    Discord Bot List uses cookies to store authentication information. Cookies are also added by third party tracking.

    + +

    Links to third party Websites

    +

    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.

    + +

    Embedded content from other websites

    +

    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.

    + +

    Changes to this Privacy Statement

    +

    + The contents of this statement may be altered at any time, at our discretion.

    +
    +
    +
    \ No newline at end of file diff --git a/website/views/server/add.ejs b/website/views/server/add.ejs index aaff1f6..4ca99ba 100644 --- a/website/views/server/add.ejs +++ b/website/views/server/add.ejs @@ -52,7 +52,7 @@ });
    - \ +
    diff --git a/website/views/server/analytics.ejs b/website/views/server/analytics.ejs new file mode 100644 index 0000000..2aa3288 --- /dev/null +++ b/website/views/server/analytics.ejs @@ -0,0 +1,92 @@ +<%- include('../includes/header.ejs', {title: 'Analytics' + bot.name}) %> +
    +
    +

     Analytics

    +
    +
    +
    +
    +
    + +
    +
    +
    Votes
    +
    <%= bot.votes || 0 %>
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    Invites  +
    +
    <%= bot.analytics_invites || 0 %>
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    Visitors  + +
    +
    <%= bot.analytics_visitors || 0%>
    +
    +
    +
    +
    +
    +

    Referrers

    +

    The domain names of the sites that most redirect to your bot's page.

    +

    + + + + + + + + + <% if(bot.analytics) { %> + <% Object.keys(bot.analytics).sort((a,b) => bot.analytics[b] - bot.analytics[a]).forEach(b => { %> + + + + + <% }) %> + <% } %> + +
    Referring UrlTotal referrers
    <%= b.split(",").join(".") %><%= bot.analytics[b] %>
    + +
    +

    Countries

    +

    These are the countries that enter your bot's page.

    +

    + + + + + + + + <% + if(bot.country) { + Object.keys(bot.country).sort((a,b) => bot.country[b] - bot.country[a]).forEach(b => { + %> + + + + + <% + }) + } + %> + +
    CountryTotal viewers
     <%= b %><%= bot.country[b] %>
    +
    \ No newline at end of file diff --git a/website/views/server/edit.ejs b/website/views/server/edit.ejs index defcd98..1e7a006 100644 --- a/website/views/server/edit.ejs +++ b/website/views/server/edit.ejs @@ -10,7 +10,7 @@
    + description
    diff --git a/website/views/servers.ejs b/website/views/servers.ejs new file mode 100644 index 0000000..100e8a7 --- /dev/null +++ b/website/views/servers.ejs @@ -0,0 +1,92 @@ +<%- include("./includes/header.ejs") %> +
    + <% var nbots=bots.filter(a=> a.promoted == true) + nbots.forEach((val, key) => { + randomIndex = Math.ceil(Math.random()*(key + 1)); + nbots[key] = nbots[randomIndex]; + nbots[randomIndex] = val; + }); + if(nbots.length > 0) { %> +
    +
    +

    Promoted Servers +

    +

    These bots are featured on BotsCord!

    +
    +
    + <% } %> + <% for(let i=0; i < nbots.length; i++) { var bot=nbots[i]; if(bot) { %> + <% getBot = global.bsl.guilds.cache.get(bot.id); %> + +
    + <%= bot.name %> +
    +

    : <%= bot.votes || 0 %> +

    +
    +
    +
    + <%= bot.name %> +
    +

    + <%= bot.description %> +

    +
    + <% if(bot.tags) {%> +
    + <% bot.tags.slice(-3).forEach(tag=>{ %> + #<%= tag %> + + <% }) %> +
    + <% } %> +
    + <% } %> + <% } %> +
    +
    +
    + <% var nbots=bots + nbots.forEach((val, key) => { + randomIndex = Math.ceil(Math.random()*(key + 1)); + nbots[key] = nbots[randomIndex]; + nbots[randomIndex] = val; + }); + if(nbots.length > 0) { %> +
    +
    +

    Random Servers +

    +

    We rolled the dice and got this nice servers!

    +
    +
    + <% } %> + <% for(let i=0; i < nbots.length; i++) { var bot=nbots[i]; if(bot) { %> + <% getBot = global.bsl.guilds.cache.get(bot.id); %> +
    + <%= bot.name %> +
    +

    : <%= bot.votes || 0 %> +

    +
    +
    +
    + <%= bot.name %> +
    +

    + <%= bot.description %> +

    +
    + <% if(bot.tags) {%> +
    + <% bot.tags.slice(-3).forEach(tag=>{ %> + #<%= tag %> + + <% }) %> +
    + <% } %> +
    + <% } } %> +
    +
    +<%- include('./includes/footer.ejs') %> \ No newline at end of file diff --git a/website/views/user/edit.ejs b/website/views/user/edit.ejs index e69de29..547279b 100644 --- a/website/views/user/edit.ejs +++ b/website/views/user/edit.ejs @@ -0,0 +1,30 @@ +<%- include('../includes/header.ejs', {title: 'User' + dcuser.username}) %> +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + " /> + +
    +
    + + +
    +
    \ No newline at end of file diff --git a/website/views/user/index.ejs b/website/views/user/index.ejs index 8c4a606..ff231fa 100644 --- a/website/views/user/index.ejs +++ b/website/views/user/index.ejs @@ -4,7 +4,21 @@


    <%= users.biography || "User Has No biography" %>
    -

    +


    + Bots owned by this user: <%= bots.length %>
    + <% if(bots) { %> + <% bots.forEach(async function(bot) { %> +
    +
    + +

    <%= bot.username %>

    +
    +
    +

    <%= bot.description %>

    +
    +
    + <% }) %> + <% } %>
    <%= dcuser.name %> @@ -53,7 +67,6 @@
    <% } %> -



    \ No newline at end of file