From 5cc67b27bca7d9d1b58c9ed504156f10d8257590 Mon Sep 17 00:00:00 2001 From: ultimateplayer1999 Date: Sun, 3 Mar 2024 10:45:24 +0000 Subject: [PATCH] Fixed missing variables --- README.md | 35 -------- commands/Info/donate.js | 21 +++++ commands/Management/resetwolfcount.js | 2 +- dbinit.js | 35 ++++---- events/messageCreate.js | 2 +- example.env | 2 + handler/index.js | 19 +++-- readme.md | 5 ++ views/donate.ejs | 116 ++++++++++++++++++++++++++ views/index.ejs | 1 + views/info.ejs | 1 + views/privacy.ejs | 1 + views/tos.ejs | 1 + 13 files changed, 179 insertions(+), 62 deletions(-) delete mode 100644 README.md create mode 100755 commands/Info/donate.js mode change 100644 => 100755 commands/Management/resetwolfcount.js mode change 100644 => 100755 dbinit.js mode change 100644 => 100755 events/messageCreate.js mode change 100644 => 100755 handler/index.js create mode 100644 views/donate.ejs diff --git a/README.md b/README.md deleted file mode 100644 index 4bf5f04..0000000 --- a/README.md +++ /dev/null @@ -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! diff --git a/commands/Info/donate.js b/commands/Info/donate.js new file mode 100755 index 0000000..ce943d4 --- /dev/null +++ b/commands/Info/donate.js @@ -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] }) + } +}; \ No newline at end of file diff --git a/commands/Management/resetwolfcount.js b/commands/Management/resetwolfcount.js old mode 100644 new mode 100755 index bfc7748..4546ee1 --- a/commands/Management/resetwolfcount.js +++ b/commands/Management/resetwolfcount.js @@ -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) => { diff --git a/dbinit.js b/dbinit.js old mode 100644 new mode 100755 index 5252adf..b7e7978 --- a/dbinit.js +++ b/dbinit.js @@ -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') { - - 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`, { + + 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(`${uri}`, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => { diff --git a/events/messageCreate.js b/events/messageCreate.js old mode 100644 new mode 100755 index cebdf7a..c8f9287 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -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); diff --git a/example.env b/example.env index a3ee4eb..3872e55 100644 --- a/example.env +++ b/example.env @@ -7,7 +7,9 @@ DB_URL= MONGODBUSER= MONGODBPASS= MONGODBCLUSTER= +MONGODBHOST= # Required if selfhosted is chosen DATABASE= +UPDATEID= # 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= diff --git a/handler/index.js b/handler/index.js old mode 100644 new mode 100755 index 6090ea0..3c02e61 --- a/handler/index.js +++ b/handler/index.js @@ -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') { - - await mongoose.connect(`mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`, { + } 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(`${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) => { diff --git a/readme.md b/readme.md index 4fa7681..7e4c9d2 100644 --- a/readme.md +++ b/readme.md @@ -52,4 +52,9 @@ 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! diff --git a/views/donate.ejs b/views/donate.ejs new file mode 100644 index 0000000..19b76cc --- /dev/null +++ b/views/donate.ejs @@ -0,0 +1,116 @@ + + + + + + + + Wolfcount donate + + + + + + + + +
+

Want to donate??

+

Please use this link to directly donate to the hoster of the server where this bot is hosted on

+

If you don't have a creditcard, you can use this link to donate with PayPal.

+

Payments on both links will get used to uphold the service :)

+

+ +
+
+
+

Translate this page:

+
+
+
+

© Ultimateplayer1999 (ultimateplayer#0369)

+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/views/index.ejs b/views/index.ejs index e38fad3..58d506a 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -78,6 +78,7 @@ Some info Privacy Policy TOS + Donate diff --git a/views/info.ejs b/views/info.ejs index 16c9d2b..a1e1987 100644 --- a/views/info.ejs +++ b/views/info.ejs @@ -76,6 +76,7 @@ Back to count Privacy Policy TOS + Donate
diff --git a/views/privacy.ejs b/views/privacy.ejs index 8055c0d..2ebf452 100644 --- a/views/privacy.ejs +++ b/views/privacy.ejs @@ -68,6 +68,7 @@ Back to count Some info TOS + Donate
diff --git a/views/tos.ejs b/views/tos.ejs index 66663f5..24db37e 100644 --- a/views/tos.ejs +++ b/views/tos.ejs @@ -67,6 +67,7 @@ Back to count Some info Privacy Policy + Donate