-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
72 lines (56 loc) · 3.9 KB
/
client.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
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const request = require('request');
var EventEmitter = require('events');
const VanityEvents = {
VanitySuccess: 'VanitySuccess',
VanityError: 'VanityError'
};
class VanityClient extends EventEmitter {
constructor({selfToken, guildId, api = { version: 10 }, betterLog = true } = {}) {
super();
if (!selfToken) throw new SyntaxError("Please Specify a Self Token!");
this.token = selfToken;
this.guildID = guildId;
this.log = betterLog || true;
console.log(this.log);
this.version = api.version || { version: 10 };
this.VanityClient = new EventEmitter();
if(typeof this.log !== "boolean") throw new SyntaxError("Log Must Be True or False!");
if (this.log == true) {
console.log("\n");
console.log("\x1b[31m%s\x1b[0m", "▓█████▄ ██▓ ██████ ▄████▄ ▒█████ ██▀███ ▓█████▄ █ ██ ██▀███ ██▓ ")
console.log("\x1b[31m%s\x1b[0m", "▒██▀ ██▌▓██▒▒██ ▒ ▒██▀ ▀█ ▒██▒ ██▒▓██ ▒ ██▒▒██▀ ██▌ ██ ▓██▒▓██ ▒ ██▒▓██▒ ");
console.log("\x1b[31m%s\x1b[0m", "░██ █▌▒██▒░ ▓██▄ ▒▓█ ▄ ▒██░ ██▒▓██ ░▄█ ▒░██ █▌ ▓██ ▒██░▓██ ░▄█ ▒▒██░ ");
console.log("\x1b[31m%s\x1b[0m", "░▓█▄ ▌░██░ ▒ ██▒▒▓▓▄ ▄██▒▒██ ██░▒██▀▀█▄ ░▓█▄ ▌ ▓▓█ ░██░▒██▀▀█▄ ▒██░ ");
console.log("\x1b[31m%s\x1b[0m", "░▒████▓ ░██░▒██████▒▒▒ ▓███▀ ░░ ████▓▒░░██▓ ▒██▒░▒████▓ ▒▒█████▓ ░██▓ ▒██▒░██████▒");
console.log("\x1b[31m%s\x1b[0m", " ▒▒▓ ▒ ░▓ ▒ ▒▓▒ ▒ ░░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒▓ ░▒▓░ ▒▒▓ ▒ ░▒▓▒ ▒ ▒ ░ ▒▓ ░▒▓░░ ▒░▓ ░");
console.log("\x1b[31m%s\x1b[0m", " ░ ▒ ▒ ▒ ░░ ░▒ ░ ░ ░ ▒ ░ ▒ ▒░ ░▒ ░ ▒░ ░ ▒ ▒ ░░▒░ ░ ░ ░▒ ░ ▒░░ ░ ▒ ░")
console.log("\x1b[31m%s\x1b[0m", " ░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░░░ ░ ░ ░░ ░ ░ ░ ")
console.log("\x1b[32m", "\n")
console.log("\x1b[31m", "NPM => https://www.npmjs.com/package/discord-url", "\x1b[0m", "\x1b[36m", "Support => https://discord.gg/luppux", "\x1b[0m")
}
};
async setVanityURL(url) {
if(!url) return null;
const headers = {
"authorization": this.token,
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
};
const payload = { "code": url };
request.patch({
url: `https://discord.com/api/v${this.version}/guilds/${this.guildID}/vanity-url`,
headers: headers,
json: payload
}, (error, response, body) => {
if (response.statusCode == 200) {
this.emit(VanityEvents.VanitySuccess,{ statusCode: 200, vanityURLCode: url, guildId: this.guildID })
return true;
} else {
this.emit(VanityEvents.VanityError, { statusCode: response.statusCode, errorMessage: response.body.message, guildId: this.guildID });
return false;
}
});
}
}
module.exports = { VanityClient, VanityEvents };