Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
clqu authored Jul 9, 2021
1 parent e00f08a commit 84c5839
Show file tree
Hide file tree
Showing 42 changed files with 2,360 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/routers/admin/ban.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const app = require('express').Router();
const banSchema = require("../../database/models/site-ban.js");
const channels = global.config.server.channels,
roles = global.config.server.roles;

console.log("[vcodes.xyz]: Admin/Ban router loaded.");

app.get("/admin/userban", global.checkAuth, async (req, res) => {
if (!config.bot.owners.includes(req.user.id)) return res.redirect('../admin');
let bandata = await banSchema.find();
res.render("admin/administrator/user-ban.ejs", {
bot: global.Client,
path: req.path,
config: global.config,
user: req.isAuthenticated() ? req.user : null,
req: req,
roles:global.config.server.roles,
channels: global.config.server.channels,
bandata: bandata
})
});
app.post("/admin/userban", global.checkAuth, async (req, res) => {
if (!config.bot.owners.includes(req.user.id)) return res.redirect('../admin');
new banSchema({
user: req.body.userID,
sebep: req.body.reason,
yetkili: req.user.id
}).save()
return res.redirect('../admin/userban?success=true&message=User banned.');
});
app.post("/admin/userunban", global.checkAuth, async (req, res) => {
if (!config.bot.owners.includes(req.user.id)) return res.redirect('../admin');
banSchema.deleteOne({
user: req.body.userID
}, function(error, user) {
if (error) console.log(error)
})
return res.redirect('../admin/userban?success=true&message=User ban removed.');
});

module.exports = app;
35 changes: 35 additions & 0 deletions src/routers/admin/botlist/certificate/decline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const app = require('express').Router();
const botsdata = require("../../../../database/models/botlist/bots.js");
const codesSchema = require("../../../../database/models/codes.js");
const uptimedata = require("../../../../database/models/uptime.js");
const appsdata = require("../../../../database/models/botlist/certificate-apps.js");
let sitedatalari = require("../../../../database/models/analytics-site.js");

console.log("[vcodes.xyz]: Admin/Botlist/Certificate Decline router loaded.");

app.post("/admin/certificate/delete/:botID", global.checkAuth, async (req, res) => {
let rBody = req.body;
await botsdata.findOneAndUpdate({
botID: req.params.botID
}, {
$set: {
certificate: "None",
}
}, function(err, docs) {})
let botdata = await botsdata.findOne({
botID: req.params.botID
});
client.users.fetch(botdata.botID).then(bota => {
client.channels.cache.get(channels.botlog).send(`<@${botdata.ownerID}>'s bot named **${bota.tag}** has not been granted a certificate.`)
client.users.cache.get(botdata.ownerID).send(`Your bot named **${bota.tag}** certificate application has been declined.\nReason: **${rBody['reason']}**`)
});
await appsdata.deleteOne({
botID: req.params.botID
})
let guild = client.guilds.cache.get(config.server.id)
guild.members.cache.get(botdata.botID).roles.remove(roles.botlist.certified_bot);
guild.members.cache.get(botdata.ownerID).roles.remove(roles.botlist.certified_developer);
return res.redirect(`/admin/certificate-apps?success=true&message=Certificate deleted.`)
});

module.exports = app;
42 changes: 42 additions & 0 deletions src/routers/admin/botlist/certificate/give.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const app = require('express').Router();
const botsdata = require("../../../../database/models/botlist/bots.js");
const codesSchema = require("../../../../database/models/codes.js");
const uptimedata = require("../../../../database/models/uptime.js");
const appsdata = require("../../../../database/models/botlist/certificate-apps.js");
let sitedatalari = require("../../../../database/models/analytics-site.js");

console.log("[vcodes.xyz]: Admin/Botlist/Certificate Give router loaded.");

app.get("/admin/certificate/give/:botID", global.checkAuth, async (req, res) => {
await botsdata.findOneAndUpdate({
botID: req.params.botID
}, {
$set: {
certificate: "Certified",
}
}, function(err, docs) {})
let botdata = await botsdata.findOne({
botID: req.params.botID
});

client.users.fetch(botdata.botID).then(bota => {
client.channels.cache.get(channels.botlog).send(`<@${botdata.ownerID}>'s bot named **${bota.tag}** has been granted a certificate.`)
client.users.cache.get(botdata.ownerID).send(`Your bot named **${bota.tag}** has been certified.`)
});
await appsdata.deleteOne({
botID: req.params.botID
})
let guild = client.guilds.cache.get(config.server.id)
guild.members.cache.get(botdata.botID).roles.add(roles.botlist.certified_bot);
guild.members.cache.get(botdata.ownerID).roles.add(roles.botlist.certified_developer);
if (botdata.coowners) {
botdata.coowners.map(a => {
if (guild.members.cache.get(a)) {
guild.members.cache.get(a).roles.add(roles.botlist.certified_developer);
}
})
}
return res.redirect(`/admin/certificate-apps?success=true&message=Certificate gived.&botID=${req.params.botID}`)
});

