diff --git a/models/bot.js b/models/bot.js index ce2a9bf..c04fc30 100644 --- a/models/bot.js +++ b/models/bot.js @@ -7,6 +7,7 @@ let hm = new mongoose.Schema({ description: { type: String, maxLength: 100 }, + owner: String, owners: [String], long_description: String, banner: String, diff --git a/website/routers/admin/index.js b/website/routers/admin/index.js index 0b00495..ef8bc33 100644 --- a/website/routers/admin/index.js +++ b/website/routers/admin/index.js @@ -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 { diff --git a/website/routers/bot/index.js b/website/routers/bot/index.js index 87bb4ba..fe223b7 100644 --- a/website/routers/bot/index.js +++ b/website/routers/bot/index.js @@ -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); diff --git a/website/views/bot/add.ejs b/website/views/bot/add.ejs index a915800..1a1515f 100644 --- a/website/views/bot/add.ejs +++ b/website/views/bot/add.ejs @@ -22,8 +22,8 @@
- - + +
diff --git a/website/views/bot/edit.ejs b/website/views/bot/edit.ejs index 38cc29a..b4440d0 100644 --- a/website/views/bot/edit.ejs +++ b/website/views/bot/edit.ejs @@ -17,6 +17,10 @@
+
+ + +