Fixed missing variables

This commit is contained in:
ultimateplayer1999 2024-03-03 10:45:24 +00:00
parent ecea682fdd
commit 5cc67b27bc
13 changed files with 179 additions and 62 deletions

View File

@ -1,35 +0,0 @@
# Discord-Linux Discord.JS v14 Base Template
Only 3 dependencies required to run this bot!
Message intents are NOT supported in this bot, this is due to the verification that Discord is enabling.
Structure:
**commands** - This folder contains commands
**event** - This folder contains files related to discord.js events. (Like "ready", "interactionCreate")
**handler** - This folder contains files that read the commands folders contents.
**index.js** - This is the main file to run the bot.
1) Use ```npm i ```
2) Create a .env file ``` touch .env```
3) Edit .env
```
TOKEN = token
```
4) Go to Handler -- > index.js and change "GUIDIDHERE" to your Discord Server's Guild ID
5) Go into https://discord.com/developers/applications and enable Privileged Intents.
6) Run the bot ```node index.js```
Want to make this better? Issue a pull request!

21
commands/Info/donate.js Executable file
View File

@ -0,0 +1,21 @@
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: 'donate',
private: false,
description: 'Shows links to donate to the service',
run: async (client, interaction) => {
const embed = new EmbedBuilder()
.setColor('#03FC20')
.setTitle('Donation')
.setDescription('Donate to the service I am using with one of the following links:')
.setFields(
{ name: ' ', value: '[Direct donation to the host (creditcard needed)](https://ssh.surf/view/donate/)', inline: false },
{ name: ' ', value: '[Donation through an external provider](https://ko-fi.com/sshsurf)', inline: false },
)
interaction.followUp({ embeds: [embed] })
}
};

2
commands/Management/resetwolfcount.js Normal file → Executable file
View File