module.exports = app;
42 changes: 42 additions & 0 deletions src/routers/admin/botlist/confirm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const app = require('express').Router();
const botsdata = require("../../../database/models/botlist/bots.js");
const codesSchema = require("../../../database/models/codes.js");
const uptimedata = require("../../../database/models/uptime.js");
const appsdata = require("../../../database/models/botlist/certificate-apps.js");
let sitedatalari = require("../../../database/models/analytics-site.js");

const roles = global.config.server.roles;
const channels = global.config.server.channels;
const client = global.Client;

console.log("[vcodes.xyz]: Admin/Botlist/Confirm Bot router loaded.");

app.get("/admin/confirm/:botID", global.checkAuth, async (req, res) => {
const botdata = await botsdata.findOne({
botID: req.params.botID
})
if (!botdata) return res.redirect("/error?code=404&message=You entered an invalid bot id.");
await botsdata.findOneAndUpdate({
botID: req.params.botID
}, {
$set: {
status: "Approved",
Date: Date.now(),
}
}, function(err, docs) {})
client.users.fetch(req.params.botID).then(bota => {
client.channels.cache.get(channels.botlog).send(`<@${botdata.ownerID}>'s bot named **${bota.tag}** has been approved. `)
client.users.cache.get(botdata.ownerID).send(`Your bot named **${bota.tag}** has been approved.`)
});
let guild = client.guilds.cache.get(config.server.id)
guild.members.cache.get(botdata.botID).roles.add(roles.botlist.bot);
guild.members.cache.get(botdata.ownerID).roles.add(roles.botlist.developer);
if (botdata.coowners) {
botdata.coowners.map(a => {
guild.members.cache.get(a).roles.add(roles.botlist.developer);
})
}
return res.redirect(`/admin/unapproved?success=true&message=Bot approved.`)
});

module.exports = app;
30 changes: 30 additions & 0 deletions src/routers/admin/botlist/decline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const app = require('express').Router();
const botsdata = require("../../../database/models/botlist/bots.js");
const codesSchema = require("../../../database/models/codes.js");
const uptimedata = require("../../../database/models/uptime.js");
const appsdata = require("../../../database/models/botlist/certificate-apps.js");
let sitedatalari = require("../../../database/models/analytics-site.js");

const roles = global.config.server.roles;
const channels = global.config.server.channels;
const client = global.Client;

console.log("[vcodes.xyz]: Admin/Botlist/Decline Bot router loaded.");

app.post("/admin/decline/:botID", global.checkAuth, async (req, res) => {
let rBody = req.body;
let botdata = await botsdata.findOne({
botID: req.params.botID
});
client.users.fetch(botdata.ownerID).then(sahip => {
client.channels.cache.get(channels.botlog).send(`<@${botdata.ownerID}>'s bot named **${botdata.username}** has been declined. `)
client.users.cache.get(botdata.ownerID).send(`Your bot named **${botdata.username}** has been declined.\nReason: **${rBody['reason']}**\nAuthorized: **${req.user.username}**`)
})
await botsdata.deleteOne({
botID: req.params.botID,
ownerID: botdata.ownerID
})
return res.redirect(`/admin/unapproved?success=true&message=Bot declined.`)
});

module.exports = app;
30 changes: 30 additions & 0 deletions src/routers/admin/botlist/delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const app = require('express').Router();
const botsdata = require("../../../database/models/botlist/bots.js");
const codesSchema = require("../../../database/models/codes.js");
const uptimedata = require("../../../database/models/uptime.js");
const appsdata = require("../../../database/models/botlist/certificate-apps.js");
let sitedatalari = require("../../../database/models/analytics-site.js");


const roles = global.config.server.roles;
const channels = global.config.server.channels;
const client = global.Client;

console.log("[vcodes.xyz]: Admin/Botlist/Delete Bot router loaded.");

app.get("/admin/delete/:botID", global.checkAuth, async (req, res) => {
const botdata = await botsdata.findOne({
botID: req.params.botID
})
if (!botdata) return res.redirect("/error?code=404&message=You entered an invalid bot id.");
let guild = client.guilds.cache.get(config.server.id)
guild.members.cache.get(botdata.botID).roles.remove(roles.bot);
await guild.members.cache.get(botdata.botID).kick();
await botsdata.deleteOne({
botID: req.params.botID,
ownerID: botdata.ownerID
})
return res.redirect(`/admin/approved?success=true&message=Bot deleted.`)
});

