Skip to content

Message logging system for Discord bots. Primarily written for bots following the Discord.js API (Node.js)

License

Notifications You must be signed in to change notification settings

s2bd/discord-bot-spyware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverwise - Discord Message Logging System

Message logging system for Discord bots. Primarily written for bots following the Discord.js API (Node.js).

  • 💬️ Auto-record messages across multiple servers
  • 😴️ Store activities and track suspicious behavior while you're AFK
  • ♻️ Keep permanent backup records of messages as a recovery
  • 👀️ Know who sends what, even if they delete their messages

Overview

Made as part of a Discord.js bot back in May 2022. Now discretely available for integrating this simple but effective algorithm into your bots with ease! The main program/algorithm is very simple. It just relies on a single function (I named it logwrite by default, but doesn't have to be the same name),

logwrite(msg,server,chatroom);

where the message, the server and text channel identifiers are passed down. Then, they are stored in a plain text file on your bot's hosting storage, be it a web server or your own device. Each MESSAGES.log file is stored within subfolders relating to the text channel it was recorded from, which are located in folders named after the servers themselves.

Terms Of Use

Use with caution. Use at your own risk. By using or relying on this source of information, you agree to be held liable legally for any damages or charges accrued via the means of using this program snippet.

How To Use

Assuming you have a seperate file for tracking the Discord client event messageCreate, you first import fs for file handling.

const fs = require('fs');

And then simply define this function:

function logwrite(msg, server, chatroom) {
fs.mkdirSync('Serverwise/'+String(server)+'/'+String(chatroom)+'/', { recursive: true });
fs.appendFileSync('Serverwise/'+String(server)+'/'+String(chatroom)+'/'+'MESSAGES.log', msg+'\n',
function (err) {if (err) throw err; });
};

Now within the scope of your program where your bot is supposed to detect messages sent by users, embed the function call, i.e.

if (message.content) { 
// ... other lines of code
logwrite(`[${String(new Date).split(" ", 5).join(" ")}]`+ String(message.author.username) + "#" + String(message.author.discriminator) + " said: " + String(message.content), message.channel.guild.name, message.channel.name);
// ... other lines of code
};

And that's it! You're good to go!

Have fun spying on your friends' servers or doing whatever your evil heart desires. I don't know what to advise you.

Bonus : Terminal Output

This is an optional modification where you can temporarily monitor the activities straight from the bot's terminal. Just like setting up the function above, you can have the message logs displayed in real-time on the console/terminal/CLI of your bot. All you have to do is add in this little snippet right before or after the logwrite function call.

if (message.content) { 
// ... other lines of code
console.log('\x1b[36m%s\x1b[0m',message.channel.guild.name,"\x1b[33m#"+message.channel.name,"\x1b[0m", message.author.username + "#" + message.author.discriminator, "said: ", message.content);
// ... other lines of code
};

Don't worry about the weird escape characters and strings (ANSI encoding) in front of the variables. They're there to 'color-code' the output neatly.

Update - June 2025

Alright here's what you need to do:

  1. Install dependencies, e.g.
npm install discord.js express ejs dotenv tailwindcss
  1. Create an .env file with your bot token, e.g.
TOKEN=your_bot_token
  1. Run your bot
node .

If you don't have a bot, use the main.js file as a basic "core" to let the Serverwise system do its work.

About

Message logging system for Discord bots. Primarily written for bots following the Discord.js API (Node.js)

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •