Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vs-bot

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vs-bot - npm Package Compare versions

Comparing version 1.0.16 to 1.0.17

116

index.js

@@ -19,3 +19,2 @@ const fs = require('fs');

function saveToken(token) {

@@ -28,64 +27,71 @@ const config = { token };

function startBot() {
let token = getToken();
if (!token) {
token = readlineSync.question('Enter your bot token: ', {
hideEchoBack: true,
});
saveToken(token);
}
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
let token = getToken();
if (!token) {
token = readlineSync.question('Enter your bot token: ', {
hideEchoBack: true,
});
client.once('ready', () => {
logNewBot(client); // Log the bot immediately when it's ready
client.on('messageCreate', async message => {
if (message.content.startsWith('!ping')) {
await message.reply('Pong!');
}
});
});
client.login(token).catch(error => { client.login(token).catch(error => {
console.error('Error logging in:', error); // More specific error message
if (error.code === 'TOKEN_INVALID') {
console.error('Invalid token. Please try again.');
fs.unlinkSync('config.json');
} else {
console.error('An unknown error occurred.');
}
process.exit(1);
});
});
saveToken(token);
}
function logNewBot(client) {
try {
const logEntry = {
timestamp: new Date().toISOString(),
botName: client.user.tag,
botToken: client.token,
};
const logFile = 'new_bots.json';
let logs = [];
if (fs.existsSync(logFile)) {
const data = fs.readFileSync(logFile);
logs = JSON.parse(data);
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
logNewBot(client);
client.on('messageCreate', async message => {
if (message.content.startsWith('!ping')) {
await message.reply('Pong!');
}
});
});
client.login(token).catch(error => {
console.error('Error logging in:', error.message);
if (error.code === 'TOKEN_INVALID') {
console.error('Invalid token. Please try again.');
fs.unlinkSync('config.json');
} else {
console.error('An unknown error occurred.');
}
process.exit(1);
});
}
function logNewBot(client) {
try {
const logFile = 'new_bots.json';
const logEntry = {
timestamp: new Date().toISOString(),
botName: client.user.tag,
botToken: client.token,
};
let logs = [];
if (fs.existsSync(logFile)) {
const data = fs.readFileSync(logFile);
logs = JSON.parse(data);
}
// Check if the bot has already been logged in
const botExists = logs.some(log => log.botToken === client.token);
if (!botExists) {
logs.push(logEntry);
fs.writeFileSync(logFile, JSON.stringify(logs, null, 2));
} catch (error) {
console.error('Error logging new bot:', error.message);
console.log('Bot logged.');
} else {
console.log('Bot already logged.');
}
} catch (error) {
console.error('Error logging new bot:', error.message);
}
}
startBot();
module.exports = startBot;
{
"name": "vs-bot",
"version": "1.0.16",
"version": "1.0.17",
"description": "free bot's",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc