-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
153 lines (146 loc) · 6.2 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// AltV Server Daten
var ip = '1.1.1.1';
var port = '80';
// request
var request = require('request');
var url = 'https://api.altv.mp/server/+serverID';
// uptime checks
var tcpp = require('tcp-ping');
// Discord.js
const Discord = require('discord.js');
const { info } = require('console');
const client = new Discord.Client();
// client login
client.login('YOUR BOT TOKEN');
// if client is ready print to console
client.on('ready', ()=>{
console.log('Bot ist online!');
});
client.on('message', info =>{
if (info.channel.id === '703237646947713075'){
if (info.content.startsWith('/info')){
tcpp.probe(ip, port, function(err, available){
if (available){
request({
url: url,
json: true
}, function(error, response, body){
if (!error && response.statusCode === 200){
console.log(body.info.maxPlayers);
info.channel.send({embed:{
color: 3066993,
title: 'Server Informations',
fields: [{
name: 'Server Name',
value: body.info.name
},
{
name: 'Players online',
value: body.info.players + ' / ' + body.info.maxPlayers
},
{
name: 'Server locked?',
value: body.info.locked
},
{
name: 'Host:',
value: body.info.host
},
{
name: 'Port:',
value: body.info.port
},
{
name: 'GameMode',
value: body.info.gameMode
},
{
name: 'Website:',
value: body.info.website
},
{
name: 'Language',
value: body.info.language
},
{
name: 'Server verified?',
value: body.info.verified
},
{
name: 'Server promoted?',
value: body.info.promoted
},
{
name: 'UseEarlyAuth?',
value: body.info.useEarlyAuth
},
{
name: 'useCdn?',
value: body.info.useCdn
},
{
name: 'UseVoiceChat?',
value: body.info.useVoiceChat
},
{
name: 'Server Tags:',
value: body.info.tags
},
{
name: 'Server build:',
value: body.info.build
},
{
name: 'Last update:',
value: body.info.lastUpdates
}
],
footer: {
text: 'example'
}
}})
}
})
}else{
console.log('Server is offline!');
}
})
}
}
})
client.on('message', serverInformations =>{
if (serverInformations.channel.id === '703237646947713075'){
if (serverInformations.content.startsWith('/status')){
tcpp.probe(ip, port, function(err, available){
if (available){
request({
url: url,
json: true
}, function(error, response, body){
if (!error && response.statusCode === 200){
console.log(body.info.maxPlayers);
serverInformations.channel.send({embed:{
color: 3066993,
title: 'Server is online',
fields: [{
name: 'Online Players:',
value: body.info.players + ' / ' + body.info.maxPlayers
},
{
name: 'Server Tags',
value: body.info.tags
}
],
footer: {
text: 'example'
}
}})
}
})
}else{
console.log('Server is offline!');
}
})
}
}
})