-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
89 lines (75 loc) · 2.68 KB
/
main.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
79
80
81
82
83
84
85
86
87
88
89
/*
Younes Azem ([@4po](https://twitter.com/4poUser))
Site: https://discord.bio/p/apo
GitHub: https://github.com/4po/
Telegram : https://t.me/apodsc
*/
const Discord = require('discord.js'),
client = new Discord.Client(),
moment = require("moment-timezone"),
fetch = require('node-fetch');
class Main {
constructor() {
this.sniperInterval;
}
async setVanityURL(url, guild) {
const time = moment.tz(Date.now(), "Europe/Paris").format("HH:mm:ss");
console.log(`[${time}] [INFO] Sniping discord.gg/${url}`);
return await fetch(`https://discord.com/api/v8/guilds/${guild.id}/vanity-url`, {
"credentials": "include",
"headers": {
"accept": "*/*",
"authorization": "Bot " + client.token,
"content-type": "application/json",
},
"referrerPolicy": "no-referrer-when-downgrade",
"body": JSON.stringify({
"code": url
}),
"method": "PATCH",
"mode": "cors"
});
}
async checkVanityURL(url) {
return await fetch(`https://discord.com/api/v8/guilds/${guild.id}/vanity-url`, {
"credentials": "include",
"headers": {
"accept": "*/*",
"authorization": "Bot " + client.token,
"content-type": "application/json",
},
"referrerPolicy": "no-referrer-when-downgrade",
"method": "GET",
"mode": "cors"
});
}
async startSnipe(url, guild) {
this.sniperInterval = setInterval(async () => {
await this.setVanityURL(url, guild);
}, 1000);
}
stopSnipe() {
return clearInterval(this.sniperInterval);
}
}
const prefix = "!";
let handler = new Main();
client.on('message', async (message) => {
let messageArray = message.content.split(" "),
args = messageArray.slice(1);
const args1 = message.content.slice(prefix.length).split(/ +/),
command = args1.shift().toLowerCase();
if (command === "start-snipe") {
let url = args[0];
if (!message.guild.features.includes('VANITY_URL')) {
return message.reply("Vous ne possedez pas l'options VANITY_URL");
};
message.reply(`Je commence à snipe l'URL ${url} dés maintenant`);
console.log(`[INFO] Start sniping the url ${url} !`);
await handler.startSnipe(url, message.guild);
};
if (command === "stop-snipe") {
handler.stopSnipe();
};
});
client.login("token here");