Added co-owners and owner to bot
This commit is contained in:
1 parent
078cb26e35
commit
8e37fd23f1
5 files changed
+39
-25
No files matched your search
@@ -7,6 +7,7 @@ let hm = new mongoose.Schema({
|
||||
description: {
|
||||
type: String, maxLength: 100
|
||||
},
|
||||
owner: String,
|
||||
owners: [String],
|
||||
long_description: String,
|
||||
banner: String,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
<label for="bot_name" class="peer-focus:font-medium absolute text-sm text-white duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-focus:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6">Short Description (Will be show on home page, MaxLength: 100)</label>
|
||||
</div>
|
||||
<div class="relative z-0 mb-6 w-full group">
|
||||
<input type="text" name="bot_owners" id="floating_last_name" class="block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 appearance-none text-white border-gray-600 focus:outline-none focus:ring-0 focus:border-blue-600 peer" placeholder=" " required />
|
||||
<label for="bot_name" class="peer-focus:font-medium absolute text-sm text-white duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6">Owners (split with <strong>,</strong> ) (You are automatic included!)</label>
|
||||
<input type="text" name="bot_owners" id="floating_last_name" class="block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 appearance-none text-white border-gray-600 focus:outline-none focus:ring-0 focus:border-blue-600 peer" placeholder=" " />
|
||||
<label for="bot_name" class="peer-focus:font-medium absolute text-sm text-white duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6">Co-Owners (split with <strong>,</strong> )</label>
|
||||
</div>
|
||||
<div class="relative z-0 mb-6 w-full group">
|
||||
<input type="text" name="bot_invite" id="floating_last_name" class="block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 appearance-none text-white border-gray-600 focus:outline-none focus:ring-0 focus:border-blue-600 peer" placeholder=" " required />
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
<label for="bot_name" class="peer-focus:font-medium absolute text-sm text-white dark:text-white duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6">Short
|
||||
Description (Will be show on home page)</label>
|
||||
</div>
|
||||
<div class="relative z-0 mb-6 w-full group">
|
||||
<input type="text" name="bot_owners" id="floating_last_name" class="block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 appearance-none text-white border-gray-600 focus:outline-none focus:ring-0 focus:border-blue-600 peer" placeholder=" " />
|
||||
<label for="bot_name" class="peer-focus:font-medium absolute text-sm text-white duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6">Co-Owners (split with <strong>,</strong> )</label>
|
||||
</div>
|
||||
<div class="relative z-0 mb-6 w-full group">
|
||||
<input type="text" name="bot_vanity" id="bot_vanity" class="block py-2.5 px-0 w-full text-sm text-white 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=" " value="<%= bot.vanity %>" />
|
||||
<label for="bot_vanity" class="peer-focus:font-medium absolute text-sm text-white dark:text-white duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6">Fill this in to get a vanity url invite.</label>
|
||||
|
||||
Reference in new issue
Block a user