Added co-owners and owner to bot

This commit is contained in:
CorwinDev committed 2022-08-19 10:45:28 +02:00
1 parent 078cb26e35
commit 8e37fd23f1
5 files changed
+39 -25

No files matched your search

+19 -18
View File
@@ -90,16 +90,17 @@ router.post('/bot/:d/:f', async function (req, res) {
res.redirect('/admin');
}
if (req.params.f == 'reject') {
bot.owners.forEach(async function (owner) {
global.client.users.fetch(owner).then(async function (user) {
try {
user.send(`Your bot ${bot.name} has been rejected by the admin. With the reason: ${req.body.reason}`);
global.client.channels.cache.get(global.config.bot.channels.new).send(`${bot.name} has been rejected by the admin. With the reason: ${req.body.reason}`);
}
catch (e) {
}
})
global.client.users.fetch(bot.owner).then(async function (user) {
try {
user.send(`<@${owner}> bot ${bot.name} has been rejected by the admin. With the reason: ${req.body.reason}`);
}
catch (e) {
}
global.client.channels.cache.get(global.config.bot.channels.new).send(`<@${owner}> bot ${bot.name} has been rejected by the admin. With the reason: ${req.body.reason}`);
})
var rem = await bots.findOneAndDelete({ id: req.params.d })
if (rem) {
res.redirect('/admin');
@@ -110,16 +111,16 @@ router.post('/bot/:d/:f', async function (req, res) {
} else if (req.params.f == 'verify') {
bot.verified = true;
bot.save();
bot.owners.forEach(async function (owner) {
global.client.users.fetch(owner).then(async function (user) {
try {
user.send(`Your bot ${bot.name} has been accepted by the admin.`);
global.client.channels.cache.get(global.config.bot.channels.new).send(`${bot.name} has been accepted by the admin. View it at: https://botscord.xyz/bot/${bot.id}`);
}
catch (e) {
}
})
global.client.users.fetch(bot.owner).then(async function (user) {
try {
user.send(`<@${owner}> bot ${bot.name} has been accepted by the admin.`);
}
catch (e) {
}
global.client.channels.cache.get(global.config.bot.channels.new).send(`<@${owner}> bot ${bot.name} has been accepted by the admin. View it at: https://botscord.xyz/bot/${bot.id}`);
})
res.redirect('/admin');
}
} else {
+13 -5
View File
@@ -49,13 +49,13 @@ router.post('/add', async function (req, res) {
req.body.bot_owners.split(',').forEach(function (owner) {
owners.push(owner.trim());
})
owners.push(req.user.id);
var bot = new bots({
id: req.body.bot_id,
name: req.body.bot_name,
verified: false,
long_description: req.body.bot_description,
owners: owners,
owner: req.user.id,
coowners: owners,
description: req.body.bot_short,
tags: req.body.tags,
token: makeid(64),
@@ -94,7 +94,7 @@ router.get('/:botID', async function (req, res) {
req.backURL = req.originalUrl;
return res.redirect('/auth');
}
if (bot.owners.includes(req.user.id)) {
if (bot.owners.includes(req.user.id) || global.config.users.verificator.includes(req.user.id) || global.config.users.owner.includes(req.user.id)) {
let coowner = new Array()
await bot.owners.forEach(async function (a) {
try {
@@ -274,11 +274,15 @@ router.post('/:botID/settings', async function (req, res) {
req.session.error = "This vanity is already in use";
return res.redirect('/');
} else {
var owners = new Array();
req.body.bot_owners.split(',').forEach(function (owner) {
owners.push(owner.trim());
})
bot.name = req.body.bot_name;
bot.description = req.body.bot_short;
bot.long_description = req.body.bot_description;
bot.vanity = req.body.bot_vanity.toLowerCase();
bot.owners = owners;
bot.save(function (err) {
if (err) {
console.log(err);
@@ -300,11 +304,15 @@ router.post('/:botID/settings', async function (req, res) {
req.session.error = "This vanity is already in use";
return res.redirect('/');
} else {
var owners = new Array();
req.body.bot_owners.split(',').forEach(function (owner) {
owners.push(owner.trim());
})
bot.name = req.body.bot_name;
bot.description = req.body.bot_short;
bot.long_description = req.body.bot_description;
bot.vanity = req.body.bot_vanity.toLowerCase();
bot.owners = owners;
bot.save(function (err) {
if (err) {
console.log(err);