Added profile and join analytics
This commit is contained in:
1 parent
ef0725439c
commit
d0a969f145
15 files changed
+227
-33
No files matched your search
+6
-2
@@ -10,10 +10,14 @@ let hm = new mongoose.Schema({
|
||||
tags: [String],
|
||||
premium: Boolean,
|
||||
invite: String,
|
||||
votes: Number,
|
||||
votes: { type: Number, default: 0 },
|
||||
bump: Date,
|
||||
webhook: String,
|
||||
bumps: Number,
|
||||
bumps: { type: Number, default: 0 },
|
||||
analytics: Object,
|
||||
analytics_visitors: Number,
|
||||
analytics_joins: Number,
|
||||
country: Object,
|
||||
});
|
||||
|
||||
module.exports = mongoose.model("servers", hm);
|
||||
+4
-4
@@ -3,10 +3,10 @@ let model = new mongoose.Schema({
|
||||
id: String,
|
||||
biography: { type: String, default: null },
|
||||
coins: String,
|
||||
website: { type: String, default: null },
|
||||
github: { type: String, default: null },
|
||||
twitter: { type: String, default: null },
|
||||
instagram: { type: String, default: null }
|
||||
website: String,
|
||||
github: String,
|
||||
twitter:String ,
|
||||
instagram: String
|
||||
});
|
||||
|
||||
module.exports = mongoose.model("profiles", model);
|
||||
@@ -164,7 +164,22 @@ app.get('/tag/:id', async (req, res) => {
|
||||
tag: id,
|
||||
});
|
||||
});
|
||||
app.get('/i/:id', async (req, res) => {
|
||||
var id = req.params.id.toLowerCase();
|
||||
var bott = await bots.findOne({ name: { $regex: req.params.id }});
|
||||
if(!bott){
|
||||
var serverr = await server.findOne({ name: { $regex: req.params.id }});
|
||||
if(!serverr){
|
||||
res.redirect('/');
|
||||
return
|
||||
}
|
||||
res.redirect('/server/' + serverr.id + '/join');
|
||||
return
|
||||
}
|
||||
res.redirect('/bot/' + bott.id + '/join');
|
||||
return
|
||||
|
||||
});
|
||||
app.get('/tos' , (req, res) => {
|
||||
res.render('tos', {
|
||||
user: req.user,
|
||||
|
||||
@@ -825,6 +825,9 @@ video {
|
||||
.h-3 {
|
||||
height: 0.75rem;
|
||||
}
|
||||
.h-96 {
|
||||
height: 24rem;
|
||||
}
|
||||
.max-h-fit {
|
||||
max-height: -webkit-fit-content;
|
||||
max-height: -moz-fit-content;
|
||||
@@ -909,6 +912,9 @@ video {
|
||||
.w-1\/4 {
|
||||
width: 25%;
|
||||
}
|
||||
.w-96 {
|
||||
width: 24rem;
|
||||
}
|
||||
.min-w-fit {
|
||||
min-width: -webkit-fit-content;
|
||||
min-width: -moz-fit-content;
|
||||
@@ -931,6 +937,9 @@ video {
|
||||
max-width: -moz-fit-content;
|
||||
max-width: fit-content;
|
||||
}
|
||||
.max-w-md {
|
||||
max-width: 28rem;
|
||||
}
|
||||
.flex-initial {
|
||||
flex: 0 1 auto;
|
||||
}
|
||||
@@ -1209,6 +1218,9 @@ video {
|
||||
.border-b-2 {
|
||||
border-bottom-width: 2px;
|
||||
}
|
||||
.border-l-8 {
|
||||
border-left-width: 8px;
|
||||
}
|
||||
.border-solid {
|
||||
border-style: solid;
|
||||
}
|
||||
@@ -1504,6 +1516,9 @@ video {
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
.text-justify {
|
||||
text-align: justify;
|
||||
}
|
||||
.text-end {
|
||||
text-align: end;
|
||||
}
|
||||
@@ -1934,6 +1949,11 @@ body {
|
||||
color: rgb(24 25 28 / var(--tw-text-opacity));
|
||||
}
|
||||
|
||||
.hover\:text-blue-300:hover {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(147 197 253 / var(--tw-text-opacity));
|
||||
}
|
||||
|
||||
.hover\:no-underline:hover {
|
||||
-webkit-text-decoration-line: none;
|
||||
text-decoration-line: none;
|
||||
@@ -2223,14 +2243,14 @@ body {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.lg\:w-1\/4 {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.lg\:w-2\/3 {
|
||||
width: 66.666667%;
|
||||
}
|
||||
|
||||
.lg\:w-1\/4 {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.lg\:flex-grow {
|
||||
flex-grow: 1;
|
||||
}
|
||||
@@ -2242,10 +2262,6 @@ body {
|
||||
.lg\:items-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.lg\:p-10 {
|
||||
padding: 2.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -47,6 +47,7 @@ router.post('/add', async function (req, res) {
|
||||
req.session.error = "You do not have admin permissions";
|
||||
return res.redirect('/');
|
||||
}
|
||||
var invite = null;
|
||||
if (req.body.create) {
|
||||
var channel = await checkServer.channels.cache.filter(channel => channel.type === Discord.ChannelType.GuildText)
|
||||
.first();
|
||||
@@ -54,15 +55,13 @@ router.post('/add', async function (req, res) {
|
||||
req.session.error = "Could not create invite";
|
||||
return res.redirect('/');
|
||||
} else {
|
||||
channel.createInvite({
|
||||
var invite = await channel.createInvite({
|
||||
maxAge: 0,
|
||||
maxUses: 0,
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
req.session.error = "Could not create invite";
|
||||
return res.redirect('/');
|
||||
}).then(invite => {
|
||||
req.body.server_invite = invite.url
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -75,7 +74,7 @@ router.post('/add', async function (req, res) {
|
||||
icon: checkServer.iconURL({ format: 'png', dynamic: true }),
|
||||
memberCount: checkServer.memberCount,
|
||||
tags: req.body.tags,
|
||||
invite: req.body.server_invite,
|
||||
invite: req.body.server_invite || invite.url,
|
||||
token: makeid(64),
|
||||
})
|
||||
var tagss = Array.from(new Set(req.body.tags));
|
||||
@@ -118,8 +117,8 @@ router.post('/add', async function (req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/:server', function (req, res) {
|
||||
servers.findOne({ id: req.params.server }, function (err, server) {
|
||||
router.get('/:server', async function (req, res) {
|
||||
servers.findOne({ id: req.params.server }, async function (err, server) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return res.redirect('/');
|
||||
@@ -128,6 +127,38 @@ router.get('/:server', function (req, res) {
|
||||
req.session.error = "No server found";
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
let referresURL = String(req.headers.referer).replace("undefined", "Unkown").split('.').join(',');
|
||||
await servers.updateOne({
|
||||
id: req.params.server
|
||||
}, {
|
||||
$inc: {
|
||||
analytics_visitors: 1
|
||||
}
|
||||
})
|
||||
var getIP = require('ipware')().get_ip;
|
||||
var ipInfo = getIP(req);
|
||||
var geoip = require('geoip-lite');
|
||||
var ip = ipInfo.clientIp;
|
||||
var geo = geoip.lookup(ip);
|
||||
|
||||
if (geo) {
|
||||
let CountryCode = geo.country || "TR"
|
||||
await servers.updateOne({
|
||||
id: req.params.server
|
||||
}, {
|
||||
$inc: {
|
||||
[`country.${CountryCode}`]: 1
|
||||
}
|
||||
})
|
||||
}
|
||||
await servers.updateOne({
|
||||
id: req.params.server
|
||||
}, {
|
||||
$inc: {
|
||||
[`analytics.${referresURL}`]: 1
|
||||
}
|
||||
})
|
||||
res.render('server/index', {
|
||||
user: req.user,
|
||||
server: server,
|
||||
@@ -267,7 +298,7 @@ router.get('/:server/vote', function (req, res) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
const embed = new Discord.Embeserversuilder()
|
||||
.setColor('#0099ff')
|
||||
.setTitle(`${req.user.username} has voted for ${bot.name}`)
|
||||
.setDescription(`[${bot.name}](${bot.url})`)
|
||||
@@ -314,7 +345,7 @@ router.get('/:server/vote', function (req, res) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
const embed = new Discord.Embeserversuilder()
|
||||
.setColor('#0099ff')
|
||||
.setTitle(`${req.user.username} has voted for ${bot.name}`)
|
||||
.setDescription(`[${bot.name}](${bot.url})`)
|
||||
@@ -334,4 +365,45 @@ router.get('/:server/vote', function (req, res) {
|
||||
}
|
||||
})
|
||||
|
||||
router.get('/:server/join', async function (req, res) {
|
||||
servers.findOne({ id: req.params.server }, async function (err, server) {
|
||||
await servers.updateOne({
|
||||
id: req.params.guildID
|
||||
}, {
|
||||
$inc: {
|
||||
analytics_joins: 1
|
||||
}
|
||||
}
|
||||
)
|
||||
let urlInvite = server.invite;
|
||||
res.render('server/join', {
|
||||
url: urlInvite,
|
||||
server: server
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
router.get('/:botID/analytics', async function (req, res) {
|
||||
if (!req.user) {
|
||||
req.session.backURL = req.originalUrl;
|
||||
return res.redirect('/auth');
|
||||
} else {
|
||||
bots.findOne({ id: req.params.botID }, async function (err, bot) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return res.redirect('/');
|
||||
}
|
||||
if (!bot) {
|
||||
req.session.error = "No bot found";
|
||||
return res.redirect('/');
|
||||
}
|
||||
res.render('bot/analytics', {
|
||||
bot: bot,
|
||||
user: req.user,
|
||||
bota: await global.bsl.users.fetch(bot.id)
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
module.exports = router;
|
||||
@@ -14,12 +14,12 @@ router.get('/me', async function (req, res) {
|
||||
return res.redirect('/auth');
|
||||
}
|
||||
var bot = await bots.find({ owners: req.user.id });
|
||||
var user = await users.find({ id: req.user.id });
|
||||
res.render('user/me', {
|
||||
var user = await users.findOne({ id: req.user.id });
|
||||
res.render('user/index', {
|
||||
user: req.user,
|
||||
bots: bot,
|
||||
users: user,
|
||||
dcuser: global.bsl.users.fetch(req.user.id)
|
||||
dcuser: await global.bsl.users.fetch(req.user.id)
|
||||
|
||||
});
|
||||
})
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
<option value="roleplay">Roleplay</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="relative z-0 mb-6 w-full group">
|
||||
<label for="tos" class="ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">Be adding a server you automatically to our <a href="/tos" target="_blank" class="text-blue-700 hover:text-blue-300">Terms of Service</a></label>\
|
||||
</div>
|
||||
<button type="submit" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -55,8 +55,8 @@
|
||||
<div class="mt-2 font-italic">
|
||||
<h3 style="color: #5f79da" class="text-uppercase">Referrers</h3>
|
||||
<p style="color: rgb(126, 126, 126)">The domain names of the sites that most redirect to your bot's page.</p>
|
||||
</div>
|
||||
<table id="analytics_referring" class="table table-hover" style="width:100%; color: #fff">
|
||||
</div><br>
|
||||
<table id="analytics_referring" class="w-full text-sm text-left text-gray-500 dark:text-gray-400 table" style="width:100%; color: #fff">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Referring Url</th>
|
||||
@@ -78,21 +78,20 @@
|
||||
<div class="mt-2 font-italic">
|
||||
<h3 style="color: #5f79da" class="text-uppercase">Countries</h3>
|
||||
<p style="color: rgb(126, 126, 126)">These are the countries that enter your bot's page.</p>
|
||||
</div>
|
||||
<table id="analytics_country" class="table table-hover" style="width:100%; color: #fff">
|
||||
<thead>
|
||||
</div><br>
|
||||
<table id="analytics_country" class="w-full text-sm text-left text-gray-500 dark:text-gray-400 table" style="width:100%; color: #fff">
|
||||
<thead class="text-xs uppercase text-white ">
|
||||
<tr>
|
||||
<th>Country</th>
|
||||
<th>Total viewers</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%
|
||||
if(bot.country) {
|
||||
Object.keys(bot.country).sort((a,b) => bot.country[b] - bot.country[a]).forEach(b => {
|
||||
%>
|
||||
<tr>
|
||||
<td translate="no"><span style="display: flex; align-items: center;"><img src="https://www.countryflags.io/<%= b %>/flat/32.png"> <%= b %></span></td>
|
||||
<td translate="no"><span style="display: flex; align-items: center;"><img src="https://countryflagsapi.com/png/<%= b %>" width="32px"> <%= b %></span></td>
|
||||
<td><span style="display: flex; align-items: center;"><%= bot.country[b] %></span></td>
|
||||
</tr>
|
||||
<%
|
||||
|
||||
@@ -51,6 +51,9 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<div class="relative z-0 mb-6 w-full group">
|
||||
<label for="tos" class="ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">Be adding a server you automatically to our <a href="/tos" target="_blank" class="text-blue-700 hover:text-blue-300">Terms of Service</a></label>\
|
||||
</div>
|
||||
<button type="submit" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,6 +1,11 @@
|
||||
<%- include("../includes/header.ejs", {title: "Edit " + server.name}) %>
|
||||
<!-- create form -->
|
||||
<div class="container-sm p-10">
|
||||
<a href="/server/<%= server.id %>/analytics" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
|
||||
<i class="fas fa-chart-bar"></i>
|
||||
<span>Analytics</span>
|
||||
</a>
|
||||
<br><br>
|
||||
<form method="post" action="">
|
||||
<div class="relative z-0 mb-6 w-full group">
|
||||
<textarea type="text" name="server_description" id="server_name" class="block py-2.5 px-0 w-full text-sm text-gray-900 bg-transparent border-0 border-b-2 border-gray-300 appearance-none dark:text-white dark:border-gray-600 dark:focus:border-blue-500 focus:outline-none focus:ring-0 focus:border-blue-600 peer" placeholder=" " required rows="5"><%= server.long_description %></textarea>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<%- include('../includes/header.ejs', {title: 'Join' + server.name}) %>
|
||||
<div class="flex flex-col items-center justify-center h-screen ">
|
||||
<div class="w-96 h-96 bg-blue-color text-white text-center rounded-lg items-center">
|
||||
<h1 class="text-3xl font-bold p-5">Join <%= server.name %></h1>
|
||||
<p>You will be redirect after 3 seconds </p>
|
||||
<div class="flex justify-center">
|
||||
<image src="/gif/loading.gif">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- script to redirect -->
|
||||
<script>
|
||||
setTimeout(function() {
|
||||
window.location.href = '<%= server.invite %>';
|
||||
}, 3000);
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<%- include('../includes/footer.ejs') %>
|
||||
File renamed without changes.
@@ -0,0 +1,59 @@
|
||||
<%- include('../includes/header.ejs', {title: 'User' + dcuser.username}) %>
|
||||
<br><br><br><br>
|
||||
<div class="lg:flex space-x-4 py-2 lg:h-5/6 sm:min-h-min">
|
||||
<div class="p-10 bg-blue-color w-full text-white h-full m-4 lg:mx-14 text-ellipsis lg:w-2/3">
|
||||
<p class="text-white text-clip">
|
||||
<pre style="white-space: pre-wrap;" class="text-clip break-wordsw-full h-full"><br><%= users.biography || "User Has No biography" %></pre>
|
||||
</p>
|
||||
</div>
|
||||
<div class="bg-blue-color w-full p-10 text-white h-full lg:w-1/4 lg:m-4">
|
||||
<img class="w-full rounded-full max-w-xs" src="https://cdn.discordapp.com/avatars/<%=dcuser.id %>/<%=dcuser.avatar %>.png" alt="<%= dcuser.name %>" onerror="this.src='/img/logo.png'">
|
||||
<h1 class="text-3xl">
|
||||
<%= dcuser.tag %>
|
||||
</h1>
|
||||
<!-- edit button -->
|
||||
<!-- fontawome icon -->
|
||||
<div class="flex">
|
||||
<a href="/user/edit" class="text-white text-sm">
|
||||
<i class="fa fa-edit"></i> Edit
|
||||
</a>
|
||||
</div>
|
||||
<% if(typeof users.website != "undefined") { %>
|
||||
<a href="<%= users.website %>" target="_blank" class="text-white text-clip">
|
||||
<i class="fab fa-website"></i>
|
||||
<%= users.website %>
|
||||
<br>
|
||||
</a>
|
||||
<% } %>
|
||||
<% if(typeof users.twitter != "undefined" ) { %>
|
||||
<a href="https://twitter.com/<%= users.twitter %>" target="_blank" class="text-white text-clip">
|
||||
<i class="fab fa-facebook"></i>
|
||||
<%= users.twitter %>
|
||||
<br>
|
||||
</a>
|
||||
<% } %>
|
||||
<% if(typeof users.instagram != "undefined") { %>
|
||||
<a href="https://instagram.com/<%= users.instagram %>" target="_blank" class="text-white text-clip">
|
||||
<i class="fab fa-instagram"></i>
|
||||
<%= users.instagram %>
|
||||
<br>
|
||||
</a>
|
||||
<% } %>
|
||||
<% if(typeof users.facebook != "undefined") { %>
|
||||
<a href="https://facebook.com/<%= users.facebook %>" target="_blank" class="text-white text-clip">
|
||||
<i class="fab fa-facebook"></i>
|
||||
<%= users.facebook %>
|
||||
<br>
|
||||
</a>
|
||||
<% } %>
|
||||
<% if(typeof users.github != "undefined") { %>
|
||||
<a href="https://youtube.com/<%= users.github %>" target="_blank" class="text-white text-clip">
|
||||
<i class="fab fa-github"></i>
|
||||
<%= users.github %>
|
||||
<br>
|
||||
</a>
|
||||
<% } %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br><br><br>
|
||||
@@ -1 +0,0 @@
|
||||
<%- include('../../includes/header.ejs', {title: 'User' + user.username}) %>
|
||||
Reference in new issue
Block a user