Added spacing and presence

This commit is contained in:
ultimateplayer1999 2023-04-26 09:32:56 +00:00
parent da1866915b
commit 37b0fc71ec
3 changed files with 18 additions and 6 deletions

View File

@ -1,5 +1,5 @@
require('dotenv').config(); require('dotenv').config();
const {Client} = require('discord.js'); const {Client, ActivityType} = require('discord.js');
const mongoose = require('mongoose'); const mongoose = require('mongoose');
const Wolfcount = require('./models/wolfcount'); const Wolfcount = require('./models/wolfcount');
@ -21,11 +21,16 @@ const client = new Client({ intents: 34305 });
client.on("ready", () => { client.on("ready", () => {
// set the status to do not disturb // set the status to do not disturb
client.user.setStatus('dnd') // client.user.setStatus('dnd')
client.user.setPresence({
activities: [{ name: `over msgs for certain letters`, type: ActivityType.Watching }],
status: 'dnd',
});
}); });
// Error handling // Error handling
client.on("error", (error) => { client.on("error", (error) => {
console.log('');
console.error("Something went wrong:", error); console.error("Something went wrong:", error);
}); });
@ -34,6 +39,7 @@ const wolfChars = ['w', 'o', 'l', 'f'];
// Find a document by validation // Find a document by validation
Wolfcount.findOne({ validation: 'wolfcount' }).then((countdocument) => { Wolfcount.findOne({ validation: 'wolfcount' }).then((countdocument) => {
console.log('');
console.log(countdocument); console.log(countdocument);
}).catch((error) => { }).catch((error) => {
console.error(error); console.error(error);
@ -43,6 +49,7 @@ basecount = 0
// Reset the wolf count // Reset the wolf count
Wolfcount.findByIdAndUpdate("6447da87681fd1bc486a4923", {count: basecount}).then(() => { Wolfcount.findByIdAndUpdate("6447da87681fd1bc486a4923", {count: basecount}).then(() => {
console.log('');
console.log('Count reset!'); console.log('Count reset!');
}).catch((error) => { }).catch((error) => {
console.error(error); console.error(error);
@ -58,9 +65,14 @@ client.on("messageCreate", (message) => {
message.react("🐺").catch(err=>console.log(err)); message.react("🐺").catch(err=>console.log(err));
newcount = basecount + 1; newcount = basecount + 1;
client.user.setPresence({
activities: [{ name: `${newcount} message(s) detected`, type: ActivityType.Watching }],
status: 'dnd',
});
basecount = newcount; basecount = newcount;
console.log('Live wolf count', newcount); console.log('');
console.log('Live wolf count:', newcount);
// update the wolf count // update the wolf count
Wolfcount.findByIdAndUpdate("6447da87681fd1bc486a4923", {count: newcount}).then(() => { Wolfcount.findByIdAndUpdate("6447da87681fd1bc486a4923", {count: newcount}).then(() => {

View File

@ -23,7 +23,7 @@ try {
// ensure that the bot stats document exists // ensure that the bot stats document exists
const wolfcount = new Wolfcount({ const wolfcount = new Wolfcount({
count: 0, count: 0,
validation: "count" validation: "wolfcount"
}); });
wolfcount.save().then(() => { wolfcount.save().then(() => {

View File

@ -1,10 +1,10 @@
const mongoose = require('mongoose'); const mongoose = require('mongoose');
const wolfclountSchema = new mongoose.Schema({ const wolfcountSchema = new mongoose.Schema({
count: Number, count: Number,
validation: String validation: String
}); });
const Wolfcount = mongoose.model('Wolfcount', wolfclountSchema); const Wolfcount = mongoose.model('Wolfcount', wolfcountSchema);
module.exports = Wolfcount; module.exports = Wolfcount;