Added rate-limit, tos, cleaned code up
This commit is contained in:
1 parent
773872a043
commit
87aec4fa1e
11 files changed
+152
-81
No files matched your search
+30
-18
@@ -83,12 +83,15 @@ client.on("guildMemberAdd", async (member) => {
|
||||
if (member.user.bot) {
|
||||
try {
|
||||
guild.member(member.id).roles.add(config.server.roles.botlist.bot);
|
||||
client.channels.cache.get(config.server.channels.new).send(`${member.user.tag} has joined the server!`);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
guild.member(member.id).roles.add(config.server.roles.botlist.user);
|
||||
client.channels.cache.get(config.server.channels.new).send(`${member.user.tag} has joined the server!`);
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
@@ -96,25 +99,34 @@ client.on("guildMemberAdd", async (member) => {
|
||||
});
|
||||
var cooldown = [];
|
||||
client.on("messageCreate", async (message) => {
|
||||
console.log(cooldown
|
||||
)
|
||||
if (message.author.bot) return;
|
||||
if (message.channel.type === "dm") return;
|
||||
// cooldown function
|
||||
if (cooldown.includes(message.author.id)) return;
|
||||
cooldown.push(message.author.id);
|
||||
const coins = await users.findOne({ id: message.author.id });
|
||||
if (!coins) {
|
||||
await users.create({ id: message.author.id, coins: 0 });
|
||||
} else {
|
||||
if (coins.coins < 1) {
|
||||
coins.coins = 1;
|
||||
coins.save();
|
||||
} else {
|
||||
coins.coins++;
|
||||
coins.save();
|
||||
if (cooldown.some(code => code.id === message.author.id)){
|
||||
var userr = cooldown.findIndex((obj => obj.id == message.author.id));
|
||||
cooldown[userr].message += 1;
|
||||
if (cooldown[userr].message >= 15) {
|
||||
cooldown[userr].message = 0;
|
||||
const coins = await users.findOne({ id: message.author.id });
|
||||
if (!coins) {
|
||||
await users.create({ id: message.author.id, coins: 0 });
|
||||
} else {
|
||||
if (coins.coins < 1) {
|
||||
coins.coins = 1;
|
||||
coins.save();
|
||||
} else {
|
||||
coins.coins++;
|
||||
coins.save();
|
||||
}
|
||||
message.reply(`You earned 1 coin! You now have ${coins.coins} coins!`);
|
||||
}
|
||||
}
|
||||
message.reply(`You have ${coins.coins} coins!`);
|
||||
setTimeout(() => {
|
||||
cooldown.splice(cooldown.indexOf(message.author.id), 1);
|
||||
}, 1200000);
|
||||
}
|
||||
return
|
||||
};
|
||||
cooldown.push({
|
||||
id: message.author.id,
|
||||
message: 0,
|
||||
});
|
||||
|
||||
});
|
||||
+18
-4
@@ -15,7 +15,9 @@ var admin = require('./routers/admin');
|
||||
var auth = require('./routers/auth');
|
||||
var servers = require('./routers/servers');
|
||||
var api = require('./routers/api');
|
||||
var profile = require('./routers/user');
|
||||
var client = require('../index');
|
||||
|
||||
const port = client.config.server.port || 3000;
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', path.join(__dirname, '/views'));
|
||||
@@ -54,8 +56,8 @@ const server = require('../models/server');
|
||||
var scopes = ['identify', 'guilds', 'guilds.join'];
|
||||
var prompt = 'consent'
|
||||
passport.use(new DiscordStrategy({
|
||||
clientID: '934087523649609768',
|
||||
clientSecret: 'nPKjKvOCOyyhDaQM64qcJYbd6CdhCxLh',
|
||||
clientID: '870001234583621713',
|
||||
clientSecret: 'vnWBrTQwSPwjCz9bykN7QwxdliQSZYaC',
|
||||
callbackURL: client.config.server.host + '/auth/callback',
|
||||
scope: scopes,
|
||||
prompt: prompt
|
||||
@@ -94,6 +96,7 @@ app.use('/admin', admin);
|
||||
app.use('/auth', auth);
|
||||
app.use('/server', servers);
|
||||
app.use('/api', api);
|
||||
app.use('/user', profile)
|
||||
|
||||
// set up routes
|
||||
app.get('/', async (req, res) => {
|
||||
@@ -162,6 +165,11 @@ app.get('/tag/:id', async (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/tos' , (req, res) => {
|
||||
res.render('tos', {
|
||||
user: req.user,
|
||||
});
|
||||
} );
|
||||
app.get("/robots.txt", function (req, res) {
|
||||
res.set('Content-Type', 'text/plain');
|
||||
res.send(`Sitemap: https://botscord.xyz/sitemap.xml`);
|
||||
@@ -183,11 +191,17 @@ app.get('/invite', function (req, res) {
|
||||
res.redirect(client.config.bot.bsl.invite);
|
||||
});
|
||||
app.use((req, res, next) => {
|
||||
res.status(404).send("Sorry can't find that!")
|
||||
res.status(404).render('error', {
|
||||
errorr: "Page not found",
|
||||
user: req.user,
|
||||
})
|
||||
})
|
||||
app.use((err, req, res, next) => {
|
||||
console.error(err.stack)
|
||||
res.status(500).send('Something broke!')
|
||||
res.status(500).render('error',{
|
||||
errorr: 500,
|
||||
user: req.user,
|
||||
})
|
||||
})
|
||||
app.listen(client.config.server.port, () => {
|
||||
console.log(colors.green("Website: "), 'Your app is listening on port ' + port);
|
||||
|
||||
@@ -880,6 +880,15 @@ video {
|
||||
.w-0 {
|
||||
width: 0px;
|
||||
}
|
||||
.w-64 {
|
||||
width: 16rem;
|
||||
}
|
||||
.w-9 {
|
||||
width: 2.25rem;
|
||||
}
|
||||
.w-4 {
|
||||
width: 1rem;
|
||||
}
|
||||
.w-3\/6 {
|
||||
width: 50%;
|
||||
}
|
||||
@@ -889,18 +898,6 @@ video {
|
||||
.w-1\/4 {
|
||||
width: 25%;
|
||||
}
|
||||
.w-64 {
|
||||
width: 16rem;
|
||||
}
|
||||
.w-9\/12 {
|
||||
width: 75%;
|
||||
}
|
||||
.w-9 {
|
||||
width: 2.25rem;
|
||||
}
|
||||
.w-4 {
|
||||
width: 1rem;
|
||||
}
|
||||
.min-w-fit {
|
||||
min-width: -webkit-fit-content;
|
||||
min-width: -moz-fit-content;
|
||||
@@ -1072,6 +1069,9 @@ video {
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
.items-stretch {
|
||||
align-items: stretch;
|
||||
}
|
||||
.justify-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
@@ -1379,12 +1379,12 @@ video {
|
||||
.p-96 {
|
||||
padding: 24rem;
|
||||
}
|
||||
.p-2\.5 {
|
||||
padding: 0.625rem;
|
||||
}
|
||||
.p-3 {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
.p-2\.5 {
|
||||
padding: 0.625rem;
|
||||
}
|
||||
.px-3 {
|
||||
padding-left: 0.75rem;
|
||||
padding-right: 0.75rem;
|
||||
@@ -1623,6 +1623,14 @@ video {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(191 219 254 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-blue-color {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(24 25 28 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-button-primary {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(88 101 242 / var(--tw-text-opacity));
|
||||
}
|
||||
.underline {
|
||||
-webkit-text-decoration-line: underline;
|
||||
text-decoration-line: underline;
|
||||
@@ -1958,11 +1966,6 @@ body {
|
||||
--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity));
|
||||
}
|
||||
|
||||
.group:hover .group-hover\:text-gray-900 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(17 24 39 / var(--tw-text-opacity));
|
||||
}
|
||||
|
||||
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:translate-y-0 {
|
||||
--tw-translate-y: 0px;
|
||||
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
||||
@@ -2035,16 +2038,6 @@ body {
|
||||
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
|
||||
}
|
||||
|
||||
.dark\:bg-gray-800 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(31 41 55 / var(--tw-bg-opacity));
|
||||
}
|
||||
|
||||
.dark\:bg-blue-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(30 58 138 / var(--tw-bg-opacity));
|
||||
}
|
||||
|
||||
.dark\:text-primary-color {
|
||||
color: #1E2023;;
|
||||
}
|
||||
@@ -2064,11 +2057,6 @@ body {
|
||||
color: rgb(209 213 219 / var(--tw-text-opacity));
|
||||
}
|
||||
|
||||
.dark\:text-blue-200 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(191 219 254 / var(--tw-text-opacity));
|
||||
}
|
||||
|
||||
.dark\:placeholder-gray-400::-moz-placeholder {
|
||||
--tw-placeholder-opacity: 1;
|
||||
color: rgb(156 163 175 / var(--tw-placeholder-opacity));
|
||||
@@ -2098,11 +2086,6 @@ body {
|
||||
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
|
||||
}
|
||||
|
||||
.dark\:hover\:bg-gray-700:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(55 65 81 / var(--tw-bg-opacity));
|
||||
}
|
||||
|
||||
.dark\:hover\:text-white:hover {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(255 255 255 / var(--tw-text-opacity));
|
||||
@@ -2138,11 +2121,6 @@ body {
|
||||
--tw-ring-color: rgb(37 99 235 / var(--tw-ring-opacity));
|
||||
}
|
||||
|
||||
.group:hover .dark\:group-hover\:text-white {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(255 255 255 / var(--tw-text-opacity));
|
||||
}
|
||||
|
||||
.peer:focus ~ .peer-focus\:dark\:text-blue-500 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(59 130 246 / var(--tw-text-opacity));
|
||||
|
||||
@@ -32,7 +32,7 @@ router.post('/add', async function (req, res) {
|
||||
var checkbot = await bots.findOne({ id: req.body.id });
|
||||
if (checkbot) {
|
||||
req.session.error = "Bot already exists";
|
||||
res.redirect('/');
|
||||
res.redirect('/bot/add');
|
||||
return
|
||||
}
|
||||
var owners = new Array();
|
||||
@@ -55,12 +55,13 @@ router.post('/add', async function (req, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
req.session.error = "Something went wrong";
|
||||
res.redirect('/');
|
||||
res.redirect('/bot/add');
|
||||
} else {
|
||||
req.session.message = "Bot added";
|
||||
res.redirect('/');
|
||||
res.redirect('/bot/' + bot.id);
|
||||
}
|
||||
});
|
||||
client.client.client.channels.cache.get(client.client.config.bot.channels.admin).send(`<@${req.user.id}> has added a new bot: ${bot.name}, invite: https://discordapp.com/oauth2/authorize?client_id=${bot.id}&scope=bot&permissions=0 `);
|
||||
} else {
|
||||
req.session.backURL = req.originalUrl;
|
||||
res.redirect('/auth');
|
||||
@@ -79,11 +80,11 @@ router.get('/:botID', async function (req, res) {
|
||||
}
|
||||
let coowner = new Array()
|
||||
await bot.owners.forEach(async function (a) {
|
||||
try{
|
||||
var b = await global.bsl.users.fetch(a)
|
||||
}catch(e){
|
||||
try {
|
||||
var b = await global.bsl.users.fetch(a)
|
||||
} catch (e) {
|
||||
}
|
||||
if(!b) return;
|
||||
if (!b) return;
|
||||
coowner.push(b)
|
||||
})
|
||||
try {
|
||||
@@ -144,11 +145,11 @@ router.post('/:botID/settings', async function (req, res) {
|
||||
req.session.error = "No bot found";
|
||||
return res.redirect('/');
|
||||
}
|
||||
if(!bot.owners.includes(req.user.id)){
|
||||
|
||||
|
||||
req.session.error = "You do not have permission to edit this bot";
|
||||
return res.redirect('/');
|
||||
if (!bot.owners.includes(req.user.id)) {
|
||||
|
||||
|
||||
req.session.error = "You do not have permission to edit this bot";
|
||||
return res.redirect('/');
|
||||
}
|
||||
bot.name = req.body.bot_name;
|
||||
bot.description = req.body.bot_short;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
var express = require('express'),
|
||||
router = express.Router();
|
||||
var servers = require('../../../models/server');
|
||||
var votes = require('../../../models/votes');
|
||||
var bots = require('../../../models/bot');
|
||||
|
||||
router.get('/', function (req,res) {
|
||||
res.redirect('/user/me')
|
||||
})
|
||||
router.get('/me', async function (req, res) {
|
||||
if (req.user) {
|
||||
var bot = await bots.find({ owners: req.user.id });
|
||||
res.render('user/me', {
|
||||
user: req.user,
|
||||
bots: bot
|
||||
});
|
||||
return
|
||||
} else {
|
||||
req.session.backURL = req.originalUrl;
|
||||
res.redirect('/auth');
|
||||
}
|
||||
})
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,9 @@
|
||||
<%- include('./includes/header.ejs', {title: 'Error ' + errorr}) %>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-white p-10">
|
||||
<h1 class="text-xl">Oeps something went wrong</h1>
|
||||
<p>Error: <%= errorr %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,7 +61,7 @@
|
||||
</svg>
|
||||
</button>
|
||||
<div class="w-0 hidden lg:block flex-grow lg:items-center lg:w-auto content-center items-center" id="navbar-solid-bg">
|
||||
<div class="flex">
|
||||
<div class="lg:flex">
|
||||
<div class="text-sm lg:flex-grow">
|
||||
<a href="/bots" class="block lg:inline-block lg:mt-0 text-white hover:text-white mr-4 text-lg">
|
||||
<li class="fa fa-robot mr-1"></li>
|
||||
@@ -77,7 +77,7 @@
|
||||
</a>
|
||||
<div class="relative inline-block text-left">
|
||||
|
||||
<div class="hidden origin-top-right absolute mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 divide-y divide-gray-100 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1" id="dropdown" style="z-index: 99 !important;">
|
||||
<div class="hidden origin-top-right absolute mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 divide-y divide-gray-100 focus:outline-none items-stretch" role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1" id="dropdown" style="z-index: 99 !important;">
|
||||
<div class="py-1" role="none">
|
||||
<a href="/invite" class="text-gray-700 block px-4 py-2 text-sm" role="menuitem" tabindex="-1" id="menu-item-0"><i class="fas fa-user-plus"></i>Invite</a>
|
||||
<a href="/discord" class="text-gray-700 block px-4 py-2 text-sm" role="menuitem" tabindex="-1" id="menu-item-1"><i class="fa-brands fa-discord"></i>Discord Server</a>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<%- include('./includes/header.ejs', {title: 'Terms of Service'}) %>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-white p-10">
|
||||
<h1 class="text-xl">Terms of Service</h1>
|
||||
<p>Last updated: August 15, 2022</p>
|
||||
<p>Please read these Terms of Service ("Terms", "Terms of Service") carefully before using the <a href="https://botscord.xyz">BotsCord</a> website (the "Service") operated by BotsCord ("us", "we", or "our").</p>
|
||||
<p>Your access to and use of the Service is conditioned on your acceptance of and compliance with these Terms. These Terms apply to all visitors, users and others who access or use the Service.</p>
|
||||
<p>By accessing or using the Service you agree to be bound by these Terms. If you disagree with any part of the terms then you may not access the Service.</p>
|
||||
<h2 class="text-xl text-button-primary">Accounts</h2>
|
||||
<p>When you create an account with us, you must provide us information that is accurate, complete, and current at all times. Failure to do so constitutes a breach of the Terms, which may result in immediate termination of your account on our Service.</p>
|
||||
<p>You are responsible for safeguarding the password that you use to access the Service and for any activities or actions under your password, whether your password is with our Service or a third-party service.</p>
|
||||
<p>You agree not to disclose your password to any third party. You must notify us immediately upon becoming aware of any breach of security or unauthorized use of your account.</p>
|
||||
<h2 class="text-xl text-button-primary">Links To Other Web Sites</h2>
|
||||
<p>Our Service may contain links to third-party web sites or services that are not owned or controlled by BotsCord.</p>
|
||||
<p>BotsCord has no control over, and assumes no responsibility for, the content, privacy policies, or practices of any third party web sites or services. You further acknowledge and agree that BotsCord shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by
|
||||
your use of or access to any such web sites or services.</p>
|
||||
<p>We strongly advise you to read the terms and conditions and privacy policies of any third-party web sites or services that you visit.</p>
|
||||
<h2 class="text-xl text-button-primary">Termination</h2>
|
||||
<p>We may terminate or suspend access to our Service immediately, without prior notice or liability, for any reason whatsoever, including without limitation if you breach the Terms.</p>
|
||||
<p>All provisions of the Terms which by their nature should survive termination shall survive termination, including, without limitation, ownership provisions, warranty disclaimers, indemnity and limitations of liability.</p>
|
||||
<p>We may terminate or suspend your account immediately, without prior notice or liability, for any reason whatsoever, including without limitation if you breach the Terms.</p>
|
||||
<p>Upon termination, your right to use the Service will immediately cease. If you wish to terminate your account, you may simply discontinue using the Service.</p>
|
||||
<p>All provisions of the Terms which by their nature should survive termination shall survive termination, including, without limitation, ownership provisions, warranty disclaimers, indemnity and limitations of liability.</p>
|
||||
<h2 class="text-xl text-button-primary">Changes</h2>
|
||||
<p>We reserve the right, at our sole discretion, to modify or replace these Terms at any time. If a revision is material we will try to provide at least 30 days notice prior to any new terms taking effect. What constitutes a material change will be determined at our sole discretion.</p>
|
||||
<p>By continuing to access or use our Service after those revisions become effective, you agree to be bound by the revised terms. If you do not agree to the new terms, please stop using the Service.</p>
|
||||
<h2 class="text-xl text-button-primary">Contact Us</h2>
|
||||
<p>If you have any questions about these Terms, please contact us.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%- include('./includes/footer.ejs') %>
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1 @@
|
||||
<%- include('../../includes/header.ejs', {title: 'User' + user.username}) %>
|
||||
Reference in new issue
Block a user