diff --git a/commands/Info/wolfcount.js b/commands/Info/wolfcount.js index c6980ba..a07c03a 100644 --- a/commands/Info/wolfcount.js +++ b/commands/Info/wolfcount.js @@ -34,7 +34,7 @@ mongoose.connect(uri, { module.exports = { name: "wolfcount", private: false, - description: "Returns the amount of times the letters wolf were said by users (state refreshes every 2 minutes).", + description: "Returns the amount of times the letters wolf were said by users.", run: async (client, interaction) => { diff --git a/commands/Management/DeleteApplicationCommands.js b/commands/Management/DeleteApplicationCommands.js new file mode 100644 index 0000000..ccba51f --- /dev/null +++ b/commands/Management/DeleteApplicationCommands.js @@ -0,0 +1,44 @@ +require("dotenv").config(); +const { EmbedBuilder, REST, Routes } = require('discord.js'); + +ownerList = [ + '213966480621043712' +]; + +const rest = new REST().setToken(process.env.TOKEN); + +// module.exports = { +// name: "deleteslashcommands", +// private: true, +// description: "Deregister guild slash commands", + +// run: async (client, interaction) => { +// if (ownerList.includes(interaction.user.id)) { + +// rest.put(Routes.applicationGuildCommands(client.user.id, interaction.guild.id), { body: [] }) +// .then(() => { +// console.log(`Successfully deleted all guild commands of guild ${interaction.guild.id}.`) +// const embed = new EmbedBuilder() +// .setColor("#FF0000") +// .setTitle("Slash commands deleted successfully") +// .setDescription(`Guild slash commands deleted successfully`) +// .setTimestamp() +// .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); +// interaction.followUp({ embeds: [embed] }); +// }) +// .catch((err) => { +// interaction.followUp({ content: 'Something went wrong'}); +// console.log(err); +// }); + +// } else { +// const embed = new EmbedBuilder() +// .setColor("#FF0000") +// .setTitle("🐺 no perms") +// .setDescription(`You have no perms to do this.`) +// .setTimestamp() +// .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); +// interaction.followUp({ embeds: [embed] }); +// } +// }, +// }; \ No newline at end of file diff --git a/commands/Management/SetStatus.js b/commands/Management/SetStatus.js new file mode 100644 index 0000000..f22ff1b --- /dev/null +++ b/commands/Management/SetStatus.js @@ -0,0 +1,36 @@ +const { EmbedBuilder, SlashCommandBuilder } = require('discord.js'); +const client = require('../../index.js'); + +developerList = [ + '213966480621043712', +]; + +module.exports = { + name: "setstatus", + private: true, + description: "Set status", + + run: async (client, interaction) => { + if (developerList.includes(interaction.user.id)) { + + client.user.setStatus('dnd') + + const embed = new EmbedBuilder() + .setColor("#FF0000") + .setTitle("Status set") + .setDescription(`Bot status set to predefined value`) + .setTimestamp() + .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); + interaction.followUp({ embeds: [embed] }); + + } else { + const embed = new EmbedBuilder() + .setColor("#FF0000") + .setTitle("🐺 no perms") + .setDescription(`You have no perms to do this.`) + .setTimestamp() + .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); + interaction.followUp({ embeds: [embed] }); + } + }, +}; diff --git a/commands/Info/resetwolfcount.js b/commands/Management/resetwolfcount.js similarity index 91% rename from commands/Info/resetwolfcount.js rename to commands/Management/resetwolfcount.js index 8e30238..bfc7748 100644 --- a/commands/Info/resetwolfcount.js +++ b/commands/Management/resetwolfcount.js @@ -1,5 +1,6 @@ const { EmbedBuilder } = require('discord.js'); const wolfcount = require('../../models/wolfcount'); +const { spawn } = require("child_process"); ownerList = [ '213966480621043712', @@ -33,6 +34,8 @@ module.exports = { .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); interaction.followUp({ embeds: [embed] }); + basecount = resetcount; + } else { const embed = new EmbedBuilder() .setColor("#FF0000") diff --git a/events/messageCreate.js b/events/messageCreate.js index 2a12a2e..cebdf7a 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -6,7 +6,7 @@ const wolfChars = ['w', 'o', 'l', 'f']; client.on("messageCreate", async (message) => { if (message.author.bot) return; - if (message.content.includes(">>")) return; + if (message.content.includes(">>") || message.content.includes(">r>")) return; // convert the message to lowercase const lowerMsg = message.content.toLowerCase(); @@ -27,6 +27,21 @@ client.on("messageCreate", async (message) => { console.log(''); console.log('Live wolf count:', newcount); + + if (newcount == 69) { + message.react("1103666748592488549").catch(err=>console.log(err)); // pogslide + message.react("1103673748466434140").catch(err=>console.log(err)); // 69nice + } + + if (newcount == 100) { + message.react("💯").catch(err=>console.log(err)); + message.react("1103666748592488549").catch(err=>console.log(err)); // pogslide + } + + if (newcount == 420) { + message.react("1103666748592488549").catch(err=>console.log(err)); // pogslide + message.react("1103675067054948392").catch(err=>console.log(err)); // pepe_high + } // update the wolf count wolfcount.findByIdAndUpdate("6447da87681fd1bc486a4923", {count: newcount}).then(() => { diff --git a/events/ready.js b/events/ready.js index 6ee3ff2..93ac9c7 100644 --- a/events/ready.js +++ b/events/ready.js @@ -1,15 +1,51 @@ const client = require("../index"); -const { ActivityType } = require('discord.js'); +const { EmbedBuilder, ActivityType } = require('discord.js'); client.on("ready", () => { - console.clear(); console.log(`${client.user.tag} is up and ready to go!`); // set the status to do not disturb // client.user.setStatus('dnd') - client.user.setPresence({ - activities: [{ name: `over msgs for certain letters`, type: ActivityType.Watching }], + // client.user.setPresence({ + // activities: [{ name: `over msgs for certain letters`, type: ActivityType.Watching }], + // status: 'dnd', + // }); + + client.user.setPresence({ + activities: [{ name: `RIP #1123`, type: ActivityType.Playing }], status: 'dnd', }); + + // Function to convert RGB to hex + function convertToHex(rgb) { + // Extract the RGB values using a regex pattern + const rgbValues = rgb.match(/\d+/g); + + // Convert each RGB value to a hexadecimal string + const hexValues = rgbValues.map((value) => { + // Convert the value to a number + const intValue = parseInt(value); + + // Convert the number to a hexadecimal string + const hexString = intValue.toString(16); + + // Pad the string with zero if needed + return hexString.padStart(2, '0'); + }); + + // Return the hex color string + return `#${hexValues.join('')}`; + }; + + const readyEmbed = new EmbedBuilder() + .setTitle('Now online!') + .setColor(convertToHex('rgb(119, 152, 229)')) + .setAuthor({ name: client.user.tag, iconURL: client.user.avatarURL() }) + .setTimestamp() + .setDescription(`${client.user.tag} is nu online`); + + // client.channels.cache.get(`967754078438449192`).send(`${client.user.tag} is nu online.`); + client.channels.cache.get(`967754078438449192`).send({ embeds: [readyEmbed] }) + }); diff --git a/handler/index.js b/handler/index.js index 4a55ca8..087d460 100644 --- a/handler/index.js +++ b/handler/index.js @@ -1,4 +1,5 @@ require("dotenv").config(); +const { ActivityType } = require("discord.js"); const { glob } = require("glob"); const { promisify } = require("util"); const globPromise = promisify(glob); @@ -54,7 +55,8 @@ module.exports = async (client) => { basecount = countdocument.count || 0; console.log(''); - console.log(`Starting count from ${basecount}`) + console.log(`Starting count from ${basecount}`); + console.log(``); }).catch((error) => { console.error(error); }); @@ -76,6 +78,11 @@ module.exports = async (client) => { // Slash Commands Register client.on("ready", async () => { + // client.user.setPresence({ + // activities: [{ name: `over msgs for certain letters`, type: ActivityType.Watching }], + // status: 'dnd', + // }); + cron.schedule('*/2 * * * *', async () => { console.log(`${moment(Date.now()).format('DD/MM/YY H:mm:ss')} Starting count refresh...`); diff --git a/index.js b/index.js index 5ea2c81..1ba86d4 100644 --- a/index.js +++ b/index.js @@ -1,13 +1,27 @@ require("dotenv").config(); -const { Client, Collection } = require("discord.js"); +const { Client, Collection, Options } = require("discord.js"); -const client = new Client({ intents: 34305 }); +const client = new Client({ + intents: 34305, + makeCache: Options.cacheWithLimits({MessageManager: 0}) + // sweepers: { + // ...Options.DefaultSweeperSettings, + // messages: { + // interval: 120, // Every 2 minutes... + // lifetime: 600, // Remove messages older then 10 minutes. + // }, + // }, +}); module.exports = client; // Global Variables client.commands = new Collection(); client.slashCommands = new Collection(); +console.clear(); +console.log(''); +console.log(`Welcome to the console of wolfcount /--/ By Ultimateplayer1999 /--/ Discord: ultimateplayer#0369`); + // Initializing the project require("./handler")(client); diff --git a/package-lock.json b/package-lock.json index 49b695b..31e4883 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "ejs": "^3.1.9", "express": "^4.18.2", "glob": "^7.2.0", + "helmet": "^7.0.0", "moment": "^2.29.4", "mongoose": "^7.1.0", "node-cron": "^3.0.2" @@ -671,6 +672,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/helmet": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-7.0.0.tgz", + "integrity": "sha512-MsIgYmdBh460ZZ8cJC81q4XJknjG567wzEmv46WOBblDb6TUd3z8/GhgmsM9pn8g2B80tAJ4m5/d3Bi1KrSUBQ==", + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -1963,6 +1972,11 @@ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" }, + "helmet": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-7.0.0.tgz", + "integrity": "sha512-MsIgYmdBh460ZZ8cJC81q4XJknjG567wzEmv46WOBblDb6TUd3z8/GhgmsM9pn8g2B80tAJ4m5/d3Bi1KrSUBQ==" + }, "http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", diff --git a/package.json b/package.json index 98f664d..ed45b2f 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "ejs": "^3.1.9", "express": "^4.18.2", "glob": "^7.2.0", + "helmet": "^7.0.0", "moment": "^2.29.4", "mongoose": "^7.1.0", "node-cron": "^3.0.2" diff --git a/views/index.ejs b/views/index.ejs index 7af9b5b..e38fad3 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -8,126 +8,88 @@ <%= basecount %> Wolfs - -

<%= basecount %> wolfs

+ +

<%= basecount %> wolfs

+ + - - - - \ No newline at end of file + \ No newline at end of file diff --git a/views/info.ejs b/views/info.ejs index 23c5929..16c9d2b 100644 --- a/views/info.ejs +++ b/views/info.ejs @@ -9,15 +9,60 @@ @@ -26,15 +71,41 @@
+ +
+
+

Some information about this bot.

The bot counts how many times the set letters are found, this will be once per message. So if someone says in this case wolf bla wolf the bot only counts one (the first one). Data refreshes every 2 minutes based on cron time (so 02, 04, 06, etc...).

You can add this bot by going to this page. It will ofcourse ask you to go through some steps set by Discord to safely add it to the wanted server (Only 100 guilds possible, it may not be verified for more).

-

- Back to count
- Privacy policy
- Terms of Service -
+
+ + + + + + diff --git a/views/notlive.txt b/views/notlive.txt new file mode 100644 index 0000000..4326b76 --- /dev/null +++ b/views/notlive.txt @@ -0,0 +1,42 @@ + /* 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; + } */ + + + + + + \ No newline at end of file diff --git a/views/privacy.ejs b/views/privacy.ejs index b9a6ae1..8055c0d 100644 --- a/views/privacy.ejs +++ b/views/privacy.ejs @@ -9,15 +9,52 @@ @@ -26,6 +63,16 @@
+ +
+
+

Privacy statement

Data we collect

The following data will get collected by using this bot. @@ -34,13 +81,29 @@

Why we collect it?

It will only get used for counting the number of messages.

Does the data get shared?

-

The message data is not shared to public, only the count is given on the page and the /wolfcount command.

-

- Back to count
- Some more information
- Terms of Service -
+

The message content is not shared to public, only the count is given on the landing page and the /wolfcount command. (The message content does not even get logged, it gets removed from its cache after processing)

+
+ + + + + + diff --git a/views/script.js--- b/views/script.js--- deleted file mode 100644 index c961468..0000000 --- a/views/script.js--- +++ /dev/null @@ -1,33 +0,0 @@ -require("dotenv").config(); -const mongoose = require('mongoose'); -const wolfcount = require('../models/wolfcount'); -const moment = require('moment'); - -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(() => { - console.log(''); - console.log(`Connected to the database`); -}).catch((error) => { - console.log(`Failed to connect to the database`); - console.log(error); -}); - -console.log(`${moment(Date.now()).format('DD/MM/YY H:mm:ss')} Starting count refresh...`); - -// Find a document by validation -wolfcount.findOne({ validation: 'wolfcount' }).then((countdocument) => { - console.log(''); - //console.log(countdocument); - console.log(`Refreshed count`) - const basecount = countdocument.count - - console.log(''); -}).catch((error) => { - console.error(error); -}); - -console.log(`${moment(Date.now()).format('DD/MM/YY H:mm:ss')} Refreshed wolfcount on cron`); \ No newline at end of file diff --git a/views/tos.ejs b/views/tos.ejs index 75fe2de..66663f5 100644 --- a/views/tos.ejs +++ b/views/tos.ejs @@ -9,15 +9,51 @@ @@ -26,15 +62,41 @@
-

Terms of Service

-

This bot kinda collects messages of Discord servers, so please mind the Terms of Service and https://discord.com/guidelines of Discord. - (The bot does not store the messages like Discord does, but it is better to follow the TOS and of Discord to avoid termination)

-

- Back to count
- Some more information
- Privacy policy + +
+
+

Terms of Service

+

This bot kinda collects messages of Discord servers, so please mind the Terms of Service and Community Guidelines of Discord. + (The bot does not store the messages like Discord does, but it is better to follow the TOS of Discord to avoid termination)

+

+ + + + + +