-
Notifications
You must be signed in to change notification settings - Fork 0
/
sniper.js
78 lines (69 loc) · 2.37 KB
/
sniper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const { Client } = require('discord.js-selfbot-v13');
const extractPokemonData = require('./src/utilities');
const { random } = require('lodash');
const client = new Client();
const channelId = '';
const messageContent = "<@716390085896962058> m s --sh --lim 3";
const priceLimit = 40000;
let targetChannel;
let buyLock = false; // Mutex lock for buying process
client.on('ready', async () => {
console.log(`Connected to ${client.user.tag}`);
targetChannel = await client.channels.fetch(channelId);
if (!targetChannel) {
console.error(`Channel with ID ${channelId} not found.`);
return;
}
spamMessages(targetChannel);
});
client.on('messageCreate', async (message) => {
if (
message.author.id === '716390085896962058' &&
message.embeds.length > 0 &&
message.embeds[0].title.includes('Pokétwo Marketplace') &&
!buyLock // Check mutex lock
) {
const embed = message.embeds[0];
const raw = embed.description.split('\n');
for (const line of raw) {
const pokemonData = extractPokemonData(line);
if (pokemonData && parseInt(pokemonData.price) < priceLimit) {
buyLock = true;
await targetChannel.send(`<@716390085896962058> m buy ${pokemonData.id}`);
break;
}
}
}
if (
message.channel.id === channelId &&
message.content.toLowerCase().includes('sure')
) {
await message.clickButton();
}
if (
message.channel.id === channelId &&
message.content.toLowerCase().includes('purchased')
) {
buyLock = false;
console.log('Bought a pokemon');
}
if (
message.channel.id === channelId &&
message.content.toLowerCase().includes('listing')
) {
console.log('Missed pokemon');
buyLock = false;
}
});
async function spamMessages(channel) {
setInterval(() => {
if (!buyLock) {
channel.send(messageContent)
.then(() => console.log('Message sent successfully'))
.catch(error => console.error('Error sending message:', error));
} else {
console.log('Skipping message sending due to active buy process');
}
}, random(3, 6) * 1000);
}
client.login('');