This repository has been archived by the owner on May 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathfivem.js
248 lines (196 loc) · 6.9 KB
/
fivem.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Complied and Created
// By Zua (ThatZiv)
// Purpose: "FiveM Bot"
// Version: 7.1.3
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Load up the discord.js library (node.js)
global.Discord = require("discord.js");
global.client = new Discord.Client();
global.config = require("./cmds/config/config.json");
global.package = require("./package.json");
global.servers = require('./auth/servers.json')
global.req = require('request');
//global.snek = require("snekfetch")
global.notes = require("./auth/notes.json")
global.news = require("./auth/news.json").body;
global.modules = require("./modules")
global.log = require("./modules/log")
// RCON UPDATE
global.Q3RCon = require('quake3-rcon');
global.rcondb = require("./auth/rcon.json");
global.crypto = require("crypto-js");
// NATIVES
global.tempNatives = require("./auth/temp.json")
global.listNatives = require("./auth/names.json")
global.fs = require("fs");
global.dns = require('dns');
global.sleep = require("system-sleep");
global.createHash = require('hash-generator'); // horrible idea btw
global.Fuse = require("fuse.js")
global.colors = require("colors")
/* dumped from premium build */
global.state = config.title;
global.icon = `http://thatziv.ddns.net/assets/fivem.png`;
const express = require('express');
global.set = new Set();
// User Config
global.title = config.title;
global.prefix = config.prefix;
global.color = config.color;
global.premcolor = config.premcolor;
global.author = package.author;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Error thing
zembed("An Error Occured...\n**Console:**\n```js\n"+error+"```");
*/
client.on("message", message => {
if (!message.content.startsWith(config.prefix)) return;
if (set.has(message.author.id)) {
message.delete();
return zembed(`<@${message.author.id}>, Please wait 3 seconds between using commands.`)
}
set.add(message.author.id)
module.exports.zembed = (args, colour) => {
let embed = new Discord.RichEmbed()
.setDescription(args)
.setColor(colour)
message.channel.send({ embed: embed })
.then(msg => {
msg.delete(5000)
})
return;
}
module.exports.good = (args) => {
let embed = new Discord.RichEmbed()
.setAuthor(state, icon)
.addField("Successful.", args)
.setColor('#1daf4c')
.setThumbnail(icon)
message.channel.send({ embed: embed })
return;
}
module.exports.bad= (args) => {
let embed = new Discord.RichEmbed()
.setAuthor(state, icon)
.addField("Failed.", args)
.setColor('#e22424')
.setThumbnail(icon)
message.channel.send({ embed: embed })
return;
}
module.exports.error = (args) => {
let embed = new Discord.RichEmbed()
.setAuthor(state, icon)
.setDescription(args)
.setColor('#e22424')
.setThumbnail(icon)
message.channel.send({ embed: embed })
return;
}
module.exports.embed = (args) => {
let embed = new Discord.RichEmbed()
.setDescription(args)
.setColor(color)
message.channel.send({ embed: embed })
return;
}
module.exports.num = (min, max) => {
return Math.floor(Math.random() * (max - min)) + min;
}
/////// LOG
/* Deprecated
function log(content) {
fs.appendFile('log.txt', `[${today}] | ${content}\n`, (err) => {
if (err) throw err;
});
} */
/* module.exports.log = function (content) {
fs.appendFile('index.html', `
<tr>
<th scope="row">${new Date()}</th>
<td>${content}</td>
<td>${message.guild}</td>
</tr>`, (err) => {
if (err) throw err;
});
} */
//////
// z-embed
function zembed(args) {
let embed = new Discord.RichEmbed()
.setDescription(args)
.setColor(color)
message.channel.send({ embed: embed })
.then(msg => {
msg.delete(5000)
})
return;
}
setTimeout(() => {
set.delete(message.author.id)
}, 3000)
if (message.author.bot) return;
if (message.content.indexOf(config.prefix) !== 0) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
try {
let commandFile = require(`./cmds/${command}.js`);
commandFile.run(client, message, args);
} catch (err) {
zembed("Sorry, That Command Doesn't Exist\n\n**Console**: ```js\n" + err + "```")
}
});
//initial start funtion
client.on("ready", () => {
var statuss = [`${client.users.size} Users | ${config.prefix}help`, `${client.guilds.size} Servers | ${config.prefix}help`]
setInterval(function start() {
log(`(${client.user.username} Bot): ${colors.green(`Online.`)}`);
var rand = statuss[Math.floor(Math.random() * statuss.length)];
global.activity = `${client.guilds.size} Servers | ${config.prefix}help`;
client.user.setActivity(`${rand}`, { type: "WATCHING" });
/* client.user.setActivity(`Under Maintenance`, { type: "WATCHING"}); */
/* client.user.setActivity(`${client.guilds.size} Servers | ${config.prefix}help `, { type: "WATCHING"}); */
client.user.setStatus('online');
return start;
}(), 180000);
// 180000 = 3 mins i think
});
client.on("guildCreate", guild => {
log(`(${config.title}): New guild joined: ${guild.name} (id: ${guild.id})`);
});
client.on("guildDelete", guild => {
log(`(${config.title}): Removed from: ${guild.name} (id: ${guild.id})`);
});
client.on("message", async message => {
if (message.author.bot) return;
if (message.content.indexOf(config.prefix) !== 0) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
// FiveM Bot API -> cdn:1234/api (HTTP)
setInterval(function start() {
let totalSeconds = (client.uptime / 1000);
let hours = Math.floor(totalSeconds / 3600);
totalSeconds %= 3600;
let minutes = Math.floor(totalSeconds / 60);
let seconds = Math.floor(totalSeconds % 60);
let uptime = `${hours} hours, ${minutes} minutes and ${seconds} seconds`;
fs.writeFile('./modules/api.json', `
{
"ping": ${Math.round(client.ping)},
"users": ${client.users.size},
"servers": ${client.guilds.size},
"uptime": ["${hours} hours",
"${minutes} minutes", "${seconds} seconds"],
"news_simplified": "${news}",
"news_html": "${news.html}"
}`,
(err) => {
if (err) { console.error(err) }
});
return start;
}(), 600000);
});
client.login(config.token);