module.exports = app;
46 changes: 46 additions & 0 deletions src/routers/admin/codeshare/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const app = require('express').Router();
const codesSchema = require("../../../database/models/codes.js");
const client = global.Client;
const channels = global.config.server.channels,
roles = global.config.server.roles;

console.log("[vcodes.xyz]: Admin/CodeShare/Add router loaded.");

app.post("/admin/addcode", global.checkAuth, async (req, res) => {
const rBody = req.body;
let kod = makeid(36);
await new codesSchema({
code: kod,
codeName: rBody['codename'],
codeCategory: rBody['category'],
codeDesc: rBody['codedesc'],
}).save()
if (rBody['main']) {
await codesSchema.updateOne({
code: kod
}, {
$set: {
main: req.body.main
}
});
}
if (rBody['commands']) {
await codesSchema.updateOne({
code: kod
}, {
$set: {
commands: req.body.commands
}
});
}
client.channels.cache.get(channels.codelog).send(new Discord.MessageEmbed()
.setTitle("New code added!").setColor("GREEN").setFooter(config.footer)
.setDescription(`The user named **[${req.user.username}](https://vcodes.xyz/user/${req.user.id})** added the code named **${rBody['codename']}** to the system.`)
.addField("Code Link", `https://vcodes.xyz/code/${kod}`, true)
.addField("Code Description", rBody['codedesc'], true)
.addField("Code Category", rBody['category'], true)
)
res.redirect('/code/' + kod)
});

module.exports = app;
33 changes: 33 additions & 0 deletions src/routers/admin/codeshare/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const app = require('express').Router();
const codesSchema = require("../../../database/models/codes.js");
const client = global.Client;
const channels = global.config.server.channels,
roles = global.config.server.roles;

console.log("[vcodes.xyz]: Admin/CodeShare/Edit router loaded.");

app.post("/admin/editcode/:code", global.checkAuth, async (req, res) => {
const rBody = req.body;
let kod = req.params.code;
await codesSchema.findOneAndUpdate({
code: kod
}, {
$set: {
codeName: rBody['codename'],
codeCategory: rBody['category'],
codeDesc: rBody['codedesc'],
main: rBody['main'],
commands: rBody['commands'],
}
}, function(err, docs) {})
client.channels.cache.get(channels.codelog).send(new Discord.MessageEmbed()
.setTitle("Code edited!").setColor("GREEN").setFooter(config.footer)
.setDescription(`The user named **[${req.user.username}](https://vcodes.xyz/user/${req.user.id})** edited the code named **${rBody['codename']}**.`)
.addField("Code Link", `https://vcodes.xyz/code/${kod}`, true)
.addField("Code Description", rBody['codedesc'], true)
.addField("Code Category", rBody['category'], true)
)
res.redirect('/code/' + kod)
});

module.exports = app;
57 changes: 57 additions & 0 deletions src/routers/admin/codeshare/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const app = require('express').Router();
const codesSchema = require("../../../database/models/codes.js");
const client = global.Client;
const channels = global.config.server.channels,
roles = global.config.server.roles;

console.log("[vcodes.xyz]: Admin/CodeShare/Index router loaded.");

app.get("/admin/codes", global.checkAuth, async (req, res) => {
let koddata = await codesSchema.find();
res.render("admin/codes.ejs", {
bot: global.Client,
path: req.path,
config: global.config,
user: req.isAuthenticated() ? req.user : null,
req: req,
roles:global.config.server.roles,
channels: global.config.server.channels,
koddata: koddata,
})
});
app.get("/admin/addcode", global.checkAuth, async (req, res) => {
res.render("admin/addcode.ejs", {
bot: global.Client,
path: req.path,
config: global.config,
user: req.isAuthenticated() ? req.user : null,
req: req,
roles:global.config.server.roles,
channels: global.config.server.channels
})
});
app.get("/admin/editcode/:code", global.checkAuth, async (req, res) => {
let kod = req.params.code;
let koddata = await codesSchema.findOne({
code: kod
})
if (!koddata) return res.redirect('/codes?error=true&message=You entered an invalid code.')
res.render("admin/editcode.ejs", {
bot: global.Client,
path: req.path,
config: global.config,
user: req.isAuthenticated() ? req.user : null,
req: req,
roles:global.config.server.roles,
channels: global.config.server.channels,
koddata: koddata,
})
});
app.get("/admin/deletecode/:code", global.checkAuth, async (req, res) => {
await codesSchema.deleteOne({
code: req.params.code
})
return res.redirect('/admin/codes?success=true&message=Code deleted.');
});

module.exports = app;
Loading

0 comments on commit 84c5839

Please sign in to comment.