@ -19,7 +19,7 @@ module.exports = {
resetcount = 0
// Reset the wolf count
wolfcount.findByIdAndUpdate("6447da87681fd1bc486a4923", {count: resetcount}).then(() => {
wolfcount.findByIdAndUpdate(`${process.env.UPDATEID}`, {count: resetcount}).then(() => {
console.log('');
console.log('Count reset!');
}).catch((error) => {

31
dbinit.js Normal file → Executable file
View File

@ -3,25 +3,26 @@ require('dotenv').config();
const mongoose = require('mongoose');
const Wolfcount = require('./models/wolfcount');
const uri = `mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`
const dblocation = process.env.DBLOCATION
try {
if (dblocation === 'selfhosted') {
if (dblocation === 'selfhosted') {
const uri = `mongodb://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBHOST}/${process.env.DATABASE}`
mongoose.connect(`${uri}`, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
console.log('');
console.log(`Connected to the selfhosted database`);
}).catch((error) => {
console.log(`Failed to connect to the database`);
console.log(error);
});
} else if (dblocation === 'cloud') {
const uri = `mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`
mongoose.connect(`mongodb://localhost:27017/wolfcounter`, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
console.log('');
console.log(`Connected to the selfhosted database`);
}).catch((error) => {
console.log(`Failed to connect to the database`);
console.log(error);
});
} else if (dblocation === 'cloud') {
mongoose.connect(`mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`, {
mongoose.connect(`${uri}`, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {

2
events/messageCreate.js Normal file → Executable file
View File

@ -44,7 +44,7 @@ client.on("messageCreate", async (message) => {
}
// update the wolf count
wolfcount.findByIdAndUpdate("6447da87681fd1bc486a4923", {count: newcount}).then(() => {
wolfcount.findByIdAndUpdate(`${process.env.UPDATEID}`, {count: newcount}).then(() => {
console.log('Count updated!');
}).catch((error) => {
console.error(error);

View File

@ -7,7 +7,9 @@ DB_URL=<optional>
MONGODBUSER=<Username>
MONGODBPASS=<Pass>
MONGODBCLUSTER=<cluster>
MONGODBHOST=<host> # Required if selfhosted is chosen
DATABASE=<dbname>
UPDATEID=<documentid> # This is the ID of the document which is created with the dbinit (or the ID of the document of an existing document if you are reinstalling this)
#Webstuff
PORT=<port>

15
handler/index.js Normal file → Executable file
View File

@ -14,24 +14,24 @@ const cwd = process.cwd()
module.exports = async (client) => {
const uri = `mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`
const dblocation = process.env.DBLOCATION
if (dblocation === 'selfhosted') {
await mongoose.connect('mongodb://localhost:27017/wolfcounter', {
const uri = `mongodb://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBHOST}/${process.env.DATABASE}`
mongoose.connect(`${uri}`, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
console.log('');
console.log(`Connected to the selfhosted database`);
}).catch((error) => {
console.log(`Failed to connect to the selfhosted database`);
console.log(`Failed to connect to the database`);
console.log(error);
});
} else if (dblocation === 'cloud') {
} else if (dblocation === 'cloud') {
const uri = `mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`
await mongoose.connect(`mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`, {
await mongoose.connect(`${uri}`, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
@ -155,6 +155,9 @@ module.exports = async (client) => {
res.render('tos');
});
app.get("/donate", (req, res) => {
res.render('donate');
});
// redirect /invite to the discord invite
app.get('/invite', async (req, res) => {

View File

@ -52,4 +52,9 @@ PORT=<port>
6) Run the bot ```node index.js```
# Want to donate? Please use one of the following links below to support the platform I am using.
[Direct donation to the host (creditcard needed)](https://ssh.surf/view/donate/)
[Donation through an external provider](https://ko-fi.com/sshsurf)
Want to make this better? Issue a pull request!

116
views/donate.ejs Normal file
View File

@ -0,0 +1,116 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" sizes="192x192" href="/wolf.png">
<title>Wolfcount donate</title>
<style>
body {
background-color: #c2c2c2 !important;
/* margin: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center; */
font-family: 'Courier New', Courier, monospace;
}
/* Keyframes */
@keyframes colorchange {
from {color: aqua;}
to {color: blue}
}
h3, .translate-box {background-image: linear-gradient(to right, #c2c2c2, #6b6a6a);}
.wolfnav {margin-right:6px;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;}
.wolfnav a {color:black; animation-name: colorchange; animation-duration: 3s; animation-iteration-count: 3;}
.wolfnav a:nth-child(1) {color:green}
.wolfnav a:nth-child(3) {color:blue}
.wolf-img img{height:760px;max-width: 100%;}
.wolf-footer {margin-right:6px;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;background-image: linear-gradient(to right, aquamarine, blue);padding: 20px;}
/* Extra Large devices */
/* @media (min-width: 1200px) { .wolf-img img{height:633px;max-width: 90%;margin: auto 40px;} } */
/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) { .wolf-img img{height:570px;max-width: 90%;margin: auto 40px;} }
/* Galaxy A13 (and all devices sharing the same width)*/
@media (min-width: 718px) and (max-width: 720px) { .wolf-footer {padding: 10px;margin-top: 28.3vh;} }
/* Galaxy Fold (extended) */
@media (max-width: 717px) { .wolfcounting {margin: 25% auto;} }
/* Small devices (landscape phones, 376px and up) */
@media (min-width: 376px) and (max-width: 425px) { .wolf-img img{height:400px;max-width: 90%;margin: auto 25px;} }
/* Small devices (landscape phones, 321px and up) */
@media (min-width: 321px) and (max-width: 375px) { .wolf-img img{height:380px;max-width: 90%;margin: auto 25px;} }
/* Small devices (landscape phones, 320px and under) */
@media (max-width: 320px) { .translate-box{ max-width: 84%;margin-left: 27px;margin-bottom: 10px; } .wolf-img img{height:330px;max-width: 90%;margin: auto 20px;} }
/* Custom devices/others */
/* Custom for up to 1400px */
/* @media (min-width: 1201px) and (max-width:1400px) { .wolfcounting {margin: 26% auto !important;} } */
@media (min-width:992px) and (max-width: 1024px) { .wolf-img img{height:633px;max-width: 90%;margin: auto 40px;} }
/* Surface Duo and Galaxy Fold (Extended)*/
@media (min-width:717px) and (max-width:720px) { .wolf-img img{height:530px;max-width: 90%;margin: auto 40px;} }
</style>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
</head>
<body>
<div class="container" style="padding: 10px">
<nav class="wolfnav">
<h3 style="box-shadow: 4px 6px; border: 3px solid grey; padding: 0.2vh 5px;">
<a href="/">Back to count</a>
<a href="/info">Some info</a>
<a href="/privacy">Privacy Policy</a>
<a href="/tos">TOS</a>
</h3>
</nav>
<div class="img-fluid wolf-img"><a href="https://imgur.com/zltFwjV"><img src="https://i.imgur.com/zltFwjV.jpg" title="source: imgur.com" /></a></div>
</div>
<div class="border container">
<h1>Want to donate??</h1>
<p>Please use <a href="https://ssh.surf/view/donate/">this link</a> to directly donate to the hoster of the server where this bot is hosted on</p>
<p>If you don't have a creditcard, you can use <a href="https://ko-fi.com/sshsurf">this link</a> to donate with PayPal.</p>
<p>Payments on both links will get used to uphold the service :)</p>
</div><br>
<footer class="container-fluid wolf-footer">
<div class="row">
<div style="box-shadow: 4px 6px; border: 3px solid grey; padding: 0.2vh 5px;" class="translate-box col-sm-auto">
<h3>Translate this page:</h3>
<div id="google_translate_element"></div>
</div>
<div style="padding: 0 28px" class="col-sm-auto wolf-copy">
<h3 style="box-shadow: 4px 6px; border: 3px solid grey; padding: 0.2vh 5px;">©<script>document.write(new Date().getFullYear())</script> Ultimateplayer1999 (ultimateplayer#0369)</h3>
</div>
</div>
</footer>
<!-- GTRANSLATE -->
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
</body>
</html>

View File

@ -78,6 +78,7 @@
<a href="/info">Some info</a>
<a href="/privacy">Privacy Policy</a>
<a href="/tos">TOS</a>
<a href="/donate">Donate</a>
</h3>
</div>

View File

@ -76,6 +76,7 @@
<a href="/">Back to count</a>
<a href="/privacy">Privacy Policy</a>
<a href="/tos">TOS</a>
<a href="/donate">Donate</a>
</h3>
</nav>
<div class="img-fluid wolf-img"><a href="https://imgur.com/zltFwjV"><img src="https://i.imgur.com/zltFwjV.jpg" title="source: imgur.com" /></a></div>

View File

@ -68,6 +68,7 @@
<a href="/">Back to count</a>
<a href="/info">Some info</a>
<a href="/tos">TOS</a>
<a href="/donate">Donate</a>
</h3>
</nav>
<div class="img-fluid wolf-img"><a href="https://imgur.com/0xO7YqI"><img src="https://i.imgur.com/0xO7YqI.jpg" title="source: imgur.com" /></a></div>

View File

@ -67,6 +67,7 @@
<a href="/">Back to count</a>
<a href="/info">Some info</a>
<a href="/privacy">Privacy Policy</a>
<a href="/donate">Donate</a>
</h3>
</nav>
<div class="img-fluid wolf-img"><a href="https://imgur.com/Dfxdj7i"><img src="https://i.imgur.com/Dfxdj7i.jpg" title="source: imgur.com" /></a></div>